Which type of block fetches or computes information for use elsewhere in a Terraform configuration?

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 type of block fetches or computes information for use elsewhere in a Terraform configuration?

Explanation:
Data sources fetch information from the provider so you can use it elsewhere in your configuration. By declaring a data block, Terraform looks up existing resources or computes values at plan time and exposes them as attributes you can reference in other resources or outputs. This is different from a resource block, which creates or manages infrastructure; a provider block, which configures the connection to the provider; and a local block, which computes values locally using Terraform expressions without pulling live data from the provider. For example, you can fetch the most recent AMI with a data block and then reference its ID when creating an instance.

Data sources fetch information from the provider so you can use it elsewhere in your configuration. By declaring a data block, Terraform looks up existing resources or computes values at plan time and exposes them as attributes you can reference in other resources or outputs. This is different from a resource block, which creates or manages infrastructure; a provider block, which configures the connection to the provider; and a local block, which computes values locally using Terraform expressions without pulling live data from the provider. For example, you can fetch the most recent AMI with a data block and then reference its ID when creating an instance.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy