Reading Data with Data Sources
Instead of hard-coding an AMI ID, you want Terraform to look up the latest Amazon Linux AMI at plan time and use its ID for an instance. What do you write?
Choose one answer
An output block that returns the newest AMI.
output
A data "aws_ami" block with most_recent = true and filters, referenced as data.aws_ami.al.id.
data "aws_ami"
most_recent = true
data.aws_ami.al.id
A resource "aws_ami" block that builds a new AMI.
resource "aws_ami"
A locals block that contains the AMI ID.
locals