How can you configure a Terraform workspace to store its state remotely?
A.
Add a cloud block inside the terraform block.
B.
Add a backend block inside the terraform block.
C.
Set the TERAFORM_CLOUD environment variable.
D.
Set the TERRAFORM_BACKEND environment variable.
The Answer Is:
A
This question includes an explanation.
Explanation:
Detailed Explanation:
Rationale for Correct Answer: To configure Terraform to use HCP Terraform for remote state storage and workspace-based runs, you add a cloud block inside the terraform block. The cloud block specifies the HCP Terraform organization and workspace configuration.
Analysis of Incorrect Options (Distractors):
B. Add a backend block inside the terraform block. This is valid for configuring other remote backends, such as S3, AzureRM, or GCS. However, for HCP Terraform workspaces, the modern and recommended configuration is the cloud block.
C. Set the TERAFORM_CLOUD environment variable. Incorrect. This environment variable is misspelled and is not how Terraform configures remote state.
D. Set the TERRAFORM_BACKEND environment variable. Incorrect. Terraform does not use this environment variable to configure a backend.
Key Concept: HCP Terraform remote state and workspace integration are configured using the cloud block.