Challenge - 5 Problems
Terraform Data Source Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ service_behavior
intermediate2:00remaining
Understanding Terraform data source output
You use a Terraform data source to query an existing AWS VPC by its ID. What will be the value of
data.aws_vpc.selected_vpc.cidr_block after applying this configuration?Terraform
data "aws_vpc" "selected_vpc" { id = "vpc-0abc123def456ghij" } output "vpc_cidr" { value = data.aws_vpc.selected_vpc.cidr_block }
Attempts:
2 left
💡 Hint
The data source fetches existing resource attributes, including the CIDR block.
✗ Incorrect
The
aws_vpc data source returns the attributes of the existing VPC identified by the given ID. The cidr_block attribute contains the IP range of the VPC, such as "10.0.0.0/16".🧠 Conceptual
intermediate1:30remaining
Purpose of Terraform data sources
What is the main purpose of using a Terraform data source when working with existing cloud resources?
Attempts:
2 left
💡 Hint
Think about how Terraform can use information about resources it did not create.
✗ Incorrect
Terraform data sources allow you to look up and use information about existing resources in your cloud environment without managing their lifecycle.
❓ Configuration
advanced2:30remaining
Correctly querying an existing AWS subnet by tag
Which Terraform configuration correctly queries an existing AWS subnet with the tag
Environment=Production and outputs its subnet ID?Attempts:
2 left
💡 Hint
Use the correct data source type and filter syntax for multiple subnets.
✗ Incorrect
The
aws_subnet_ids data source supports filtering by tags using the filter block. It returns a list of subnet IDs matching the filter. Option A correctly uses filter with name and values to find subnets tagged with Environment=Production.❓ security
advanced2:00remaining
Security implications of querying existing resources
When using Terraform data sources to query existing cloud resources, what is a key security consideration?
Attempts:
2 left
💡 Hint
Think about what permissions Terraform needs to read existing resource information.
✗ Incorrect
Terraform requires read permissions to query existing resources via data sources. It does not get write or modify permissions automatically. Proper IAM roles or policies must be assigned to allow safe querying.
❓ Architecture
expert3:00remaining
Designing Terraform to query multi-cloud existing resources
You need to write a Terraform configuration that queries existing virtual networks from both AWS and Azure in the same deployment. Which approach correctly supports querying both cloud providers' existing networks?
Attempts:
2 left
💡 Hint
Terraform supports multiple providers in one configuration.
✗ Incorrect
Terraform can manage multiple cloud providers by defining multiple provider blocks. To query existing resources from AWS and Azure, use their respective data sources under their providers. Option D correctly separates providers and uses the correct data sources.