Complete the code to define a remote state data source in Terraform.
data "terraform_remote_state" "example" { backend = "[1]" config = { bucket = "my-terraform-state" key = "state.tfstate" region = "us-east-1" } }
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.[1]["vpc_id"] }
The remote state outputs are accessed via the outputs attribute.
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/terraform.tfstate" region = "us-west-2" } }
The backend must match the storage service used. For AWS S3, use s3.
Fill both blanks to correctly define a remote state data source for Azure Blob Storage.
data "terraform_remote_state" "storage" { backend = "[1]" config = { container_name = "tfstate" key = "storage.tfstate" [2] = "my-storage-account" } }
For Azure Blob Storage, the backend is azurerm and the storage account is specified with storage_account_name.
Fill all three blanks to correctly access a remote state output named 'subnet_ids' and assign it to a local variable.
locals {
subnet_ids = data.terraform_remote_state.network.[1][[2]]
count = length(local.subnet_ids) [3] 0
}Access outputs with outputs, use the output key as a string, and compare count with 0 using '>'.