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
A variable with default = data.aws_ami.latest, passed into the instance.
variable
default = data.aws_ami.latest
A data "aws_ami" block with most_recent = true and filters.
data "aws_ami"
most_recent = true
A resource "aws_ami" block with most_recent = true, referenced by its id.
resource "aws_ami"
id
A locals block that calls lookup("aws_ami", "latest") at plan time.
locals
lookup("aws_ami", "latest")