1 Answer
- Newest
- Most votes
- Most comments
0
Hi, yes, it is possible to run a CLI command like the one below to obtain the latest image matching a given name:
aws ec2 describe-images --owners amazon --filters Name=platform,Values=windows --filters "Name=name,Values=Windows_Server*" | jq "[.Images[] | {ImageId: .ImageId ,Name: .Name, CreationDate: .CreationDate}] | sort_by(.CreationDate) | .[-1]"
{
"ImageId": "ami-06277c3639439d32c",
"Name": "Windows_Server-2022-English-Full-ECS_Optimized-2023.07.11",
"CreationDate": "2023-07-17T16:58:12.000Z"
}
If you use an SDK instead of CLI, use same parameters as above adapted to your programming language of choice.
Best,
Didier
Relevant content
- asked a year ago
- Accepted Answerasked a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 months ago
- AWS OFFICIALUpdated 3 months ago
Thanks I will try this out
When I try this, the output is null - aws ec2 describe-images --owners amazon --filters Name=platform,Values=windows --filters "Name=name,Values=CIS Microsoft Windows Server 2022*" | jq "[.Images[] | {ImageId: .ImageId ,Name: .Name, CreationDate: .CreationDate}] | sort_by(.CreationDate) | .[-1]"
Actually this one helped aws ec2 describe-images --owners aws-marketplace --filters Name=platform,Values=windows --filters "Name=name,Values=CIS Microsoft Windows Server 2022*" | jq "[.Images[] | {ImageId: .ImageId ,Name: .Name, CreationDate: .CreationDate}] | sort_by(.CreationDate) | .[-1]" I will check if I can convert it to boto3 SDK