微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

TargetGroup 对象不支持属性 TargetGroupAttribute

如何解决TargetGroup 对象不支持属性 TargetGroupAttribute

我使用对流层和 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 文档是我用来添加属性here

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

解决方法

我能够解决这个问题。我不知道为什么会这样,但我能够成功部署 NLB,并通过以下方式启用取消注册属性。

原始代码

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

新代码

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

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。