How to mentioned SG name when using dynamic block for Sg rules

HI All,

I have created two SG …elb_sg1 and web_app_sg2.I am already using the dynamic locks for allowing the trafiic but i have aproblem how I can define a security group id in a rule while enetring the values for those variables.

For example I creeated a variable for egress traffic for elb_sg1 from ELB to Web-App.

variable “elb_sg1_egress_rule” {
description = “values must be in sequence [from_port ,to_port, protocol, cidr_blocks, security_group, description]”
type = list(any)

terraform.tfvars ###
elb_sg_egress_rule = [
[80, 80, “tcp”, , [???], “traffic from elb to web-app”]

how I an define the security group id of web_app_sg2 in [???] …i tried many combination but it is not working like referreing the SG id of web_app_sg2 ( with and without interpolation … I am gettign the below error:

Error: Variables not allowed

on terraform.tfvars line 36:
36: elb_sg_egress_rule = [80, 80, “tcp”, , ["${}"], “traffic from
elb to web-app”]

Variables may not be used here.

Has anyone faced such issue or work this out.
Any help/hint will be appreciate.

1 Like