Tag: Terraform

Browse all articles, tutorials, and guides about Terraform

Guides

Posts

DevOps
2025-07-14|12 min read

The Hidden Costs of Over-Automation in DevOps

Automation speeds things up, but too much of it can hide failures, slow incident response, and add fragile layers you have to maintain.

Terraform
2025-06-20|5 min read

How to Use the AWS account_id Variable in Terraform

Learn how to dynamically retrieve and use the AWS account_id variable in Terraform for your configurations.

Terraform
2025-06-01|5 min read

Terraform Conditionals: Handling Non-Existent Variables

Learn how to use Terraform conditionals to handle cases where a variable does not exist or is not defined.

Terraform
2025-05-01|7 min read

Terraform: Failed to install provider, does not match checksums from dependency lock file

Troubleshoot the Terraform error about provider checksums not matching the dependency lock file and learn safe fixes and best practices.

Terraform
2025-04-18|8 min read

How to Fix Terraform "Variables Not Allowed" Error During Plan

Learn why Terraform throws 'Variables not allowed' errors in certain contexts and how to resolve them using locals, data sources, or restructuring your configuration.

Terraform
2025-04-10|7 min read

Experimenting Locally with Terraform

Practical techniques for running, testing, and iterating on Terraform locally before you push changes to remote state or CI.

Terraform
2025-04-05|7 min read

Can Terraform Watch a Directory for Changes? Working With Dynamic Files

Learn how to handle scenarios where you need Terraform to respond to file changes, and explore alternatives to automatic directory watching.

Terraform
2025-03-21|6 min read

Best practices when using Terraform?

Discover essential best practices for using Terraform to manage your infrastructure effectively and securely.

Terraform
2025-03-20|5 min read

How to create an SSH key in Terraform?

Learn how to generate and manage SSH keys in Terraform for secure access to your infrastructure.

Terraform
2025-03-20|8 min read

How to Share Providers and Variables Across Terraform Modules

Learn the right way to configure providers and pass variables when working with Terraform modules, avoiding common pitfalls with provider inheritance and variable scoping.

Terraform
2025-03-18|8 min read

How to Organize Terraform Modules for Multiple Environments

Learn effective patterns for structuring Terraform modules to manage dev, staging, and production environments without duplicating code.

Terraform
2025-03-12|7 min read

How to Save Terraform Plan and Apply Output to a File

Learn how to save Terraform plan output for review, share readable apply logs, and use the -out flag for safe two-step deployments.

Terraform
2025-03-05|8 min read

How to Store Terraform Azure State File in a Different Subscription

Learn how to configure Terraform to store its state file in an Azure Storage Account that exists in a different subscription from your infrastructure resources.

Terraform
2025-02-28|6 min read

Variable Keys in Terraform Maps

Learn how to use variable keys in Terraform maps to create dynamic and flexible configurations.

Terraform
2025-02-27|6 min read

What Does Terraform Refresh Really Do?

Understand the purpose and functionality of the `terraform refresh` command in Terraform workflows.

Terraform
2025-02-25|7 min read

How to Get an Object from a List of Objects in Terraform?

Learn how to retrieve a specific object from a list of objects in Terraform using filters and expressions.

Terraform
2025-02-25|7 min read

How to Run Terraform Init From a Different Directory

Learn how to initialize and manage Terraform configurations from outside their directory using -chdir, working directories, and automation patterns.

Terraform
2025-02-23|6 min read

How to Check if String Contains a Substring in Terraform Interpolation?

Learn how to check if a string contains a substring in Terraform using interpolation functions like `contains` and `regex`.

Terraform
2025-02-20|4 min read

Should I commit .tfstate files to Git?

Understand why committing .tfstate files to Git is not recommended and explore best practices for managing Terraform state.

Terraform
2025-02-18|8 min read

How to Add SSH Keys to GCP Instances Using Terraform

Learn how to configure SSH key access for Google Cloud Platform compute instances with Terraform, including project-wide and instance-specific keys.

Terraform
2025-02-16|6 min read

How to Append to a List in Terraform?

Learn how to append elements to a list in Terraform using functions like `concat` and dynamic blocks.

Terraform
2025-02-16|7 min read

Terraform Outputs for Resources with Count

