Terraform by HashiCorp is the industry standard for Infrastructure as Code.
First Configuration
terraform {
required_providers {
aws = { source = "hashicorp/aws", version = "~> 5.0" }
}
}
provider "aws" { region = var.aws_region }
resource "aws_instance" "web" {
ami = "ami-0c55b159cbfafe1f0"
instance_type = var.instance_type
tags = { Name = "web-server" }
}
Workflow
terraform init
terraform plan
terraform apply
terraform destroy
Remote State
terraform {
backend "s3" {
bucket = "my-terraform-state"
key = "prod/terraform.tfstate"
}
}
Modules
module "production_vpc" {
source = "./modules/vpc"
vpc_cidr = "10.0.0.0/16"
}
Explore our Cloud Platforms eBook collection.