Terraform Associate Exam QuestionsBrowse all questions from this exam

Terraform Associate Exam - Question 46


Examine the following Terraform configuration, which uses the data source for an AWS AMI.

What value should you enter for the ami argument in the AWS instance resource?

Show Answer
Correct Answer: C

In Terraform, when using a data source to reference an AWS AMI, the correct syntax to retrieve the AMI ID for use in a resource definition is through the `id` attribute of the data source. Therefore, for the given AWS instance resource, the correct value for the `ami` argument is `data.aws_ami.ubuntu.id`. This ensures that the AMI used is the one specified in the `aws_ami` data source named `ubuntu`.

Discussion

7 comments
Sign in to comment
Jaro3000
Jun 11, 2023

C is correct.

BereOption: C
Aug 3, 2024

In the context of the example given in the question: data "aws_ami" "ubuntu" { most_recent = true filter { name = "name" values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"] } filter { name = "virtualization-type" values = ["hvm"] } owners = ["099720109477"] # Canonical } resource "aws_instance" "web" { ami = data.aws_ami.ubuntu.id instance_type = "t2.micro" tags = { Name = "HelloWorld" } }

EltoothOption: C
Jun 27, 2023

C is correct answer. https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance

Ahmad_Terraform
Jul 13, 2023

data.aws_ami.ubuntu.id

0ptimusOption: C
Sep 11, 2023

data.aws_ami.ubuntu.id

Power123
Mar 31, 2024

Answer is C

Ni33Option: C
May 9, 2024

C is the correct answer