OpenTofu
OpenTofu is an infrastructure as code tool that lets you build, change, and version cloud and on-prem resources safely and efficiently. Originally a fork…
- Docker & Rancher Desktop Tutorials
Terraform Docker Provider: Manage Containers and Images as Code
Use the Terraform and OpenTofu Docker provider (kreuzwerker/docker) with Rancher Desktop to manage images, networks, volumes and containers declaratively.
- Terraform & OpenTofu Tutorials
AWS with Terraform Tutorial: Terraform CI/CD (21)
Automate Terraform and OpenTofu on AWS with GitHub Actions: checks on every pull request, plan comments, approved applies and OIDC without keys.
- Terraform & OpenTofu Tutorials
AWS with Terraform Tutorial: Terraform Tools (20)
The essential tools for Terraform and OpenTofu: fmt, validate, TFLint, Trivy, Checkov, terraform-docs, Infracost and pre-commit hooks.
- Terraform & OpenTofu Tutorials
AWS with Terraform Tutorial: Terraform Backends (19)
Store the Terraform or OpenTofu state in an encrypted, versioned S3 bucket with native state locking, and migrate the local state to it.
- Terraform & OpenTofu Tutorials
AWS with Terraform Tutorial: Terraform Modules (18)
Refactor the AWS network of the tutorial into a reusable Terraform module with variables and outputs, without recreating any resource.
- Terraform & OpenTofu Tutorials
AWS with Terraform Tutorial: AWS Load Balancers (16)
Use Terraform to create an Application Load Balancer with a target group, listeners and HTTPS in front of an Auto Scaling group on AWS.
- Terraform & OpenTofu Tutorials
AWS with Terraform Tutorial: AWS Auto Scaling (15)
Use the Terraform aws_launch_template and aws_autoscaling_group resources to run a self-healing, scalable group of EC2 instances on AWS.
- Terraform & OpenTofu Tutorials
Estimate AWS Costs in Terraform Pull Requests with Infracost
How to see the monthly cost of Terraform and OpenTofu changes before applying them with Infracost, and how to keep AWS demo costs under control.
- Terraform & OpenTofu Tutorials
AWS VPC Peering and Transit Gateway with Terraform
Connect AWS VPCs with Terraform or OpenTofu using VPC peering for simple cases or a Transit Gateway for many networks, with routes and a comparison of costs.
- Terraform & OpenTofu Tutorials
What is OpenTofu? The Open-Source Fork of Terraform Explained
OpenTofu is the open-source Infrastructure as Code tool, a fork of Terraform managed by the Linux Foundation. Learn what it is, how it works and how to start.
- Terraform & OpenTofu Tutorials
Terraform lifecycle: prevent_destroy, create_before_destroy, ignore_changes
How to use the Terraform and OpenTofu lifecycle block: prevent_destroy, create_before_destroy, ignore_changes, replace_triggered_by and conditions.
Infrastructure as Code
OpenTofu
OpenTofu is the open-source, Linux Foundation fork of Terraform for Infrastructure as Code, compatible with Terraform providers and HCL.
- Terraform & OpenTofu Tutorials
Terraform and OpenTofu on Oracle Cloud (OCI): Getting Started with the OCI Provider
Deploy your first resources on Oracle Cloud (OCI) with Terraform or OpenTofu: API key authentication, a VCN, a compute instance and an Object Storage bucket.
- Terraform & OpenTofu Tutorials
Terraform import, moved and removed Blocks: Refactor Without Destroying
How to import existing AWS resources into Terraform or OpenTofu, rename them with moved blocks and stop managing them with removed blocks, without downtime.
- Terraform & OpenTofu Tutorials
Terraform -replace, taint and -target: Recreate or Limit Resources Safely
How to force Terraform and OpenTofu to recreate a resource with -replace (the replacement for taint), when to use -target and how to avoid its risks.
- Terraform & OpenTofu Tutorials
Terraform vs OpenTofu: Differences, License and Which One to Choose
Compare Terraform and OpenTofu: license, governance, compatibility, exclusive features such as state encryption, and how to decide which one to use.
- Terraform & OpenTofu Tutorials
Terraform Variables, Outputs and Locals Explained with Examples
How to use input variables, validation, outputs and local values in Terraform and OpenTofu, and how to set variables with tfvars files and environment variables.
- Terraform & OpenTofu Tutorials
AWS IAM Roles and Policies with Terraform and OpenTofu
How to create IAM roles, policies, instance profiles and assume-role trust relationships with Terraform or OpenTofu, following least privilege, with AWS examples.
- Terraform & OpenTofu Tutorials
Terraform and OpenTofu with GitHub Actions and AWS OIDC (No Access Keys)
Run Terraform or OpenTofu plan on pull requests and apply on merge with GitHub Actions, authenticating to AWS with OIDC and short-lived credentials.
- Terraform & OpenTofu Tutorials
Terraform and OpenTofu Cheat Sheet: Commands and HCL Syntax
A quick reference of the most used Terraform and OpenTofu commands (init, plan, apply, state, import, workspace) and HCL syntax, with examples to copy.
- Terraform & OpenTofu Tutorials
AWS S3 Buckets with Terraform and OpenTofu: Secure Configuration
Create secure AWS S3 buckets with Terraform or OpenTofu: public access block, encryption with KMS, versioning, lifecycle rules and bucket policies.
- Terraform & OpenTofu Tutorials
Terraform and OpenTofu on OpenStack: Getting Started with the OpenStack Provider
Deploy your first resources on OpenStack with Terraform or OpenTofu: clouds.yaml authentication, a network and router, an instance and a floating IP.
Infrastructure as Code
Configuration Drift
Configuration drift is the difference between the real infrastructure and its Terraform code or state, caused by manual changes. Learn how to detect and fix it.
- Terraform & OpenTofu Tutorials
terraform-aws-modules: Create a VPC and EKS Cluster with the Official Community Modules
How to use the popular terraform-aws-modules (vpc, iam, s3-bucket, eks) from the Terraform and OpenTofu registry: versions, inputs, outputs and a VPC plus EKS example.
- Terraform & OpenTofu Tutorials
Terraform Multi-Region and Multi-Account AWS with Provider Aliases
How to deploy to several AWS regions and accounts from one Terraform or OpenTofu configuration using provider aliases, assume_role, modules and for_each on providers.
Infrastructure as Code
Terraform Backend
A Terraform backend defines where the state is stored and how operations run. Learn the S3 backend, locking and how to migrate between backends.
- Terraform & OpenTofu Tutorials
AWS Lambda and API Gateway with Terraform: Serverless HTTP API
Deploy a serverless HTTP API with an AWS Lambda function, IAM role, CloudWatch logs and API Gateway HTTP API using Terraform or OpenTofu.
- Terraform & OpenTofu Tutorials
Terraform and OpenTofu Testing: tofu test, validate and Terratest
How to test infrastructure code: terraform validate, the native terraform test and tofu test framework with mock providers, plan checks and Terratest.
- Terraform & OpenTofu Tutorials
AWS SQS and SNS with Terraform: Queues, Topics and Dead-Letter Queues
Create AWS SQS queues with dead-letter queues, SNS topics and subscriptions with Terraform or OpenTofu, including encryption and the access policy for fan-out.
- Terraform & OpenTofu Tutorials
Terraform and OpenTofu Project Structure: Recommended Layouts
How to organize a Terraform or OpenTofu project: files, modules, environments, state splitting, versions and a monorepo layout that scales with the team.
- Terraform & OpenTofu Tutorials
Common Terraform and OpenTofu Errors and How to Fix Them
Fix the most common Terraform errors: state lock, provider version, cycle, invalid count, already exists, access denied, credentials and failed apply on AWS.
- Terraform & OpenTofu Tutorials
AWS VPC Endpoints and PrivateLink with Terraform: Private Access to AWS Services
Create gateway and interface VPC endpoints with Terraform or OpenTofu to reach S3, DynamoDB and other AWS services privately and reduce NAT gateway costs.
- Terraform & OpenTofu Tutorials
Terraform Secrets Management: Keep Passwords Out of Code and State
How to handle secrets in Terraform and OpenTofu: sensitive variables, AWS Secrets Manager, SSM, generated passwords, ephemeral values and state encryption.
Infrastructure as Code
Terraform Workspace
A Terraform workspace is a named state inside the same backend and configuration, used to create several copies of an infrastructure.
- Terraform & OpenTofu Tutorials
Automate AWS with EventBridge Scheduler and Lambda: Stop and Start EC2 on a Schedule (Terraform)
Automate AWS tasks with Terraform: schedule a Lambda function with EventBridge Scheduler to stop and start tagged EC2 instances and save costs outside working hours.
Infrastructure as Code
Terraform State
The Terraform state is the file where Terraform and OpenTofu record which real resources they manage, so they can plan and apply changes.
Infrastructure as Code
Terraform Module
A Terraform module is a reusable set of resources in a directory, with input variables and outputs. Learn how modules work in Terraform and OpenTofu.
- Terraform & OpenTofu Tutorials
Terraform and OpenTofu on Alibaba Cloud: Getting Started with the Alicloud Provider
Deploy your first resources on Alibaba Cloud with Terraform or OpenTofu: RAM user credentials, a VPC with a vSwitch, a security group, an ECS instance and an OSS bucket.
- Terraform & OpenTofu Tutorials
Terraform and OpenTofu on Azure: Getting Started with the AzureRM Provider
Deploy your first Azure resources with Terraform or OpenTofu: Azure CLI login, resource group, virtual network, storage account and remote state.
- Terraform & OpenTofu Tutorials
Terraform Workspaces vs Directories: How to Manage Environments
Compare Terraform and OpenTofu workspaces with separate directories and tfvars files to manage dev, pre and pro environments, and learn which one to use.
Infrastructure as Code
Terraform Provider
A Terraform provider is a plugin that lets Terraform and OpenTofu manage resources of a platform such as AWS, Azure or Kubernetes through its API.
- Terraform & OpenTofu Tutorials
Terraform and OpenTofu on DigitalOcean: Droplets, VPC and Firewall
Deploy your first resources on DigitalOcean with Terraform or OpenTofu: API token, an SSH key, a VPC, a Droplet and a cloud firewall, with a comparison to AWS.
- Terraform & OpenTofu Tutorials
Terraform Security Scanning with tflint, Checkov and Trivy
Find misconfigurations in Terraform and OpenTofu code before deploying: tflint for errors, Checkov and Trivy for AWS security issues, with CI examples.
- Terraform & OpenTofu Tutorials
Terraform Conditionals and for Expressions: Ternary, count, splat and Examples
How to write conditions and loops in Terraform and OpenTofu: the ternary operator, count and for_each switches, for expressions, splat, try, lookup, merge and flatten.
- Terraform & OpenTofu Tutorials
AWS Organizations and Multi-Account Setup with Terraform
Design and create a multi-account AWS landing zone with Terraform or OpenTofu: AWS Organizations, OUs, accounts, service control policies and cross-account roles.
- Terraform & OpenTofu Tutorials
Terraform depends_on and Resource Dependencies Explained
How Terraform builds its dependency graph, the difference between implicit and explicit dependencies, when to use depends_on, and how to fix dependency cycles.
- Terraform & OpenTofu Tutorials
Terraform and OpenTofu with Cloudflare: DNS, WAF, Caching, R2 and Tunnels
Manage Cloudflare with Terraform or OpenTofu: DNS records, WAF, redirect, cache and rate limit rules, zone settings, DNSSEC, R2 buckets and tunnels.
- Terraform & OpenTofu Tutorials
AWS KMS and Secrets Manager with Terraform: Encrypt and Store Secrets
Create KMS keys with rotation and policies, and store and read secrets in AWS Secrets Manager and SSM Parameter Store with Terraform or OpenTofu, safely.
- Terraform & OpenTofu Tutorials
AWS Security Monitoring with Terraform: CloudTrail, GuardDuty, Config and Security Hub
Enable AWS security services with Terraform or OpenTofu: an organization CloudTrail, GuardDuty, AWS Config and Security Hub, with encrypted log storage.
- Terraform & OpenTofu Tutorials
AWS CloudWatch Alarms, Logs and Dashboards with Terraform
Monitor AWS with Terraform or OpenTofu: log groups with retention, metric filters, CloudWatch alarms that notify through SNS, and a dashboard.
- Terraform & OpenTofu Tutorials
Static Website on AWS with S3, CloudFront and ACM using Terraform
Host a static website on AWS with a private S3 bucket, CloudFront with Origin Access Control, an ACM certificate and Route 53, using Terraform or OpenTofu.
- Terraform & OpenTofu Tutorials
Terraform Provisioners and EC2 user_data: When to Use Each (and Alternatives)
How Terraform provisioners (local-exec, remote-exec, file) work, why they are a last resort, and how to use EC2 user_data, cloud-init and Ansible instead.
- Terraform & OpenTofu Tutorials
AWS DynamoDB Tables with Terraform: Keys, Indexes, TTL and Autoscaling
Create AWS DynamoDB tables with Terraform or OpenTofu: partition and sort keys, global secondary indexes, on-demand or provisioned capacity, TTL, backups and encryption.
- Terraform & OpenTofu Tutorials
Terraform and OpenTofu on Google Cloud: Getting Started with the Google Provider
Deploy your first resources on Google Cloud with Terraform or OpenTofu: authentication, enabling APIs, a VPC network, a Cloud Storage bucket and remote state in GCS.
- AWS Tutorials
AWS Three-Tier Web Architecture: Reference Design with Terraform
A reference architecture for a highly available three-tier web application on AWS: VPC, ALB, EC2 auto scaling and RDS, with the Terraform modules to build each layer.
- Terraform & OpenTofu Tutorials
HashiCorp Terraform Associate Certification Study Guide
A study plan for the HashiCorp Certified Terraform Associate exam: topics, what to practice, commands to know and links to hands-on tutorials with AWS.
- Terraform & OpenTofu Tutorials
AWS Systems Manager Session Manager with Terraform: SSH Without Open Ports
Connect to EC2 instances without SSH keys, bastion hosts or open port 22 using AWS Systems Manager Session Manager, configured with Terraform or OpenTofu.
- Terraform & OpenTofu Tutorials
Terraform and OpenTofu Interview Questions and Answers (with AWS Examples)
The most common Terraform and OpenTofu interview questions for DevOps and cloud roles, with short answers on state, modules, lifecycle, secrets, AWS and CI/CD.
- Terraform Best Practices
Terraform and OpenTofu Best Practices for AWS and the Cloud
A practical checklist of Terraform and OpenTofu best practices: state, modules, versions, security, CI/CD, naming, testing and cost control.
- Terraform & OpenTofu Tutorials
Terraform for_each vs count: Which One to Use and Why
Learn the difference between the Terraform and OpenTofu count and for_each meta-arguments, with AWS examples, and why for_each avoids destroying resources.
- Terraform & OpenTofu Tutorials
Terragrunt with OpenTofu: Keep Your Configuration DRY
What Terragrunt is and how to use it with OpenTofu or Terraform to avoid repeating backend and provider code across environments, with a complete AWS example.
- Terraform & OpenTofu Tutorials
Terraform Data Sources and terraform_remote_state with AWS Examples
How to read existing infrastructure with Terraform data sources and share values between configurations with terraform_remote_state or SSM Parameter Store.
- Terraform & OpenTofu Tutorials
Terraform Dynamic Blocks: Generate Nested Blocks from Variables
How to use dynamic blocks in Terraform and OpenTofu to generate repeated nested blocks such as security group rules, with for_each, iterator and AWS examples.
- Terraform & OpenTofu Tutorials
Terraform vs CloudFormation vs CDK vs Pulumi: Which IaC Tool for AWS?
Compare Terraform/OpenTofu, AWS CloudFormation, AWS CDK and Pulumi for AWS infrastructure: language, state, multi-cloud, drift, learning curve and when to choose each.
- Terraform & OpenTofu Tutorials
Terraform Helm Provider: Deploy Helm Charts to Kubernetes with OpenTofu
Install Helm charts in a Kubernetes cluster with the Terraform and OpenTofu Helm provider: values, secrets, upgrades, ingress-nginx and cert-manager examples.
- Terraform & OpenTofu Tutorials
How to Encrypt Terraform State with OpenTofu
Step-by-step guide to encrypting the Terraform state file with OpenTofu state encryption and AWS KMS, with a full configuration example.
- Terraform & OpenTofu Tutorials
AWS with Terraform Tutorial: AWS Route 53 (DNS) (14)
Using the Terraform aws_route53_delegation_set, aws_route53_zone, and aws_route53_record resource blocks to configure DNS in AWS.
- Terraform & OpenTofu Tutorials
AWS with Terraform Tutorial: AWS RDS Instances (13)
Using the Terraform aws_db_instance resource block to configure, launch, and secure RDS instances.
- Terraform & OpenTofu Tutorials
AWS with Terraform Tutorial: AWS EC2 Instances (12)
How to use the Terraform aws_instance resource block to configure, launch, and secure EC2 instances.
- Terraform & OpenTofu Tutorials
AWS with Terraform Tutorial: AWS AMIs (11)
How to use the Terraform aws_ami data source to find the AMI (root volume template with an operating system) used to launch EC2 instances.
- Terraform & OpenTofu Tutorials
AWS with Terraform Tutorial: AWS Key Pairs (10)
How to configure and use the Terraform aws_key_pair resource to upload an SSH public key to AWS and use it for public key authentication on EC2 instances.
- Terraform & OpenTofu Tutorials
AWS with Terraform Tutorial: AWS Security Groups (9)
How to configure and use the Terraform aws_security_group and aws_security_group_rule resources to create AWS security groups and secure the infrastructure.
- Terraform & OpenTofu Tutorials
AWS with Terraform Tutorial: AWS Routing Tables (8)
How to configure and use the Terraform aws_route_table, aws_route, and aws_main_route_table_association resource blocks to create and manage AWS Routing Tables.
- Terraform & OpenTofu Tutorials
AWS with Terraform Tutorial: AWS NAT Gateway (7)
How to configure and use the Terraform aws_nat_gateway and aws_eip resources to create NAT Gateways and Elastic IPs for the private subnets of a VPC.
- Terraform & OpenTofu Tutorials
AWS with Terraform Tutorial: AWS Internet Gateway (6)
How to configure and use the Terraform aws_internet_gateway resource block to create an AWS Internet Gateway that gives a VPC access to the Internet.
- Terraform & OpenTofu Tutorials
AWS with Terraform Tutorial: AWS Subnets (5)
How to configure and use the Terraform aws_subnet resource block to create and manage AWS Subnets inside a VPC.
- Terraform & OpenTofu Tutorials
AWS with Terraform Tutorial: AWS VPC (4)
How to configure and use the Terraform aws_vpc resource block to create and manage an AWS VPC (Virtual Private Cloud), step by step.
- Terraform & OpenTofu Tutorials
AWS with Terraform Tutorial: Terraform AWS Provider (3)
How the Terraform and OpenTofu AWS provider authenticates to AWS, where to store the state and which provider source to use, before creating resources.
AWS Security, Identity and Compliance
AWS IAM
AWS Identity and Access Management (IAM) is a web service provided by Amazon Web Services (AWS) that enables users to securely control access to AWS…
- Terraform & OpenTofu Tutorials
AWS with Terraform Tutorial: AWS Basics (2)
AWS is the world’s leading cloud platform, used by startups and large enterprises.
- Terraform & OpenTofu Tutorials
AWS with Terraform Tutorial: Terraform Basics (1)
How to start building AWS infrastructure with Terraform: Terraform is an Infrastructure as Code (IaC) tool used to provision and manage infrastructure.
Infrastructure as Code
Terraform Built-in Functions
Terraform functions perform specific tasks on configuration data: numeric, string, collection, date and time, file system and more.
- AWS Tutorials
How to use Terraform, AWS, and Ansible Together
How to use Terraform to create AWS infrastructure with tags, and Ansible with its dynamic inventory plugin to configure the servers, linked by the tags.
- Ansible Tutorials
How to Install Ansible
How to install the Ansible control node on Ubuntu with apt or pipx, and check that Ansible works.
- Terraform Best Practices
How to Share Infrastructure in Multiple Terraform Projects?
Sharing infrastructure across multiple Terraform projects using Data Sources helps maintain consistency, reduce redundancy, and promote collaboration.
Operating Systems and Virtualization
SSH
SSH, which stands for Secure Shell, is a cryptographic network protocol that allows for secure communication and data transfer between two computers over an…
- Terraform & OpenTofu Tutorials
Generating and using AWS Key Pairs with Terraform or OpenTofu
Generation of an Ed25519 Key Pair for SSH Authentication on AWS Linux Machines and Uploading of Key Pairs with Terraform.
- Terraform & OpenTofu Tutorials
Terraform AWS EKS Cluster Deployment & Application Publishing through ALB
This how-to demonstrates how to use Terraform to create an AWS EKS cluster and deploy an application along with a Load Balancer on top.
- Terraform & OpenTofu Tutorials
Terraform AWS ECS Fargate Cluster Deployment & Docker Container Publishing
How-to use Terraform or OpenTofu to create an AWS ECS (Elastic Container Service) running in Fargate and deploy a Docker container.
- Terraform & OpenTofu Tutorials
How to Create AWS IAM users with Terraform & OpenTofu
Programmatically creating AWS users using IaC tools like Terraform & OpenTofu
- Terraform & OpenTofu Tutorials
Using a PGP Key Pair
Generation of a Pretty Good Privacy (PGP) Key Pair for automated AWS IAM user access key creation with Terraform.
- Terraform & OpenTofu Tutorials
How to Deploy Applications in Kubernetes using Terraform
How to publish multiple replicas of an Application (from the Docker Registry) and create a NodePort in Kubernetes using Terraform (in 10 seconds)
- Terraform & OpenTofu Tutorials
How to Migrate Infrastructure from Terraform to OpenTofu
How to migrate existing AWS Terraform-managed infrastructure that uses remote backend storage (e.g. S3) to OpenTofu.
- Terraform & OpenTofu Tutorials
How to Deploy Applications in Kubernetes using OpenTofu
How to publish multiple replicas of an application from the Docker registry and create a NodePort or a LoadBalancer in Kubernetes using OpenTofu.
- Terraform & OpenTofu Tutorials
How to Install OpenTofu
Install OpenTofu on Ubuntu with the official installer script or manually from the GitHub releases, check the installation and upgrade it.
- Terraform Best Practices
AWS and Terraform Naming Best Practices
Terraform and AWS resource naming should follow a company standard. Each company has different requirements and the standard should be adjusted.
- Terraform & OpenTofu Tutorials
How To Debug Terraform
Options and techniques for debugging Terraform and OpenTofu Infrastructure plans.
Infrastructure as Code
HCL
HCL is a domain-specific language developed by HashiCorp, a company known for its infrastructure automation tools such as Terraform, Vault, Consul, and Nomad.
Concepts and Practices
IaC
IaC is an approach to managing and provisioning computing infrastructure through machine-readable code and automation, rather than manual processes.
- Terraform & OpenTofu Tutorials
Terraform Cloud Agents in a Kubernetes Cluster
How Terraform Cloud agents (HCP Terraform agents) run Terraform on private infrastructure, deployed in a Kubernetes cluster with Terraform itself.
- Terraform & OpenTofu Tutorials
How to disable AWS instance destroy with Terraform?
Techniques to prevent infrastructure destroy in Terraform by protecting selected instances and resources from being accidentally destroyed.
- Terraform & OpenTofu Tutorials
How to programmatically use your public Internet IP address in Terraform?
Obtain your public IP address and use it in Terraform to create AWS Security Rules.
- Terraform & OpenTofu Tutorials
Creating AWS RDS Database with Terraform (4/5)
Tutorial and source code explaining how to create and manage MariaDB (or MySQL) RDS database with Terraform in AWS.
- Terraform & OpenTofu Tutorials
AWS Route 53, AMI Lookup and EC2 Creation with Terraform (3/5)
Tutorial and source code explaining how to manage AWS Route 53 DNS Service, create and register EC2 instances and find an AMI with Terraform.
- AWS Tutorials
Creating AWS EC2 Instances and Security Rules with Terraform (5/5)
Tutorial and source code explaining how to manage AWS EC2 Instances and Security with Terraform.
- Terraform & OpenTofu Tutorials
AWS VPC Subnets, Routing Tables and Internet Access using Terraform (2/5)
Tutorial and source code explaining how to create and manage AWS networking with Terraform.
- AWS Tutorials
AWS VPC, Route 53, RDS MariaDB, EC2 using Ansible and Terraform (1/5)
Tutorial and source code explaining how to provision and configure a VPC, Route 53, RDS MariaDB, Instances and security groups using Ansible and Terraform…