Learn how to manage and structure Terraform outputs for resources created with the `count` meta-argument.

Terraform
2025-02-15|5 min read

Specifying an API Gateway Endpoint with a Variable in Terraform

Learn how to dynamically specify an API Gateway endpoint with a variable in Terraform for flexible configurations.

Terraform
2025-02-10|7 min read

How to Output a Field From a Terraform Module

Learn how to properly expose resource attributes from Terraform modules using outputs, and how to access nested values from complex data structures.

Terraform
2025-02-05|5 min read

Conditional Attributes in Terraform

Learn how to use conditional expressions to dynamically set resource attributes in Terraform.

Terraform
2025-01-30|6 min read

Managing Different Environments in Terraform

Learn how to manage different environments in Terraform using workspaces, variable files, and directory structures.

Terraform
2025-01-29|7 min read

Can a Resource Be Passed as a Variable into a Module?

Learn how to pass resources as variables into modules in Terraform for reusable and modular infrastructure.

Terraform
2025-01-28|8 min read

How to Configure ECS Fargate Task Execution Roles With Terraform

Learn how to properly set up IAM execution roles for ECS Fargate task definitions in Terraform, including permissions for ECR, CloudWatch Logs, and Secrets Manager.

Terraform
2025-01-26|7 min read

"Variables May Not Be Used Here" During Terraform Init

Learn why the "Variables may not be used here" error occurs during `terraform init` and how to resolve it.

Terraform
2025-01-24|7 min read

How to Reference a Resource Created by a Terraform Module

Learn how to reference resources created by a Terraform module in your configurations.

Terraform
2025-01-23|6 min read

Should .terraform.lock.hcl Be in .gitignore? (The Answer Might Surprise You)

The .terraform.lock.hcl file causes confusion for many Terraform users. Learn why you should commit it to version control and how to handle it properly.

Terraform
2025-01-22|8 min read

Conditional Resource Creation in Terraform Based on .tfvars Variables

Learn how to conditionally create Terraform resources using variables from .tfvars files. Learn count, for_each, and dynamic blocks for flexible infrastructure.

Terraform
2025-01-20|5 min read

terraform.tfvars vs variables.tf: What is the Difference?

Understand the difference between terraform.tfvars and variables.tf in Terraform and how to use them effectively.

Terraform
2025-01-20|6 min read

Use Terraform to set up a Lambda function triggered by a scheduled event source

Learn how to use Terraform to create an AWS Lambda function triggered by a scheduled event source, such as a cron job.

Terraform
2025-01-15|7 min read

How to Fix Terraform Provider Checksum Mismatch Errors

Running into 'doesn't match checksums from dependency lock file' errors when installing Terraform providers? Learn what causes this issue and how to resolve it safely.

Terraform
2025-01-13|7 min read

How to Fix "Error acquiring the state lock: ConditionalCheckFailedException"

Learn how to diagnose and fix Terraform state lock errors that prevent your infrastructure deployments from running.

Terraform
2025-01-12|8 min read

How to Fix Terraform Not Deploying API Gateway Stage

Learn why Terraform might not deploy your AWS API Gateway stage and how to properly configure deployments with automatic triggering on configuration changes.

Terraform
2025-01-10|5 min read

How to Load Input Data from a File in Terraform

Learn how to load input data from a file in Terraform using the `file` function and external data sources.

Terraform
2025-01-05|9 min read

How to Apply SQL Scripts to RDS Databases With Terraform

Learn different approaches for running SQL scripts and migrations against RDS databases during Terraform deployment, including provisioners, external tools, and dedicated migration resources.

Terraform
2024-12-30|7 min read

How to Convert a List to a String in Terraform

Learn different methods for converting lists to strings in Terraform using join(), jsonencode(), and format() functions for various use cases.

Terraform
2024-12-22|8 min read

How to Use Terraform Module Output as Input for Another Module

Learn how to chain Terraform modules together by passing outputs from one module as inputs to another, creating organized and reusable infrastructure configurations.

Terraform
2024-12-18|8 min read

How to Configure CloudWatch Logs Subscription Filter to Lambda With Terraform

Learn how to stream CloudWatch Logs to a Lambda function using Terraform, including proper permissions and error handling.

Terraform
2024-12-15|6 min read

Terraform: Error Creating IAM Role. MalformedPolicyDocument: Has Prohibited Field Resource

Learn how to resolve the 'MalformedPolicyDocument: Has prohibited field Resource' error when creating an IAM role in Terraform.

Terraform
2024-12-09|5 min read

How to Ignore Change of an Attribute in Terraform Blocks

Learn how to use the `lifecycle` block with the `ignore_changes` argument to ignore changes to specific attributes in Terraform.

Terraform
2024-12-05|8 min read

How to Organize a Terraform Repository with Multiple Subfolders

Learn how to structure a Terraform repository with multiple environments, modules, and configurations in a way that scales with your infrastructure needs.

AWS
2024-12-01|8 min read

What Does AssumeRole: Service: ec2 Do?

Understand the role of AssumeRole with Service: ec2 in AWS IAM policies and how it integrates with Terraform.

Terraform
2024-12-01|7 min read

How to Split a Terraform File (main.tf) into Several Files (No Modules)

Organizing Terraform configurations by splitting a single main.tf file into multiple files can improve readability and maintainability. Learn how to do this without using modules.

Terraform
2024-11-28|7 min read

How to Fix Terraform Import "Index Value Required" Error for String Keys

Learn how to resolve the 'Index value required' error when importing resources with for_each in Terraform, and understand the correct syntax for string-based resource keys.

Terraform
2024-11-20|5 min read

How to Execute Terraform Actions Without the Interactive Prompt

Learn how to automate Terraform workflows by bypassing the interactive prompt for commands like apply and destroy.

Terraform
2024-11-20|6 min read

How to Get the Current Working Directory in Terraform

Learn how to reference file paths in Terraform using path.module, path.root, and path.cwd - and understand which one to use in different scenarios.

AWS
2024-11-20|7 min read

How to Retrieve a Secret in Terraform from AWS Secret Manager

Learn how to securely retrieve secrets from AWS Secret Manager using Terraform in your infrastructure as code workflows.

Terraform
2024-11-15|4 min read

How do you do simple string concatenation in Terraform?

Learn how to perform string concatenation in Terraform using interpolation and the join function.

Terraform
2024-11-15|6 min read

How to for_each through a list(objects) in Terraform

Learn how to use the for_each construct in Terraform to iterate through lists of objects and dynamically create resources.

Terraform
2024-11-08|8 min read

How to Read Environment Variables From a .env File in Terraform

Learn different approaches for loading environment variables from .env files into Terraform, from shell scripts to external data sources.

Terraform
2024-11-05|6 min read

How to Attach Multiple IAM Policies to IAM Roles Using Terraform

Learn how to attach multiple IAM policies to a single IAM role in Terraform to manage permissions effectively.

Terraform
2024-11-02|5 min read

Fixing the "Invalid Legacy Provider Address" Error in Terraform

Learn how to resolve the 'Invalid legacy provider address' error in Terraform by upgrading your provider configurations.

Terraform
2024-11-01|5 min read

Variables Within Variables in Terraform

Learn how to use variables within variables in Terraform to create dynamic and reusable configurations.

Terraform
2024-10-29|5 min read

How to Display Sensitive Data Output Variables in Terraform

Learn how to handle and display sensitive data output variables in Terraform safely and effectively.

Terraform
2024-10-25|7 min read

How to Get List Index When Using for_each in Terraform

Learn how to access the index or position when iterating over lists with for_each in Terraform, and understand the differences between for_each and count.

Terraform
2024-10-23|7 min read

Determining Minimum AWS Permissions for Terraform Configurations

Learn how to identify the minimum AWS permissions required for your Terraform configurations to enhance security and compliance.

Terraform
2024-10-20|8 min read

How to Use Conditional Data Sources in Terraform

Learn how to conditionally fetch data in Terraform using count, for_each, and conditional expressions to query external resources only when needed.

Terraform
2024-10-20|6 min read

Terraform + DynamoDB: All Attributes Must Be Indexed

Learn how to handle the 'all attributes must be indexed' requirement in DynamoDB when using Terraform.

Terraform
2024-10-12|8 min read

How to Reference Resources Created With for_each in Terraform

