Terraform

Browse all articles, tutorials, and guides about Terraform

About Terraform

Provision and manage cloud infrastructure using Terraform. Follow examples that demonstrate best practices for infrastructure as code.

Posts

Terraform
2025-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
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-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-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-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-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-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-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-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
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-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-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-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-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-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|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-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-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.