python - 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 文档在这里。
任何建议或帮助将不胜感激。谢谢!
解决方案
我能够解决这个问题。我不确定为什么会出现这种情况,但我能够成功部署 NLB,并通过以下方式启用了取消注册属性。
原始代码
TargetGroupAttribute = [
elb.TargetGroupAttribute(
Key='deregistration_delay.connection_termination.enabled',
Value='true'
)
]
新代码
TargetGroupAttributes = [
elb.TargetGroupAttribute(
Key='deregistration_delay.connection_termination.enabled',
Value='true'
)
]
通过在变量末尾添加“s”解决了该问题。
推荐阅读
- powerbi - PowerBI 财政年度
- bash - 查找的 Bash 排序顺序 - 同名目录之前的文件
- amazon-cognito - 是否总是需要授权人:aws_iam?(使用身份池,支持非授权访问)
- python-3.x - Python Scipy Curvefit 到线性二次曲线
- c++ - 评估模板括号内的 constexpr
- mysql - mysql - 比较 date=n 和 date=n-1 的字符串值
- kubernetes - Kubernetes Pod 到 Pod 通信
- postgresql - 在 PostgreSQL 中存储过滤条件的最佳方式
- delphi - Delphi FMX 中的目录树视图
- time-complexity - TapeEquilibrium O(N*N)