Search code examples
amazon-ec2terraform-provider-awsamazon-ami

How to define terraform aws_ami resource for Fedora Atomic Amazon Machine Image (ami)


I am trying to use terraform to get an aws_ami data resource as follows:

data "aws_ami" "fedora_atomic" {
  most_recent = true

  filter {
    name   = "name"
    values = [
      "ubuntu/images/hvm-ssd/ubuntu-trusty-14.04-amd64-server-*"] <==== What to specify here?
  }

  filter {
    name   = "virtualization-type"
    values = [
      "hvm"]
  }

  owners = [
    "099720109477"]  <=== What's the owner id?
  # Canonical
}

But I want to replace the above with the following image desription, which I found on the AWS console:

Fedora-Atomic-25-20170727.0.x86_64-us-east-1-HVM-standard-0 - ami-00035c7b

Question How do I find the right values for the fields above i.e. what is the correct code for the above for a Fedora Atomic image?

I am struggling to find this information.

Many Thanks


Solution

  • Fedora Atomic has been EOL since 2019 and you won't find new AMIs but to answer your question, the owner is the Account ID and you can find it from the AWS Console

    enter image description here

    The name can be part of what is available in the description, ie Fedora-Atomic-25-

    Combining them all

    data "aws_ami" "fedora_atomic" {
      most_recent = true
    
      filter {
        name   = "name"
        values = ["Fedora-Atomic-25-*"]
      }
    
      filter {
        name   = "virtualization-type"
        values = [ "hvm"]
      }
    
      owners = ["125523088429"] 
    }
    
    output "ami" {
       value = data.aws_ami.fedora_atomic.id
    }