Complete the code to define a remote state data source using Terraform.
data "terraform_remote_state" "example" { backend = "[1]" config = { bucket = "my-terraform-state" key = "state.tfstate" region = "us-west-2" } }
The backend specifies where the remote state is stored. For AWS S3, use s3.
Complete the code to access an output named 'vpc_id' from the remote state.
output "vpc_id" { value = data.terraform_remote_state.example.outputs.[1] }
Terraform outputs are case-sensitive and usually use snake_case. The output name is 'vpc_id'.
Fix the error in the remote state data source configuration by completing the missing backend name.
data "terraform_remote_state" "network" { backend = "[1]" config = { bucket = "network-state" key = "network.tfstate" region = "us-east-1" } }
The backend must be set to a valid remote backend. For AWS S3, use s3.
Fill both blanks to correctly configure the remote state data source with S3 backend and specify the state file key.
data "terraform_remote_state" "app" { backend = "[1]" config = { bucket = "app-state-bucket" key = "[2]" region = "us-east-2" } }
The backend is 's3' for AWS S3 storage. The key is the path to the state file, here 'app.tfstate'.
Fill all three blanks to define a remote state data source with S3 backend, specify the bucket, and access the 'subnet_ids' output.
data "terraform_remote_state" "network" { backend = "[1]" config = { bucket = "[2]" key = "network.tfstate" region = "us-west-1" } } output "subnet_ids" { value = data.terraform_remote_state.network.outputs.[3] }
The backend is 's3' for AWS S3. The bucket is the S3 bucket name. The output accessed is 'subnet_ids'.