How to Get the Latest OS AMI Id in AWS using Terraform

Guillermo Musumeci
6 min readJan 16, 2020

--

When we need to deploy an EC2 instance in AWS (Amazon Web Services), we will need to get the AMI (Amazon Machine Image) ID of the image based on the AWS region and operating system version.

To achieve this task, we can use the data source “aws_ami” in Terraform.

Get Latest AMI of Amazon Linux

--

--

Guillermo Musumeci

Certified AWS, Azure & GCP Architect | HashiCorp Ambassador | Terraform SME | KopiCloud Founder | ex-AWS | Entrepreneur | Book Author | Husband & Dad of ✌