Search code examples
pythonamazon-web-servicestroposphereaws-nlb

TargetGroup object does not support attribute TargetGroupAttribute


Using Troposphere and Python I have created an AWS NLB. It works fine, I am just trying to add a new property to it. The property I am trying to add is "deregistration_delay.connection_termination.enabled". But when I try and update my stanza It does not like my syntax.

Here is my code block with the TargetGroupAttribute that I am trying to add.

my_target_group = t.add_resource(elb.TargetGroup(
    "MyTargetGroup",
    Name = 'MyTGName',
    Port = os.getenv('PORT'),
    Protocol = os.getenv('PROTOCOL'),
    VpcId = MyVPCid.id,
    HealthCheckIntervalSeconds = os.getenv('HEALTH_CHECK_INTERVAL_SECONDS'),
    HealthCheckPort = os.getenv('PORT'),
    HealthCheckProtocol = os.getenv('HEALTH_CHECK_PROTOCOL'),
    HealthyThresholdCount = os.getenv('HEALTHY_THRESHOLD_COUNT'),
    UnhealthyThresholdCount = os.getenv('UNHEALTHY_THRESHOLD_COUNT'),
    TargetGroupAttribute = [
        elb.TargetGroupAttribute(
            Key='deregistration_delay.connection_termination.enabled',
            Value='true'
        )
    ],
    Targets = build_tg_desc_lst(list_of_instances, os.getenv('PORT'))
))

It does not like the "TargetGroupAttribute" section of the code block I shared. I get the error "TargetGroup object does not support attribute TargetGroupAttribute".

The AWS documentation is here that I used to add the property.

Any advice or help would be greatly appreciated. Thanks!


Solution

  • I was able to resolve the issue. I'm not sure why this was the case but I was able to successfully deploy the NLB with the Deregistration attribute enabled by the following.

    Orginal Code

    TargetGroupAttribute = [
            elb.TargetGroupAttribute(
                Key='deregistration_delay.connection_termination.enabled',
                Value='true'
            )
        ]
    

    New Code

    TargetGroupAttributes = [
            elb.TargetGroupAttribute(
                Key='deregistration_delay.connection_termination.enabled',
                Value='true'
            )
        ]
    

    By adding an 's' at the end of the variable resolved the issue.