Recall & Review
beginner
What is the main purpose of data sources in Terraform?
Data sources let Terraform read information from existing infrastructure outside of its control, so it can use that info when creating or updating resources.Click to reveal answer
beginner
How do data sources help avoid duplication in infrastructure management?
They allow Terraform to reference existing resources instead of creating new ones, preventing duplicate resources and conflicts.
Click to reveal answer
intermediate
Why is querying existing infrastructure important before provisioning new resources?
It ensures Terraform has up-to-date info about current resources, so it can make decisions that keep infrastructure consistent and avoid errors.
Click to reveal answer
beginner
Give an example of when you would use a data source in Terraform.
When you want to get the ID of an existing network or security group to attach to a new server, you use a data source to query that info.
Click to reveal answer
intermediate
What happens if Terraform does not query existing infrastructure before applying changes?
Terraform might create duplicate resources, overwrite settings, or fail due to conflicts, leading to unstable infrastructure.
Click to reveal answer
What does a Terraform data source do?
✗ Incorrect
Data sources read existing infrastructure info; they do not create or delete resources.
Why use data sources instead of hardcoding resource IDs?
✗ Incorrect
Data sources keep configs dynamic by fetching current info, avoiding errors from hardcoded values.
Which problem can occur if Terraform ignores existing infrastructure?
✗ Incorrect
Ignoring existing infrastructure can cause Terraform to create duplicates, causing conflicts.
When is it best to use a data source in Terraform?
✗ Incorrect
Data sources are used to reference existing resources not managed by Terraform.
What kind of info can a Terraform data source provide?
✗ Incorrect
Data sources provide details like IDs and attributes of existing resources.
Explain why Terraform uses data sources to query existing infrastructure before creating new resources.
Think about how Terraform knows what already exists.
You got /4 concepts.
Describe a scenario where using a Terraform data source is necessary and beneficial.
Consider when you need info from resources created outside Terraform.
You got /4 concepts.