I have the following code in Terraform. The issue is the image no longer exits and it’s failing to build.
data "aws_ami" "ami_ai_demos" {
most_recent = true
filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-20200323"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
owners = ["099720109477"]
}
I could update values
with the current image but do not want to rebuild the image. Is there anyway to work around this issue?
3
Answers
It was most probably deprecated thus not searchable anymore. Just use direct ami ID for your region instead of filters.
https://cloud-images.ubuntu.com/locator/
cloud-images.ubuntu.com
Thank you for the suggestions. As my requirements are that the EC2 instance is not rebuilt, I will have to remove it from Terraform state. This makes sense as so long as Terraform see’s it it’ll want to act on the resource.
https://www.terraform.io/cli/commands/state/rm
The better option would be to use like this, as this will always pick up the latest image avalaible and your build will not fail.