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!

質問済み 4ヶ月前126ビュー
1回答
1
承認された回答

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
エキスパート
回答済み 4ヶ月前
profile picture
エキスパート
レビュー済み 2ヶ月前
profile pictureAWS
エキスパート
レビュー済み 4ヶ月前

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

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

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

関連するコンテンツ