Lunch EC2 Instance in response to a URL

0

Hi, how do I Lunch an EC2 Instance in response to a URL (https://example.com) ? I have a lead time of 10-15 mins on lunching an EC2 instance, deploying the application and redirect the user to specific service. While the instance launch is in progress, a message should be displayed. I was looking at implementing that via AWS Lambda to start the instance, AWS SSM (Systems Manager) to automate the deployment via ssm_document = 'AWS-RunShellScript'. However, not sure about how the timeout will work OR is there any similar workaround. Any pointers will be highly appreciated. Thanks!

asked 3 months ago121 views
1 Answer
1
Accepted Answer

Hello.

I think it is possible to start EC2 when a URL is accessed by using API Gateway and Lambda.
I think the code provided in the blog below will be helpful for starting EC2.
https://repost.aws/knowledge-center/start-stop-lambda-eventbridge

It is possible to automate the execution of ssm_document by creating an EventBridge and Lambda that react to EC2 launch events.
I think the settings in the following document will be helpful for EC2 startup detection.
https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-log-ec2-instance-state.html
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/monitoring-instance-state-changes.html

Finally, I think it is possible to switch by creating a Lambda that rewrites the A record of "https://example.com" to the EC2 IP after ssm_document execution is complete.

profile picture
EXPERT
answered 3 months ago
profile picture
EXPERT
reviewed a month ago
profile pictureAWS
EXPERT
reviewed 3 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