Q: Your plan fails because a data source cannot find a resource that is created in the same apply. Why does this happen?
Data sources read existing infrastructure during planning, before new resources are created. If the object does not already exist, the lo...
#Terraform #Use VPC ID from another module #L2 #IaC #Cloud Infrastructure
🎙️ Candidate Opening & Architectural Context
""Treat Terraform code with the same rigor as application code: pre-merge plans, state locks, and automated drift detection. When addressing this question, I walk the interviewer through our production incident runbook: isolating the blast radius, checking diagnostic logs and metrics, and applying a safe fix.""
Advertisement
🛠️ Production Runbook & Step-by-Step Resolution
1️⃣
Production Solution & Architecture
Data sources read existing infrastructure during planning, before new resources are created. If the object does not already exist, the lookup fails. Use direct references to the managed resource instead of a data source when both live in the same configuration, or split the workflow into stages if the dependency truly must be read after creation.
💡 The Senior SRE Gold Nugget (Key Architectural Takeaway)
"Pro-Tip: Data sources read existing infrastructure during planning, before new resources are created. If the object does not already exist,."
⚡ 60-Second Elevator Pitch Talking Points
- Immediate Triage: Data sources read existing infrastructure during planning, before new resources are created. If
- Run targeted verification commands before modifying configuration.
- Automate permanent guardrails (CI check, alerts, IaC policy) to prevent recurrence.
Advertisement