2 Answers
- Newest
- Most votes
- Most comments
0
Hello.
As answered in the question below, I think it can be handled by using StepFunctions or catching the AMI creation completion event with EventBridge, but does that not meet your requirements?
https://repost.aws/ja/questions/QUgemo9BsiTOihjpKQYJd23g/trigger-lambda-with-15-min-delay
0
Hello, I agree on using AWS Step Functions, and I would suggest to adjust your Step Functions state machine to include a wait and retry mechanism:
- After detecting the AMI creation, add a new state to retrieve the snapshot ID associated with the AMI.
- Implement a wait state with a retry loop to check the snapshot status.
- Only proceed to instance creation when the snapshot is available.
You could check the snapshot status with something like the following (in Python)
import boto3
def check_snapshot_status(snapshot_id):
ec2 = boto3.client('ec2')
response = ec2.describe_snapshots(SnapshotIds=[snapshot_id])
snapshot = response['Snapshots'][0]
return snapshot['State'] == 'completed'
answered a year ago
Relevant content
- asked 7 years ago
