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
asked 10 months ago222 views
1 Answer
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
EXPERT
answered 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions