Exam Terraform Associate All QuestionsBrowse all questions from this exam
Question 194

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

    Correct Answer: A

    You can access state stored with the local backend by using the terraform_remote_state data source. The terraform_remote_state data source allows you to retrieve outputs from the state of another Terraform configuration and supports both remote and local backends. When using the local backend, you need to define the path to the state file in the backend configuration block and then reference that path in the terraform_remote_state data block to get the desired outputs.

Discussion
Stanislav4907Option: A

The terraform_remote_state data source allows you to retrieve outputs from the state of another Terraform configuration, which can be stored in a local or remote backend. To use the terraform_remote_state data source with a local backend, you would define the path to the state file in the backend configuration block of your Terraform configuration, and then use that path in the data "terraform_remote_state" block to retrieve the desired output values.

FarziWaliMarziOption: A

https://developer.hashicorp.com/terraform/language/state/remote-state-data data "terraform_remote_state" "vpc" { backend = "local" config = { path = "..." } } # Terraform >= 0.12 resource "aws_instance" "foo" { # ... subnet_id = data.terraform_remote_state.vpc.outputs.subnet_id } # Terraform <= 0.11 resource "aws_instance" "foo" { # ... subnet_id = "${data.terraform_remote_state.vpc.subnet_id}" }

Daro_Option: A

As per below documentation https://developer.hashicorp.com/terraform/language/state/remote-state-data and example of configuration data "terraform_remote_state" "vpc" { backend = "local" config = { path = "..." } } Answer is: [ A ]

lezgino

The terraform_remote_state data source is used to access state stored with a remote backend, such as S3 or Consul. You cannot access state stored with the local backend using the terraform_remote_state data source.

StribOption: A

Example Usage (local Backend) https://developer.hashicorp.com/terraform/language/state/remote-state-data#example-usage-local-backend

VSMuOption: A

Example https://developer.hashicorp.com/terraform/language/state/remote-state-data#example-usage-local-backend

NunyabiznesOption: B

The terraform_remote_state data source is used to access state data stored in a remote backend (such as S3, GCS, or Terraform Cloud). It is not designed to access local backend state files directly. However, if you want to access data from another Terraform configuration's local state, you can use output variables and pass the values between configurations using input variables or other methods.

shahin_am2Option: B

B. False. According to the Terraform documentation, the terraform_remote_state data source can be used to access state data stored in a remote backend. This allows you to use output values from one Terraform configuration as input values for another configuration. However, the local backend is not considered a remote backend, because it stores state data locally on disk. Therefore, you cannot use the terraform_remote_state data source to access state stored with the local backend.

princajenOption: B

B. False. The terraform_remote_state data source is used to fetch outputs from the state of a different Terraform configuration, which is stored remotely, and use them as input for the current configuration. It is used with remote backends, not local ones.

AbuuOption: A

this is correct. The terraform_remote_state data source allows you to access state stored with the local backend, enabling you to share and reference state between different configurations. This is especially useful when using multiple configurations to manage different parts of the same infrastructure.

Daro_Option: A

As per below documentation https://developer.hashicorp.com/terraform/language/state/remote-state-data and example of configuration data "terraform_remote_state" "vpc" { backend = "local" config = { path = "..." } } Answer is: [ A ]

kounilascoOption: B

it is false

master9Option: B

As asking for Local not remote state file

campsOption: B

The terraform_remote_state data source is used to access the state data from another Terraform configuration that is stored in a remote backend, not a local backend. This data source enables you to fetch the outputs of another Terraform project and use them as input variables in your current Terraform project. When using the local backend, the Terraform state is stored in a local file (usually named terraform.tfstate). This means the state is not accessible through the terraform_remote_state data source, as it is not stored remotely.

SaadKhamis

It is possible to use it to access local backend. https://developer.hashicorp.com/terraform/language/state/remote-state-data#example-usage-local-backend data "terraform_remote_state" "vpc" { backend = "local" config = { path = "..." } }

David_C_90Option: A

I tested this and I believe this is correct. Check the link https://developer.hashicorp.com/terraform/language/state/remote-state-data#example-usage-local-backend Note that the state file must already exist and the data you will obtain is the data present on the file: if you change the terraform configuration corresponding to the state you are trying to read, you will obtain the "old" data.

khaled_razoukOption: B

I'll go with B

rotimislawOption: B

Seems B to me

pyro7Option: B

False. The local backend stores state locally on the same machine as the Terraform configuration files, and it is not accessible over a network connection. To access state stored in a remote backend, you need to use the terraform_remote_state data source.