aws ec2 describe-images \
--owners aws-marketplace \
--filters '[
{"Name": "name", "Values": ["CentOS Linux 7*"]},
{"Name": "virtualization-type", "Values": ["hvm"]},
{"Name": "architecture", "Values": ["x86_64"]},
{"Name": "image-type", "Values": ["machine"]}
]' \
--query 'sort_by(Images, &CreationDate)[-1]' \
--region us-east-1 \
--output json
Table format
aws ec2 describe-images \
--owners aws-marketplace \
--filters Name=product-code,Values=aw0evgkw8e5c1q413zgy5pjce \
--query 'Images[*].[CreationDate,Name,ImageId]' \
--filters "Name=name,Values=CentOS Linux 7*" \
--region us-west-2 \
--output table \
| sort -r
data "aws_ami" "linux-node" {
most_recent = true
owners = ["aws-marketplace"]
filter {
name = "name"
values = ["CentOS Linux 7*"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
filter {
name = "architecture"
values = ["x86_64"]
}
filter {
name = "image-type"
values = ["machine"]
}
}
aws ec2 describe-images \
--owners amazon \
--filters '[
{"Name": "name", "Values": ["Windows_Server-2016-English-Full-Containers-*"]},
{"Name": "virtualization-type", "Values": ["hvm"]}
]' \
--query 'sort_by(Images, &CreationDate)[-1]' \
--region us-east-1 \
--output json
aws ec2 describe-images \
--owners amazon \
--filters '[
{"Name": "name", "Values": ["Windows_Server-2019-English-Core-Containers*"]},
{"Name": "virtualization-type", "Values": ["hvm"]}
]' \
--query 'sort_by(Images, &CreationDate)[-1]' \
--region us-east-1 \
--output json
aws ec2 describe-images \
--owners amazon \
--query 'Images[*].[CreationDate,Name,ImageId]' \
--filters "Name=name,Values=Windows_Server-2019*" \
--region us-east-1 \
--output table \
| sort -r
aws ec2 describe-images \
--owners amazon \
--query 'Images[*].[CreationDate,Name,ImageId]' \
--filters "Name=name,Values=Windows_Server-2019-English-Full-Containers*" \
--region us-east-1 \
--output table \
| sort -r
data "aws_ami" "win-node" {
most_recent = true
owners = ["amazon"]
filter {
name = "name"
values = ["Windows_Server-2019-English-Core-Containers*"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
}
data "aws_ami" "workstation" {
most_recent = true
owners = ["amazon"]
filter {
name = "name"
values = ["Windows_Server-2016-English-Full-Containers-*"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
}
aws ec2 describe-images \
--owners 309956199498 \
--query 'Images[*].[CreationDate,Name,ImageId]' \
--filters "Name=name,Values=RHEL-7.?*GA*" \
--region us-east-1 \
--output table \
| sort -r
data "aws_ami" "linux-node" {
most_recent = true
owners = ["309956199498"]
filter {
name = "name"
values = ["RHEL-7.*GA*"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
}