To configure an AWS instance, put named values inside its resource block: `ami` selects an image, `subnet_id` identifies a subnet, and `instance_type` sets the instance type. Each is an argument: a `name = value` assignment that changes how the block behaves. The resource’s type determines which arguments it accepts. section 2.5.1 section 2.2.3
Listing 2.12 Terraform resource with arguments
resource "aws_instance" "hello_world" {
ami = data.aws_ami.ubuntu.id #1
subnet_id = data.aws_subnets.default.ids[0] #1
instance_type = var.instance_type #1
}
The instance’s argument values come from three places: an AMI data source, a subnet data source, and an input variable. An argument value can be a Terraform expression, not just a literal. section 2.2.3
An argument name can appear only once in a block. Do not confuse an object-valued argument, which has an equals sign, with a nested subblock, which does not. Subblocks can normally repeat—for example, a data source can use several `filter` subblocks. section 2.2 section 2.2.3
Arguments also become accessible attributes, so another block can refer to a configured value. A resource may expose additional read-only attributes after a plan or apply; values inside subblocks are not exposed as attributes. Ordinary resource arguments configure infrastructure, while meta arguments tell Terraform how to process a block during planning. Some meta arguments require literal values or values known at plan time. section 2.2.4 section 2.7
