A configuration declares data "aws_ami" "ubuntu" { ... } to look up an image. Which expression passes that image's id to the ami argument of an aws_instance resource?
Choose one.
Every data source is addressed as data.TYPE.NAME.ATTRIBUTE, while a managed resource is addressed as TYPE.NAME.ATTRIBUTE with no prefix.
The block is a data source, so its address starts with data., followed by the type label aws_ami and the name label ubuntu, then the attribute id. Dropping the prefix points at a non-existent managed resource, dropping the type breaks the address, and treating the name as a bracketed key confuses the name label with instance keys from for_each.
- Identify the block type: data, so the address needs the data. prefix.
- Append both labels in order: type aws_ami, then name ubuntu.
- Append the attribute: .id.
Exam tip: Managed resources: TYPE.NAME.attr. Data sources: data.TYPE.NAME.attr.
Terraform Resources, Data Sources, Variables, and Outputs — the lesson that teaches this.