Difference between revisions of "Terraform data source: aws ami"
Jump to navigation
Jump to search
(23 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
* https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami | * https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami | ||
* [[AWS instance example with aws ami lookup]] | * [[AWS instance example with aws ami lookup]] | ||
+ | * <code>[[hirsute]], [[Ubuntu 22.10 Kinetic Kudu|kinetic]]</code> ([[Ubuntu 22.10 Kinetic Kudu]]), [[Noble Numbat]] | ||
+ | |||
+ | values = ["ubuntu/images/hvm-ssd-[[gp3]]/ubuntu-[[noble]]-24.04-amd64-server-*"] | ||
+ | values = ["ubuntu/images/hvm-ssd/ubuntu-*-23.04-amd64-server-*"] | ||
+ | values = ["[[ubuntu/images/]]hvm-ssd/ubuntu-[[kinetic]]-22.10-amd64-server-*"] | ||
+ | values = ["ubuntu/images/hvm-ssd/ubuntu-[[jammy]]-22.04-amd64-server-*"] | ||
+ | |||
+ | |||
+ | |||
+ | |||
[[data]] "[[aws_ami]]" "my_ubuntu" { | [[data]] "[[aws_ami]]" "my_ubuntu" { | ||
− | most_recent = true | + | [[most_recent]] = true |
[[filter]] { | [[filter]] { | ||
name = "name" | name = "name" | ||
− | values = ["ubuntu/images/hvm-ssd/ubuntu- | + | values = ["ubuntu/images/hvm-ssd/ubuntu-*-23.04-amd64-server-*"] |
} | } | ||
Line 16: | Line 26: | ||
[[owners]] = ["[[099720109477]]"] # [[Canonical]] | [[owners]] = ["[[099720109477]]"] # [[Canonical]] | ||
− | } | + | } |
+ | |||
+ | [[data]] "[[aws_ami]]" "my_ubuntu" { | ||
+ | [[most_recent]] = true | ||
+ | |||
+ | [[filter]] { | ||
+ | name = "name" | ||
+ | values = ["ubuntu/images/hvm-ssd/ubuntu-[[jammy]]-22.04-amd64-server-*"] | ||
+ | } | ||
+ | |||
+ | filter { | ||
+ | name = "virtualization-type" | ||
+ | values = ["hvm"] | ||
+ | } | ||
+ | |||
+ | [[owners]] = ["[[099720109477]]"] # [[Canonical]] | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | {{aws_ami example}} | ||
+ | |||
+ | |||
Line 39: | Line 71: | ||
name = "name" | name = "name" | ||
values = ["[[RHEL]]-7.9_HVM_[[GA]]*-x86_64-0-Hourly2-GP2"] | values = ["[[RHEL]]-7.9_HVM_[[GA]]*-x86_64-0-Hourly2-GP2"] | ||
+ | } | ||
+ | } | ||
+ | |||
+ | == ECS == | ||
+ | data "aws_ami" "ecs_ami" { | ||
+ | most_recent = true | ||
+ | owners = ["591542846629"] | ||
+ | |||
+ | filter { | ||
+ | name = "name" | ||
+ | values = ["[[amzn2-ami-ecs]]-*"] | ||
+ | } | ||
+ | |||
+ | filter { | ||
+ | name = "architecture" | ||
+ | values = ["x86_64"] | ||
+ | } | ||
+ | |||
+ | filter { | ||
+ | name = "virtualization-type" | ||
+ | values = ["hvm"] | ||
} | } | ||
} | } | ||
== Owners == | == Owners == | ||
− | * [[Amazon]]: 591542846629 | + | * [[Amazon]]: [[591542846629]] |
− | * [[Canonical]]: 099720109477 | + | * [[Canonical]]: [[099720109477]] |
== Related == | == Related == | ||
Line 52: | Line 105: | ||
* <code>[[aws_instance]]</code> | * <code>[[aws_instance]]</code> | ||
* <code>[[aws ec2 describe-images --owners self amazon]]</code> | * <code>[[aws ec2 describe-images --owners self amazon]]</code> | ||
− | |||
− | |||
* [[Terraform resource: aws_ami]]</code> | * [[Terraform resource: aws_ami]]</code> | ||
− | * [[self]] | + | * <code>[[self]]</code> |
− | * [[arm64]], [[amd64]] | + | * <code>[[arm64]], [[amd64]]</code> |
− | * [[data.aws_ami]].your_ubuntu.id | + | * <code>[[data.aws_ami]].your_ubuntu.id</code> |
+ | * [[Kinetic]] | ||
+ | * [[data.aws_ami.ubuntu.id]] | ||
+ | * [[forces replacement]] | ||
== See also == | == See also == | ||
* {{aws_ami}} | * {{aws_ami}} | ||
+ | * {{AMI}} | ||
* {{Terraform data sources}} | * {{Terraform data sources}} | ||
[[Category:Terraform]] | [[Category:Terraform]] |
Latest revision as of 11:30, 25 October 2024
- https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami
- AWS instance example with aws ami lookup
hirsute, kinetic
(Ubuntu 22.10 Kinetic Kudu), Noble Numbat
values = ["ubuntu/images/hvm-ssd-gp3/ubuntu-noble-24.04-amd64-server-*"] values = ["ubuntu/images/hvm-ssd/ubuntu-*-23.04-amd64-server-*"] values = ["ubuntu/images/hvm-ssd/ubuntu-kinetic-22.10-amd64-server-*"] values = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"]
data "aws_ami" "my_ubuntu" { most_recent = true filter { name = "name" values = ["ubuntu/images/hvm-ssd/ubuntu-*-23.04-amd64-server-*"] } filter { name = "virtualization-type" values = ["hvm"] } owners = ["099720109477"] # Canonical }
data "aws_ami" "my_ubuntu" { most_recent = true filter { name = "name" values = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"] } filter { name = "virtualization-type" values = ["hvm"] } owners = ["099720109477"] # Canonical }
data "aws_ami" "my_ubuntu" { most_recent = true filter { name = "name" values = ["ubuntu/images/hvm-ssd/ubuntu-hirsute-21.04-amd64-server-*"] } filter { name = "virtualization-type" values = ["hvm"] } owners = ["099720109477"] # Canonical }
data "aws_ami" "amzlinux2" { most_recent = true owners = ["amazon"] filter { name = "name" values = ["amzn2-ami-hvm-*-x86_64-ebs"] } }
Contents
RHEL[edit]
https://dev.to/drewmullen/terraform-boilerplate-common-awsami-searches-5hcg
data "aws_ami" "rhel_7" { most_recent = true owners = ["309956199498"] filter { name = "name" values = ["RHEL-7.9_HVM_GA*-x86_64-0-Hourly2-GP2"] } }
ECS[edit]
data "aws_ami" "ecs_ami" { most_recent = true owners = ["591542846629"] filter { name = "name" values = ["amzn2-ami-ecs-*"] } filter { name = "architecture" values = ["x86_64"] } filter { name = "virtualization-type" values = ["hvm"] } }
Owners[edit]
Related[edit]
- hvm or paravirtual
terraform show | egrep -w "resource|data" | grep -v "#"
aws_availability_zones
aws_instance
aws ec2 describe-images --owners self amazon
- Terraform resource: aws_ami
self
arm64, amd64
data.aws_ami.your_ubuntu.id
- Kinetic
- data.aws_ami.ubuntu.id
- forces replacement
See also[edit]
aws_ami, aws ec2 describe-images
, AMI ARM, aws_instance, data.aws_ami.ubuntu.id- AWS, AMI, AFI,
aws ec2 describe-images
, Amazon Linux, Amazon Linux 2,amazon-linux-extras
, AWS CreateImage - Terraform data sources:
aws_vpc
,template_file
,aws_subnet_ids
,terraform remote state
,aws_eks_cluster
,aws_ami, aws_availability_zones, aws_partition, archive_file
Advertising: