如何在对流层云形成中加入尺度策略?

2024-05-04 15:36:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我创建了一个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(参考(“tintASG”) 文件“/usr/lib/python2.7/site packages/trophosphere/init.py”,第79行,在getattr 引发AttributeError(名称)

应在这一行中确定参考:

^{pr2}$

CloudFormation脚本的部分应该如下所示:

            "tintScaleDown1": {
                    "Type": "AWS::AutoScaling::ScalingPolicy",
                    "Properties": {
            "AdjustmentType": "ChangeInCapacity",
                            "AutoScalingGroupName": {
                                    "Ref": "tintASG"
                            },
                            "Cooldown": "900",
                            "ScalingAdjustment": "-1"
                    }
    },

建议?在


Tags: 文件代码py脚本ref对流层cooldownautoscalinggroupname
2条回答

好吧,所以马克·皮克,对流层的创造者,指出我的语法是不正确的。解决办法是

tintScaleDown.AutoScalingGroupName(Ref("tintASG"))

应该是

^{pr2}$

我会这样回答的。在

from troposphere import Template, autoscaling
t = Template() # Add the template object as "t"
#Create the Autoscaling object as "asg" within the creation of the object, call the template to make the template format
asg = t.add_resource(autoscaling.ScalingPolicy(
    "tintScaleDown1",
    AdjustmentType="ChangeInCapacity",
    AutoScalingGroupName=Ref(tintASG),
    Cooldon="900",
    ScalingAdjustment="-1",

))
print(t.to_json())

相关问题 更多 >