Learn how to reference individual resources and attributes from for_each loops in other Terraform resources, including cross-resource dependencies and data extraction patterns.

Terraform
2024-09-30|7 min read

How to Concatenate Lists in Terraform Using concat()

Learn how to combine multiple lists in Terraform using the concat() function, plus advanced patterns for merging and manipulating list data.

Terraform
2024-09-15|9 min read

How to Fix Common Terraform S3 Backend Configuration Errors

Learn how to troubleshoot and resolve common errors when configuring Terraform's S3 backend, from access denied issues to state locking problems.

Terraform
2024-08-15|5 min read

Fixing "A Reference to Resource Type Must Be Followed by At Least One Attribute Access" in Terraform

Learn how to resolve the error 'A reference to resource type must be followed by at least one attribute access' in Terraform.

Terraform
2024-08-10|5 min read

How to Create a Folder in an AWS S3 Bucket Using Terraform

Learn how to create a folder in an AWS S3 bucket using Terraform by leveraging the `aws_s3_object` resource.

Terraform
2024-07-26|5 min read

Using a Git Branch as a Source for Terraform Modules

Learn how to use a specific Git branch as the source for Terraform modules to manage versioning and development workflows.

Terraform
2024-07-24|5 min read

Getting an Environment Variable in Terraform Configuration

Learn how to retrieve and use environment variables in Terraform configurations using the `env` function and input variables.

Terraform
2024-06-21|5 min read

Is there an AND/OR Conditional Operator in Terraform?

Learn how to use AND/OR conditional operators in Terraform to create dynamic configurations.

Terraform
2024-06-19|5 min read

Refactoring modules: Error: Provider configuration not present

Learn how to resolve the 'Provider configuration not present' error when refactoring Terraform modules.

Terraform
2024-06-17|4 min read

How can I remove a resource from Terraform state?

Learn how to safely remove a resource from Terraform state without affecting the actual infrastructure.

Terraform
2024-06-16|5 min read

How are data sources used in Terraform?

Understand how to use data sources in Terraform to fetch information about existing resources.

Terraform
2024-06-15|5 min read

Upgrade Terraform to Specific Version

Learn how to upgrade Terraform to a specific version on your system, ensuring compatibility with your infrastructure.

Terraform
2024-06-11|5 min read

Initial setup of Terraform backend using Terraform

Learn how to configure a Terraform backend for secure and efficient state management.

Terraform
2024-06-08|6 min read

Terraform Infrastructure as Code Best Practices

How to write scalable and maintainable Terraform code for your cloud infrastructure.

Terraform
2024-05-15|5 min read

I would like to run Terraform only for a specific resource

Learn how to target specific resources in Terraform to save time and avoid unnecessary changes.

Terraform
2024-05-05|6 min read

How to Migrate Terraform State Between Projects

Learn how to safely migrate Terraform state between projects using the `terraform state` command.

Terraform
2024-04-22|6 min read

Terraform - Delete All Resources Except One

Learn how to delete all resources managed by Terraform except for a specific resource by using targeted commands and state manipulation.

Terraform
2024-04-21|6 min read

How to Write an if, else, elsif Conditional Statement in Terraform

Learn how to use if, else, and elsif conditional statements in Terraform to create dynamic configurations.

Terraform
2024-03-29|7 min read

Terraform Failing with Invalid for_each Argument / The Given "for_each" Argument Value is Unsuitable

Learn how to troubleshoot and fix the "Invalid for_each argument" error in Terraform.

Terraform
2024-03-21|6 min read

Can Terraform Be Used to Provision On-Premises Servers?

Learn how Terraform can be used to provision on-premises servers by integrating with tools like VMware vSphere, Ansible, and bare-metal providers.

Terraform
2024-02-21|4 min read

Concatenate a String with a Variable in Terraform

Learn how to concatenate strings with variables in Terraform to create dynamic configurations.

Terraform
2024-02-18|6 min read

Modules + Output from for_each

Learn how to use for_each with modules in Terraform to dynamically create resources and manage outputs.

Terraform
2024-01-23|5 min read

Terraform Statefile is Locked: How to Unlock It

Learn how to unlock a locked Terraform statefile using the `force-unlock` command and best practices to avoid future locks.