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 the remote state storage type. For AWS S3, use s3.
Complete the code to reference the remote state output named 'vpc_id'.
output "vpc_id" { value = data.terraform_remote_state.example.[1][0] }
Remote state outputs are accessed as a map using bracket notation, e.g., outputs["vpc_id"].
Fix the error in the remote state data source block to correctly specify the S3 bucket region.
data "terraform_remote_state" "example" { backend = "s3" config = { bucket = "my-terraform-state" key = "state.tfstate" region = "[1]" } }
The correct AWS region for the bucket is us-west-2. Using an invalid region like 'us-west-3' causes errors.
Fill both blanks to configure the remote state data source for a Google Cloud Storage bucket.
data "terraform_remote_state" "example" { backend = "[1]" config = { bucket = "my-gcs-bucket" prefix = "[2]" } }
For Google Cloud Storage, the backend is gcs. The prefix is the folder path inside the bucket, e.g., terraform/state.
Fill all three blanks to correctly reference a remote state output named 'subnet_ids' from an Azure backend.
data "terraform_remote_state" "example" { backend = "[1]" config = { resource_group_name = "myResourceGroup" storage_account_name = "mystorageaccount" container_name = "tfstate" key = "prod.terraform.tfstate" } } output "subnet_ids" { value = data.terraform_remote_state.example.[2][[3]] }
The backend for Azure is azurerm. Remote state outputs are accessed via the outputs map, and keys must be quoted strings like "subnet_ids".