Skip to content

Repository files navigation

terraform-aws-ami-search

About

Terraform module to find the last version of an AWS Ami IDs for working region, using common os name.

License

License: MIT

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files, to deal in the Software
without restriction.

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.

Source: https://opensource.org/licenses/MIT

See LICENSE for full details.

Authors

Documentation

Requirements

Name Version
terraform >= 0.13
aws >= 2.0
null >= 3.0

Modules

No modules.

Resources

Name Type
null_resource.this resource
aws_ami.this data source

Inputs

Name Description Type Default Required
allow_eof_ami Ability to use images that are no longer supported and have reached their end of life date. Default value is false and we do not suggest changing it. bool false no
architecture The architecture of the image. Available values: x86_64*, arm64. string "x86_64" no
os The OS reference name. Available vaules: ubuntu-18.04, ubuntu-20.04, ubuntu-22.04, ubuntu-24.04, debian-10, debian-11, debian-12, amazon2, al2023. string n/a yes
virtualization_type Keyword to choose what virtualization mode created instances will use. Available values: paravirtual*, hvm. string "hvm" no

Outputs

Name Description
ami_id The AMI id result of the search
owner_id The owner id of the selected ami
root_device_name The device name of the root dev

Examples

module "app_prod_ec2_label" {
  source  = "cloudposse/label/null"
  version = "v0.25.0"

  namespace  = "app"
  stage      = "prod"
  name       = "jumphost"
  attributes = ["private"]
  delimiter  = "-"

  tags = {
    "BusinessUnit" = "XYZ",
  }
}


module "ami" {
  source = "../../"
  os     = "amazon2"
}

resource "aws_instance" "instance" {
  instance_type = var.instance_type
  ami           = module.ami.ami_id
  tags          = module.app_prod_ec2_label.tags
}

Supported versions matrix

OS Name Version Owner Id Regex EOL
Ubuntu 18.04 099720109477 ^ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-.*-server-.* 31/05/2023
Ubuntu 20.04 099720109477 ^ubuntu/images/hvm-ssd/ubuntu-focal-20.04-.*-server-.* 02/04/2025
Ubuntu 22.04 099720109477 ^ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-.*-server-.* 01/04/2027
Ubuntu 24.04 099720109477 ^ubuntu/images/hvm-ssd/ubuntu-noble-24.04-.*-server-.* 25/04/2029
Debian 10 136693071363 ^debian-10-.* 30/06/2026
Debian 11 136693071363 ^debian-11-.* 31/08/2026
Debian 12 136693071363 ^debian-12-.* 10/06/2028
Amazon Linux 2 137112412989 ^amzn2-ami-hvm-.*x86_64-gp2 30/06/2025
Amazon Linux 2023 137112412989 al2023-ami-2023.* 15/03/2028

About

Terraform module to find the last version of an AWS Ami IDs for working region

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages