The article discusses the challenges and solutions related to infrastructure drift in cloud environments when using Infrastructure as Code (IaC) tools like Terraform. Here are the key points:
Challenges of Drift
- Terraform State File Limitations: The state file maintained by Terraform only reflects what it thinks is running, not necessarily what's actually deployed in your cloud environment.
- Manual Changes and Scale Issues:
- As environments scale (multiple accounts, regions), manually tracking drift becomes impractical.
- Manual audits and console checks are time-consuming and error-prone.
Solutions
-
CloudQuery: A tool that syncs actual cloud state into SQL tables, allowing you to query your infrastructure as if it were a database:
- Example Query:
SELECT account_id, region, instance_id, tags FROM aws_ec2_instances WHERE tags->>'owner' IS NULL ORDER BY account_id, region; - This helps identify discrepancies between what's actually running and what Terraform thinks is running.
- Example Query:
-
Identifying Drift:
- If a resource exists in the cloud but not in your IaC state: Use
terraform importto bring it under management.
- If a resource exists in the cloud but not in your IaC state: Use
Read the full article at The New Stack
Want to create content about this topic? Use Nemati AI tools to generate articles, social posts, and more.

![[AINews] The Unreasonable Effectiveness of Closing the Loop](/_next/image?url=https%3A%2F%2Fmedia.nemati.ai%2Fmedia%2Fblog%2Fimages%2Farticles%2F600e22851bc7453b.webp&w=3840&q=75)



