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 questionsThe 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.
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.
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.
Keep practicing
Take the free Terraform-Associate-004 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other Terraform-Associate-004 practice questions
- Question 1You should run terraform fnt to rewrite all Terraform configurations within the current w…
- Question 2Module variable assignments are inherited from the parent module and you do not need to e…
- Question 3terraform validate confirms thesyntaxof Terraform files.
- Question 4Using the terraform state rm command against a resource will destroy it.
- Question 5Variables declared within a module are accessible outside of the module.
- Question 6terraform init retrieves and caches the configuration for all remote modules.
