Exam Terraform Associate All QuestionsBrowse all questions from this 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?

    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
Jaro3000Option: C

C is correct.

EltoothOption: C

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

BereOption: C

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

data.aws_ami.ubuntu.id

Ni33Option: C

C is the correct answer

Power123Option: C

Answer is C

0ptimusOption: C

data.aws_ami.ubuntu.id