0
0
Terraformcloud~10 mins

Remote state data source for cross-project in Terraform - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a remote state data source using Terraform.

Terraform
data "terraform_remote_state" "example" {
  backend = "[1]"
  config = {
    bucket = "my-terraform-state"
    key    = "state.tfstate"
    region = "us-west-2"
  }
}
Drag options to blanks, or click blank then click option'
As3
Blocal
Cgcs
Dazurerm
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'local' instead of 's3' for remote state backend.
Confusing 'gcs' (Google Cloud Storage) with AWS S3.
2fill in blank
medium

Complete the code to reference the remote state output named 'vpc_id'.

Terraform
output "vpc_id" {
  value = data.terraform_remote_state.example.[1][0]
}
Drag options to blanks, or click blank then click option'
Avpc_id
Boutputs.vpc_id
Coutputs["vpc_id"]
Doutput.vpc_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using dot notation directly on outputs which is invalid.
Trying to access output without referencing 'outputs' map.
3fill in blank
hard

Fix the error in the remote state data source block to correctly specify the S3 bucket region.

Terraform
data "terraform_remote_state" "example" {
  backend = "s3"
  config = {
    bucket = "my-terraform-state"
    key    = "state.tfstate"
    region = "[1]"
  }
}
Drag options to blanks, or click blank then click option'
Aus-east-1
Bus-west-2
Cus-west-3
Deu-central-1
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-existent AWS region.
Typos in the region string.
4fill in blank
hard

Fill both blanks to configure the remote state data source for a Google Cloud Storage bucket.

Terraform
data "terraform_remote_state" "example" {
  backend = "[1]"
  config = {
    bucket = "my-gcs-bucket"
    prefix = "[2]"
  }
}
Drag options to blanks, or click blank then click option'
Agcs
Bs3
Cterraform/state
Dstate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 's3' backend for GCS bucket.
Leaving prefix empty or incorrect.
5fill in blank
hard

Fill all three blanks to correctly reference a remote state output named 'subnet_ids' from an Azure backend.

Terraform
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]]
}
Drag options to blanks, or click blank then click option'
Aazurerm
Boutputs
C"subnet_ids"
Dsubnet_ids
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong backend name like 's3' for Azure.
Accessing outputs without quotes around keys.