Cloudformation更改Ec2实例状态 [英] Cloudformation to Change Ec2 Instance State

查看:141
本文介绍了Cloudformation更改Ec2实例状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我正在设计Cloudformation模板,以创建EC2实例并监视EC2实例,使用cloudwatch启用详细信息监视,并在达到指标后将实例状态更改为停止

Currently I am designing Cloudformation template to create an EC2 instance and monitor the EC2 instance, enable detail monitoring using cloudwatch and change the instance state to stop once it reached the metrics,

我能够创建一个能够启用指标的实例,但无法将实例状态更改为停止。

I am able to create a instance able to enable metrics but I am not able to change the instance state to stop.

推荐答案

如果您想在指定的stop UserGuide / aws-properties-cw-alarm.html rel = nofollow noreferrer> AWS :: CloudWatch :: Alarm 将资源转换为 ALARM 状态,您可以使用arn:aws:automate:region:ec2:stop ARN完成此操作 http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-alarmaction rel = nofollow noreferrer> Al的AlarmActions 属性

If you want to change the EC2 instance state to stop when a specified AWS::CloudWatch::Alarm Resouce transitions into ALARM state, you can accomplish this using the special arn:aws:automate:region:ec2:stop ARN in the AlarmActions property for the alarm.

但是请注意,在此之前,您需要使用Amazon EC2或CloudWatch控制台手动创建至少一个停止,终止或重新启动警报,以创建警报。 EC2ActionsAccess IAM角色。创建此IAM角色后,您可以直接使用CloudFormation资源创建停止,终止或重新启动警报。请参阅 PutMetricAlarm 文档以获取更多详细信息。

Note however that before this will work, you need to manually create at least one stop, terminate, or reboot alarm using the Amazon EC2 or CloudWatch console to create the EC2ActionsAccess IAM role. After this IAM role is created, you can create stop, terminate, or reboot alarms using the CloudFormation resource directly. See the PutMetricAlarm documentation for more details.

这篇关于Cloudformation更改Ec2实例状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