Run Commandの実行結果をLamdbaで受け取る方法

0

AWSにてRunCommandの成否をLamdbaで受け取る方法はありますでしょうか。 記事を漁りましたが記述が見つからず、有識者の方おりましたらご教授頂ければ幸いです。

demandé il y a un an292 vues
1 réponse
0

EventBridge で Run Command の実行結果の成否を検知し、任意の Lambda 関数を起動することはできるかと思います。

参考: チュートリアル: EventBridge を使用した AWS Lambda 関数の schedule https://docs.aws.amazon.com/ja_jp/eventbridge/latest/userguide/eb-run-lambda-schedule.html

EventBridge で Run Command の実行結果の成否を検知するには、例えば以下のようなイベントルールを設定します。

{
  "source": ["aws.ssm"],
  "detail-type": ["EC2 Command Status-change Notification"],
  "detail": {
    "status": ["Success", "TimedOut", "Failed"]
  }
}

EventBridge から Lambda へは以下のようなイベントが送信されます。
インスタンスID: i-abcd1111 および i-abcd2222 に対する AWS-RunPowerShellScript の実行が成功した際のイベント例:

{
  "version": "0",
  "id": "51c0891d-0e34-45b1-83d6-95db273d1602",
  "detail-type": "EC2 Command Status-change Notification",
  "source": "aws.ssm",
  "account": "123456789012",
  "time": "2016-07-10T21:51:32Z",
  "region": "us-east-1",
  "resources": ["arn:aws:ec2:us-east-1:123456789012:instance/i-abcd1111", "arn:aws:ec2:us-east-1:123456789012:instance/i-abcd2222"],
  "detail": {
    "command-id": "e8d3c0e4-71f7-4491-898f-c9b35bee5f3b",
    "document-name": "AWS-RunPowerShellScript",
    "expire-after": "2016-07-14T22:01:30.049Z",
    "parameters": {
      "executionTimeout": ["3600"],
      "commands": ["date"]
    },
    "requested-date-time": "2016-07-10T21:51:30.049Z",
    "status": "Success"
  }
}
profile picture
hayao-k
répondu il y a un an

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions