-
-
Save AlainODea/5b6466a5df07a6ee0c92e34f60f24c65 to your computer and use it in GitHub Desktop.
resource "aws_ami_copy" "amazon-linux-2-encrypted" { | |
name = "${data.aws_ami.amazon-linux-2.name}-encrypted" | |
description = "${data.aws_ami.amazon-linux-2.description} (encrypted)" | |
source_ami_id = "${data.aws_ami.amazon-linux-2.id}" | |
source_ami_region = "${var.region}" | |
encrypted = true | |
tags { | |
ImageType = "encrypted-amzn2-linux" | |
} | |
} | |
data "aws_ami" "amazon-linux-2" { | |
most_recent = true | |
filter { | |
name = "owner-alias" | |
values = ["amazon"] | |
} | |
filter { | |
name = "name" | |
values = ["amzn2-ami-hvm-*-x86_64-ebs"] | |
} | |
} |
you now need to set
owners = "amazon"
instead of using the owner-alias.
https://www.terraform.io/docs/providers/aws/d/ami.html
Thank you. This was done for Terraform v0.11.3 and aws provider v1.60.0. I've updated the title to show that constraint now. I didn't anticipate that this would be broken by future releases. I appreciate you identifying this gap.
And now you need to set owners = ["amazon"]
@steadysupply wrote:
And now you need to set
owners = ["amazon"]
Not for Terraform v0.11.3 and aws provider v1.60.0, which this was written for. I'm guessing your comment is intended for other people hitting this as a search result.
Can you explain when this changed for their benefit?
The least I can say is it is the fact for 14 Terraform
thanks.
Thanks! This worked for me as of today everything latest.
data "aws_ami" "i" {
owners = ["amazon"]
most_recent = true
filter {
name = "name"
values = ["amzn2-ami-hvm-*-x86_64-ebs"]
}
}
If using CDKTF python
amazon_linux_2 = ec2.DataAwsAmi(self, "amazon-linux-2",
most_recent=True,
owners=["amazon"],
filter=[
ec2.DataAwsAmiFilter(
name="name",
values=["amzn2-ami-hvm-*-x86_64-ebs"]
)
]
)
data "aws_ami" "base_ami" {
most_recent = true
owners = ["amazon"]
filter {
name = "name"
values = ["al2023-ami-2023.*-x86_64"]
}
filter {
name = "architecture"
values = ["x86_64"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
}
al2023-ami-2023.*-x86_64 => this one is enough of you and x86_64 and hvm added additionally,
I got the info from: https://www.thelinuxfaq.com/937-how-can-i-get-latest-ami-id-for-aws-instance
you now need to set
owners = "amazon"
instead of using the owner-alias.https://www.terraform.io/docs/providers/aws/d/ami.html