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
Jaro3000Option: C
Jun 11, 2022

C is correct.

EltoothOption: C
Jun 27, 2022

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

BereOption: C
Aug 3, 2023

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" } }

Ahmad_TerraformOption: C
Jul 13, 2022

data.aws_ami.ubuntu.id

0ptimusOption: C
Sep 11, 2022

data.aws_ami.ubuntu.id

Power123Option: C
Mar 30, 2023

Answer is C

Ni33Option: C
May 9, 2023

C is the correct answer