stop EC2 windows not having activity

0

How can I stop an EC2 instance with a lambda or in any other way when it is detected that it has no activity in the last 15 minutes?

Luis
質問済み 1年前235ビュー
1回答
0
承認された回答

To stop EC2 with Lambda, the code in the following document may be useful.
https://repost.aws/knowledge-center/start-stop-lambda-eventbridge

It seems to me that incorporating a method of detecting no activity in the past 15 minutes into this code would accomplish your requirement.
As for how to get the activity, there is a CloudWatch metric for EC2 called NetworkIn.
How about using the metrics here to alarm and trigger Lambda if the threshold falls below the threshold?
This metric is the amount of network traffic received by EC2, so if the value is low for the past 15 minutes, an alarm is raised to indicate that no communication is being sent to EC2 (EC2 is rarely used).

profile picture
エキスパート
回答済み 1年前
profile picture
エキスパート
レビュー済み 2ヶ月前
  • Thanks for the link. It has served me well. Although I still don't understand or see a way to identify if the Instance hasn't had any activity for the last 15 minutes. I want to shut down the EC2 instance as long as there is no activity on the instance in the last 15 min.

    Thank you

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