2

So the thing is:

I have this resource creation set for AWS Cloudformation using ElasticBeanstalk, which creates additional internal_loadbalancer:

Resources:
IntLB: 
    Type: AWS::ElasticLoadBalancing::LoadBalancer
    Properties:
        ConnectionDrainingPolicy: 
            Enabled: true 
            Timeout: 20
        CrossZone: true
        HealthCheck:
            HealthyThreshold: 3
            Interval: 10
            Target: "TCP"
            Timeout: 5
            UnhealthyThreshold: 5
        Listeners: 
            - InstancePort: 443
              LoadBalancerPort: 443
              Protocol: HTTPS
              SSLCertificateId: arn:aws:acm:
              InstanceProtocol: HTTP
        Scheme: internal
        SecurityGroups: 
            - { "Ref" : "AWSEBLoadBalancerSecurityGroup" }
        Subnets:
            - "subnet-1"
            - "subnet-2"
            - "subnet-3"
            - "subnet-4"
            - "subnet-5"
            - "subnet-6"

AWSEBAutoScalingGroup:
    Type: AWS::AutoScaling::AutoScalingGroup
    Properties: 
        LoadBalancerNames:
            - { "Ref" : "AWSEBLoadBalancer" }
            - { "Ref" : "IntLB" }

What I would like to do is write a condition that if environment_ID = XYZ then apply the creation of the resource and if not ignore it.

I was looking around for AWS documentation and forums but I'm not sure what would be the correct approach.

Any ideas ?

Thanks!

DaWe4444
  • 131
  • 1
  • 2
  • 6

1 Answers1

3

What if you create a condition and apply this to your resource?

Conditions: 
     CreateInternalELB: !Equals [ !Ref AWSEBEnvironmentId, XYZ ]
Resources:
    IntLB: 
        Type: AWS::ElasticLoadBalancing::LoadBalancer
        Condition: CreateInternalELB
        Properties:
            [...]

Change XYZ to your environment id.

I just wrote this on my phone, so please excuse any typos. Not sure either if you can include conditions like this in the EB structure.

Bazze
  • 1,531
  • 10
  • 11