Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create an alb security group in for loop #267

Open
bsushant-athena opened this issue May 18, 2020 · 0 comments
Open

create an alb security group in for loop #267

bsushant-athena opened this issue May 18, 2020 · 0 comments

Comments

@bsushant-athena
Copy link

bsushant-athena commented May 18, 2020

hi there, I've 10 arrays with list of IP's and I want to create a security group out of each one. I want to do this inside a for loop. i'm getting problem on the line 11...bold and added comment. Please suggest a way to achieve this

for i in 1..(10) do
	    resources (x_alb_security_group_#{i}") do
	        deletion_policy "Retain"
	        on_condition! :should_create_elb
	        type 'AWS::EC2::SecurityGroup'
	        properties do
	            group_description 'x -elb non-prod security group'
	            vpc_id attr!(:vpc_info_invoker, 'primaryVpcId')
	        end
	    end
##getting error below here >>
    **"_white_list#{i}".each_with_index do |security_ip, i|**
      resources("alb_ingress_rule_#{i}") do
        type "AWS::EC2::SecurityGroupIngress"
        properties do
          group_id ref!("x_alb_security_group_1")
          from_port 80
          to_port 80
          ip_protocol "tcp"
          cidr_ip security_ip
        end
      end
      resources("alb_ingress_rule_#{i + _white_list"#{i}".length}") do
        type "AWS::EC2::SecurityGroupIngress"
        properties do
          group_id ref!("x_alb_security_group_#{i}")
          from_port 443
          to_port 443
          ip_protocol "tcp"
          cidr_ip security_ip
        end
      end
    end
end	
@bsushant-athena bsushant-athena changed the title create a alb security group in for loop create an alb security group in for loop May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant