When dealing with large EBS volumes (like your 1TB volume with 750GB data), snapshots can take significant time to complete. The AWS Management Console shows the start time but doesn't explicitly display the completion timestamp.
Here's how to programmatically check when your snapshot actually finished:
aws ec2 describe-snapshots --snapshot-ids snap-1234567890abcdef0 \
--query 'Snapshots[0].{StartTime: StartTime, State: State, Progress: Progress}' \
--output json
For automation purposes, you can use AWS SDKs. Here's a Python example using Boto3:
import boto3
from datetime import datetime
ec2 = boto3.client('ec2')
def get_snapshot_completion_time(snapshot_id):
response = ec2.describe_snapshots(SnapshotIds=[snapshot_id])
snapshot = response['Snapshots'][0]
if snapshot['State'] == 'completed':
# AWS doesn't provide completion time directly, but we can:
# 1. Check the latest event in CloudTrail
# 2. Or monitor the state change programmatically
print(f"Snapshot started at: {snapshot['StartTime']}")
# Alternative: Check CloudTrail events
cloudtrail = boto3.client('cloudtrail')
events = cloudtrail.lookup_events(
LookupAttributes=[
{
'AttributeKey': 'ResourceName',
'AttributeValue': snapshot_id
}
],
MaxResults=1
)
if events['Events']:
return events['Events'][0]['EventTime']
return None
For critical workflows, consider implementing a monitoring solution:
import time
def monitor_snapshot(snapshot_id, poll_interval=300):
while True:
response = ec2.describe_snapshots(SnapshotIds=[snapshot_id])
snapshot = response['Snapshots'][0]
if snapshot['State'] == 'completed':
completion_time = datetime.now()
print(f"Snapshot completed at: {completion_time}")
return completion_time
print(f"Current progress: {snapshot['Progress']}%")
time.sleep(poll_interval)
Set up a CloudWatch Event to trigger when the snapshot completes:
aws events put-rule \
--name "EBS-Snapshot-Completed" \
--event-pattern '{
"source": ["aws.ec2"],
"detail-type": ["EBS Snapshot Notification"],
"detail": {
"event": ["createSnapshot"],
"result": ["succeeded"]
}
}'
- First snapshots take longer than subsequent incremental snapshots
- Performance is affected by volume size and instance activity
- Network throughput impacts cross-region snapshots
When working with AWS EC2 EBS snapshots, especially for large volumes (like our 1TB volume with 750GB data), the actual completion time isn't immediately visible in the AWS Console. While the Management Console shows the start time and progress percentage, the precise completion timestamp requires deeper inspection.
The most reliable method is using AWS CLI to query the completion timestamp:
aws ec2 describe-snapshots --snapshot-ids snap-1234567890abcdef0 \
--query 'Snapshots[0].{StartTime: StartTime, State: State, Progress: Progress}'
This returns a JSON response showing the exact start time but not completion time. To get completion details, we need to examine CloudTrail logs.
CloudTrail captures the complete API activity. Use this command to find the completion event:
aws cloudtrail lookup-events \
--lookup-attributes AttributeKey=EventName,AttributeValue=CompleteSnapshot \
--start-time "2023-01-01T00:00:00Z" \
--end-time "2023-01-02T00:00:00Z" \
--query "Events[].CloudTrailEvent" \
--output text | jq -r '. | select(.requestParameters.snapshotId == "snap-1234567890abcdef0")'
This returns detailed JSON including the exact completion timestamp.
For automated tracking, use the AWS SDK. Here's a Python example using boto3:
import boto3
import time
from datetime import datetime
def monitor_snapshot_completion(snapshot_id):
ec2 = boto3.client('ec2')
cloudtrail = boto3.client('cloudtrail')
# Get snapshot start time
snapshot = ec2.describe_snapshots(SnapshotIds=[snapshot_id])['Snapshots'][0]
start_time = snapshot['StartTime']
# Poll CloudTrail for completion event
while True:
events = cloudtrail.lookup_events(
LookupAttributes=[{
'AttributeKey': 'EventName',
'AttributeValue': 'CompleteSnapshot'
}],
StartTime=start_time,
EndTime=datetime.utcnow()
)
for event in events['Events']:
event_detail = json.loads(event['CloudTrailEvent'])
if event_detail['requestParameters']['snapshotId'] == snapshot_id:
completion_time = event['EventTime']
print(f"Snapshot completed at: {completion_time}")
return completion_time
time.sleep(300) # Check every 5 minutes
monitor_snapshot_completion('snap-1234567890abcdef0')
You can configure a CloudWatch Event Rule to trigger when the snapshot completes:
aws events put-rule \
--name "SnapshotCompletion" \
--event-pattern '{
"source": ["aws.ec2"],
"detail-type": ["EBS Snapshot Notification"],
"detail": {
"event": ["createSnapshot"],
"result": ["succeeded"]
}
}'