配置Elastic-Beanstalk负载平衡器安全组

时间:2019-01-11 14:24:58

标签: amazon-web-services terraform amazon-elastic-beanstalk

我尝试为具有Terraform的Elastic-Beanstalk负载平衡器配置安全组

我尝试了以下选项,其中eb-ec2-security-group对eb-lb-security-group源具有入站规则:

setting {
    namespace = "aws:elasticbeanstalk:environment"
    name      = "LoadBalancerType"
    value     = "application"
}
setting {
    namespace = "aws:autoscaling:launchconfiguration"
    name = "SecurityGroups"
    value = "${aws_security_group.eb-ec2-security-group.id}"
}
setting {
    namespace = "aws:elb:loadbalancer"
    name = "SecurityGroups"
    value = "${aws_security_group.eb-lb-security-group.id}"
}
setting {
    namespace = "aws:elb:loadbalancer"
    name = "ManagedSecurityGroup"
    value = "${aws_security_group.eb-lb-security-group.id}"
}

但是它仍然会创建使用其自己的安全组的负载均衡器。我发现了这个问题Disable automatic security group naming in Elastic Beanstalk,但是对于Terraform来说,设置ManagedSecurityGroup不适用于我。

1 个答案:

答案 0 :(得分:0)

将名称空间更改为aws:elbv2:loadbalancer对我有用

setting {
    namespace = "aws:elbv2:loadbalancer"
    name = "SecurityGroups"
    value = "${aws_security_group.eb-lb-security-group.id}"
}
setting {
    namespace = "aws:elbv2:loadbalancer"
    name = "ManagedSecurityGroup"
    value = "${aws_security_group.eb-lb-security-group.id}"
}

并且无需为ec2实例显式创建安全组来为loadbalancer配置inboud规则,因为它会自动创建它。