I need to get 5 colums reported from awscli. These are, last snapshot taken for instance, the date it was taken, the tag used if any, the name tag of the instance and the instance i.d.
The below will list ALL snapshots and the time taken and a 'null' name gets reported...
aws ec2 describe-snapshots --query 'Snapshots[*].{ID:SnapshotId,Time:StartTime,Name:Tags[?Key==`Name`]|[0].Value}'
This will give me the description of the snapshot, the snap id and the date:
aws ec2 describe-snapshots --owner self --output json | jq '.Snapshots[] | select(.StartTime < "'$(date --date='-1 month' '+%Y-%m-%d')'") | [.Description, .StartTime, .SnapshotId]'
So basically I have something that gives me the snapshot data, will query on date and tell me what time it was taken but I'm missing the full requirement all in one.
I guess the main stumbling block for me is how to only report on the last snapshot that was taken for an instance. Can anyone please help?