Start EC2 instances event base.

0

I would like to start an ec2 instance event base. Suppose instance is stopped and when someone trying to SSH/RDP or by running a python script, instance should start may be through lambda function or using event bridge.

Sisir
已提問 10 個月前檢視次數 233 次
1 個回答
0

What about triggering the connection in the Systems Manager session manager to start Lambda?
This would allow us to run Lambda and launch EC2 when Amazon EventBridge detects a session manager event.
Below is an example of an Amazon EventBridge event pattern.

{
  "source": ["aws.ssm"],
  "detail-type": ["AWS API Call via CloudTrail"],
  "detail": {
    "eventSource": ["ssm.amazonaws.com"],
    "eventName": ["StartSession"],
    "requestParameters": {
      "target": ["EC2 ID"]
    }
  }
}

Another possibility would be to enable VPC flow logging and use CloudWatch Logs subscription filters to share logs to Lambda when there is an SSH connection.
https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/SubscriptionFilters.html#LambdaFunctionExample

Please refer to the example in the following document for the Lambda function to be used for startup.
https://repost.aws/knowledge-center/start-stop-lambda-eventbridge

profile picture
專家
已回答 10 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南