0
0
Terraformcloud~5 mins

Why data sources query existing infrastructure in Terraform - Quick Recap

Choose your learning style9 modes available
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?
AReads info from existing infrastructure
BCreates new cloud resources
CDeletes unused resources
DRuns scripts on servers
Why use data sources instead of hardcoding resource IDs?
ATo delete old resources automatically
BTo speed up resource creation
CTo avoid using variables
DTo keep Terraform configs dynamic and accurate
Which problem can occur if Terraform ignores existing infrastructure?
ADuplicate resources may be created
BTerraform will run faster
CResources will be deleted automatically
DNo impact on infrastructure
When is it best to use a data source in Terraform?
AWhen creating brand new resources
BWhen deleting resources
CWhen referencing resources created outside Terraform
DWhen running Terraform plan only
What kind of info can a Terraform data source provide?
AUser login credentials
BResource IDs, names, and attributes
CTerraform version info
DCloud provider billing details
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.