Course contentsShow
← Cloud and Infrastructure
Lesson 740 of 2,98914. Terraform FundamentalsFree lesson

Resource Arguments and Attributes

Learn the difference between required/optional arguments and computed attributes exposed by resources.

Resource Arguments and Attributes

What you'll learn: You'll understand the difference between the inputs you provide to a resource (arguments) and the outputs it generates after creation (attributes).

Arguments: What You Configure

When you define a resource in Terraform, arguments are the configuration values you must or can provide. Think of them as the settings you fill out on a form before submitting it.

Arguments come in two types:

  • Required arguments: Values you must provide for the resource to be created. Without them, Terraform will throw an error.
  • Optional arguments: Values you can provide to customize behavior, but they have reasonable defaults if omitted.

For example, when creating a compute instance, the instance type might be required, while tags might be optional.

Attributes: What Gets Computed

After Terraform creates a resource, the cloud provider generates additional information about it. These are computed attributes — values you can't set directly but can reference later.

Think of attributes as the receipt you get after completing a transaction. You didn't choose the transaction ID, but now you have it and can use it.

Common examples include:

  • Unique identifiers assigned by the provider
  • Auto-generated IP addresses
  • Creation timestamps
  • Connection endpoints

Using Attributes in References

Once a resource exists, you can reference its attributes using the syntax you learned earlier. This lets you pass computed values (like an ID) from one resource to another, creating dependencies.

Key Takeaway: Arguments are the inputs you provide to configure a resource (required or optional), while attributes are the outputs computed by the provider after the resource is created—both are essential for building connected infrastructure.