问题
anyone know how to synchronously call AWS Lambda when my new AMI is available? I'd like emphasize that I'm interested in AMI's available state, not just pending. Basically I'm looking for something like RDS Event for EC2.
Flow: CreateAMIAPICall --> AMI ami-abc123 is beeing created (pending) --> AMI ami-abc123 is available --> ? --> TRIGGER AWS LAMBDA
回答1:
You did not state the language you are using in Lambda, but boto3
has the capability!
From EC2 — Boto 3 Docs:
waiter = client.get_waiter('image_available')
Polls
EC2.Client.describe_images()
every 15 seconds until a successful state is reached. An error is returned after 40 failed checks.
回答2:
There isn't an event type like this which is generated when CreateImage is called and subsequently a new AMI becomes ready to use
You'll just have to poll for the state with DescribeImages
来源:https://stackoverflow.com/questions/51704471/notify-when-ami-available