AWS CloudWatch启动/停止EC2实例 [英] AWS CloudWatch to start/stop EC2 instances

查看:235
本文介绍了AWS CloudWatch启动/停止EC2实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是寻找启动/停止AWS EC2实例的方法,以防CPU利用率因另一个EC2实例的增加或降低而降低。我知道AWS中有Auto Scaling服务可用,但我遇到无法利用该服务的情况。

Just looking the way to start/stop a AWS EC2 instance in case of CPU utilization increase or decrease on another EC2 instacne. I know there is service available Auto Scaling in AWS but I have a scenario where I can't take advantage of this service.

因此,仅查看是否有可能或任何人可以帮助我解决这个问题。

So just looking if it is possible or anyone can help me on this.

只需详细说明问题,例如假设我在AWS账户上有2个EC2实例,名称分别为EC21和EC22。默认情况下,EC22实例处于停止状态。

Just detailing the concern like suppose I have 2 EC2 instance on AWS account by name EC21 and EC22. By default, EC22 instance is stopped.

现在,我需要设置CloudWatch或任何其他服务来检查EC21实例上的负载/ CPU利用率是否增加了70%,然后需要启动EC22服务器,并且类似地,如果EC21实例上的负载减少30%,则停止EC22服务器。

Now I need to setup CloudWatch or any other service to check if load/CPU utilization increase on EC21 instance by 70% then need to start EC22 server and similarly if load decrease on EC21 instance by 30% then stop EC22 server.

请咨询!

推荐答案

触发CloudWatch警报时,它将通知SNS主题。您可以拥有该SNS主题,然后调用Lambda函数,然后可以启动EC2实例。

When your CloudWatch alarm is triggered, it will notify an SNS topic. You can have that SNS topic then invoke a Lambda function, which can then start your EC2 instance.


  1. 创建一个AWS Lambda函数来启动您的EC2实例。 EC2实例。

  2. 配置SNS主题以在接收消息时调用Lambda函数。您可以在此处阅读有关内容:使用Amazon SNS通知调用Lambda函数

  3. 最后,确保您的CloudWatch警报将消息发送到SNS主题。

这篇关于AWS CloudWatch启动/停止EC2实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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