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?
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?
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`.
C is correct.
C is correct answer. https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance
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" } }
data.aws_ami.ubuntu.id
C is the correct answer
Answer is C
data.aws_ami.ubuntu.id