我创建了一个 python 对流层脚本,总体上运行良好。我刚刚添加了一段新代码,以将策略添加到自动缩放组以发出警报。
代码如下所示:
tintScaleDown = autoscaling.ScalingPolicy("tintScaleDown1")
tintScaleDown.AdjustmentType = "ChangeInCapacity"
tintScaleDown.AutoScalingGroupName(Ref("tintASG"))
tintScaleDown.Cooldown = "900"
tintScaleDown.ScalingAdjustment = "1"
t.add_resource(tintScaleDown)
错误是:
回溯(最后一次调用):文件“inPowered.py”,第 395 行,在 tintScaleDown.AutoScalingGroupName(Ref("tintASG")) 文件“ /usr/lib/python2.7/site-packages/troposphere/init .py ",第 79 行,在getattr中 引发 AttributeError(name)
参考应该已经建立在这一行:
asg = autoscaling.AutoScalingGroup("tintASG")
CloudFormation 脚本的部分应如下所示:
"tintScaleDown1": {
"Type": "AWS::AutoScaling::ScalingPolicy",
"Properties": {
"AdjustmentType": "ChangeInCapacity",
"AutoScalingGroupName": {
"Ref": "tintASG"
},
"Cooldown": "900",
"ScalingAdjustment": "-1"
}
},
建议?