Skip to content

Snapshot is in pending

0

i automated the process of creating the instance whenever a ami with certain name is created. Since this is a automated and a near real time process instance creation is failing saying snapshot is in pending state. (ami is available). i want a mechanism to get when snapshot also available (progress -100%) to automate my work im using lambda, state machine and event bridge currently

2 Answers
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

EXPERT
answered a year ago
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:

  1. After detecting the AMI creation, add a new state to retrieve the snapshot ID associated with the AMI.
  2. Implement a wait state with a retry loop to check the snapshot status.
  3. 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'
AWS
answered a year 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.