首页 > 解决方案 > TargetGroup 对象不支持属性 TargetGroupAttribute

问题描述

我使用 Troposphere 和 Python 创建了一个 AWS NLB。它工作正常,我只是想向它添加一个新属性。我要添加的属性是“deregistration_delay.connection_termination.enabled”。但是当我尝试更新我的节时,它不喜欢我的语法。

这是我尝试添加的带有 TargetGroupAttribute 的代码块。

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'))
))

它不喜欢我共享的代码块的“TargetGroupAttribute”部分。我收到错误“TargetGroup 对象不支持属性 TargetGroupAttribute”。

我用来添加属性的 AWS 文档在这里。

任何建议或帮助将不胜感激。谢谢!

标签: pythonamazon-web-servicestroposphereaws-nlb

解决方案


我能够解决这个问题。我不确定为什么会出现这种情况,但我能够成功部署 NLB,并通过以下方式启用了取消注册属性。

原始代码

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

新代码

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

通过在变量末尾添加“s”解决了该问题。


推荐阅读