Archives for Terraform

Terraform create_before_destroy Lifecycle Rule Explained

Terraform create_before_destroy Lifecycle Rule Explained When Terraform needs to replace a resource (destroy and recreate), it follows a specific order. Understanding the create_before_destroy lifecycle rule helps you avoid downtime during infrastructure updates. Default Behavior: Destroy Then Create By default, when a resource needs to be replaced, Terraform: Destroys the old…
Continue Reading

How to Migrate Terraform State from Local to a Remote Backend

How to Migrate Terraform State from Local to a Remote Backend When you first start with Terraform, state is stored locally in As your team grows, you need to migrate to a remote backend for collaboration, security, and state locking. Why Migrate to a Remote Backend? Enables team collaboration —…
Continue Reading

Terraform Workspaces vs Separate Directories: Which is Better for Dev/Prod?

Terraform Workspaces vs Separate Directories: Which is Better for Dev/Prod? Managing multiple environments like Dev, Staging, and Production is one of the most common Terraform challenges. You have two main approaches: Workspaces and Separate Directories. Here is how they differ and when to use each. Terraform Workspaces Workspaces allow multiple…
Continue Reading

What Happens If You Manually Delete a Resource in the Cloud Console?

What Happens If You Manually Delete a Resource in the Cloud Console? Manually deleting a cloud resource outside of Terraform — such as via the AWS Console, Azure Portal, or GCP Console — creates a situation called configuration drift. Understanding how Terraform handles this is critical for maintaining infrastructure integrity.…
Continue Reading

When Should You Explicitly Use depends_on in Terraform?

When Should You Explicitly Use depends_on in Terraform? Terraform automatically builds a dependency graph by analyzing resource references in your code. In most cases, you never need to declare dependencies manually. But there are specific scenarios where depends_on is necessary. How Implicit Dependencies Work When one resource references another, Terraform…
Continue Reading

Terraform count vs for_each: Which is Better for Dynamic Resources?

Terraform count vs for_each: Which is Better for Dynamic Resources? When creating multiple instances of a resource in Terraform, you have two options: count and for_each. Knowing when to use each one is a key concept for writing reliable, maintainable infrastructure code. Using count count creates resources using a numeric…
Continue Reading
Verified by MonsterInsights