Terraform-Associate-004 practice question 9 of 35

You can access state stored with the local backend by using terraform_remote_state data source.

Full set: 360 questions
Answer options
A: True
B: False
Correct Answer:
[TRUE]
Explanation

The terraformremotestate data source is used to fetch the root module outputs of a separate Terraform configuration. While its name implies it is only for remote backends (like S3, AzureRM, or Terraform Cloud), it is also explicitly designed to work with state files stored on the local filesystem. To achieve this, the backend argument within the data source block is set to "local", and the config block must specify the path to the terraform.tfstate file.

Why Incorrect

The statement is not False. A common misconception is that the terraformremotestate data source can only target backends that are network-accessible or "remote." However, the official implementation and documentation confirm that "local" is a valid backend type for this data source, allowing it to read state files directly from the local disk.

References

1. HashiCorp Terraform Documentation, terraformremotestate Data Source: The official documentation provides a direct example of this usage. In the "Example Usage" section, it shows how to configure the data source with backend = "local" and a config block containing the path to the state file.

Source: HashiCorp, Terraform Documentation.

Reference: Data Sources > terraformremotestate > Example Usage. The example explicitly states:

hcl

data "terraformremotestate" "vpc" {

backend = "local"

config = {

path = "../vpc/terraform.tfstate"

}

}

2. HashiCorp Terraform Documentation, Backends - local: This page describes the local backend, which stores the state file on the local filesystem. The terraformremotestate data source can be configured to read from a state file managed by this backend type.

Source: HashiCorp, Terraform Documentation.

Reference: Terraform > Backends > Types > local. This page confirms that the local backend stores state in a local file named terraform.tfstate by default, which is the target file for the terraformremotestate data source when using the local backend type.

Scroll to Top