Terraform on Ubuntu 26.04 LTS - sudo-rs, APT Rollback, and Hardened Base Images
Install and run Terraform on Ubuntu 26.04 LTS Resolute Raccoon. Covers sudo-rs as default, APT 3.2 rollback, Kernel 7.0, Wayland-only, ROCm, and building...
Terraform
Import existing cloud resources into Terraform state. Step-by-step guide covering AWS, Azure, and GCP resources with import block syntax.
This comprehensive guide covers everything you need to know with practical, copy-paste examples for your Terraform projects.
Understanding this topic is essential for writing production-ready Terraform code that scales across teams and environments.
terraform {
required_version = ">= 1.5"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
provider "aws" {
region = var.region
}variable "environment" {
type = string
description = "Deployment environment"
default = "dev"
validation {
condition = contains(["dev", "staging", "prod"], var.environment)
error_message = "Must be dev, staging, or prod."
}
}
locals {
name_prefix = "myapp-${var.environment}"
common_tags = {
Environment = var.environment
ManagedBy = "terraform"
Project = var.project_name
}
}
resource "aws_instance" "app" {
ami = data.aws_ami.latest.id
instance_type = local.is_prod ? "t3.large" : "t3.micro"
tags = merge(local.common_tags, { Name = "${local.name_prefix}-app" })
}For production environments, consider these patterns:
# Dynamic blocks for flexible configuration
resource "aws_security_group" "app" {
name = "${local.name_prefix}-sg"
dynamic "ingress" {
for_each = var.ingress_rules
content {
from_port = ingress.value.port
to_port = ingress.value.port
protocol = "tcp"
cidr_blocks = ingress.value.cidrs
}
}
}terraform plan output before applyingRelated: How to install AWS CLI on macOS using Homebrew — set up AWS CLI in minutes.
Apply these patterns in your next Terraform project for cleaner, more maintainable infrastructure code. Bookmark this guide for quick reference.
Install and run Terraform on Ubuntu 26.04 LTS Resolute Raccoon. Covers sudo-rs as default, APT 3.2 rollback, Kernel 7.0, Wayland-only, ROCm, and building...
Set up Terraform CI-CD with GitHub Actions. Covers plan on PR, apply on merge, state locking, secrets management, and environment protection.
Deploy and manage Docker containers with Terraform. Covers the Docker provider, images, containers, networks, and volumes with practical examples.
Master Terraform workspaces for managing dev, staging, and production environments. Covers workspace commands, state isolation, and CI/CD integration.