Which expression correctly references the ID attribute of a data source named ubuntu with type aws_ami?

Prepare for the HashiCorp Terraform Associate Exam with quizzes, flashcards, and multiple-choice questions. Each question includes hints and explanations. Boost your confidence and ace your exam!

Multiple Choice

Which expression correctly references the ID attribute of a data source named ubuntu with type aws_ami?

Explanation:
Accessing attributes of a data source in Terraform uses the pattern data.<TYPE>.<NAME>.<ATTRIBUTE>. For a data source of type aws_ami named ubuntu, the ID attribute is accessed as data.aws_ami.ubuntu.id. This is the correct expression because it first identifies the data source (data), then its type (aws_ami), then its given name (ubuntu), and finally the attribute you want (id). The other forms don’t follow this syntax: omitting the data prefix or misplacing the segments would refer to the wrong object or fail to reference the attribute at all.

Accessing attributes of a data source in Terraform uses the pattern data.... For a data source of type aws_ami named ubuntu, the ID attribute is accessed as data.aws_ami.ubuntu.id. This is the correct expression because it first identifies the data source (data), then its type (aws_ami), then its given name (ubuntu), and finally the attribute you want (id). The other forms don’t follow this syntax: omitting the data prefix or misplacing the segments would refer to the wrong object or fail to reference the attribute at all.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy