← All insightsIntegration

How to use Amazon Web Services with Terraform

CodeWizard Academy · 20 April 2025 · 3 min read · Intermediate

Amazon Web Services and Terraform are a common pairing in a modern DevOps stack. Here is how they fit together and a practical way to wire them up.

Where Amazon Web Services fits

AWS is a broad public cloud spanning compute (EC2, ECS, EKS, Lambda), storage (S3, EBS), networking (VPC) and hundreds of managed services - best operated declaratively with IaC and least-privilege IAM.

hcl
data "aws_iam_policy_document" "read_assets" {
  statement {
    actions   = ["s3:GetObject"]
    resources = ["arn:aws:s3:::acme-assets/*"]
  }
}
resource "aws_iam_policy" "read_assets" {
  name   = "read-assets"
  policy = data.aws_iam_policy_document.read_assets.json
}

Where Terraform fits

Terraform describes infrastructure as declarative HCL, builds a dependency graph, and shows a plan of exactly what will change before it applies - across AWS, Azure, GCP and hundreds of providers.

hcl
terraform {
  required_providers { aws = { source = "hashicorp/aws", version = "~> 5.0" } }
  backend "s3" {
    bucket = "acme-tfstate"
    key    = "prod/network.tfstate"
    region = "eu-west-1"
  }
}

variable "env" { type = string, default = "prod" }

resource "aws_s3_bucket" "assets" {
  bucket = "acme-${var.env}-assets"
  tags   = { Environment = var.env }
}

Making them work together

  • Use SSO for humans and OIDC roles for CI - no static keys
  • Write least-privilege IAM and manage everything via IaC
  • Remote, locked state; separate state per environment/component
  • Pin provider and module versions; commit .terraform.lock.hcl

Want this pairing set up properly, with docs and handover? That is exactly the kind of work CodeWizard's embedded senior engineers do - and both Amazon Web Services and Terraform have active community groups you can join for free.

Like where this is going?

Get hands-on help from the engineers who write these posts.

Book a free consult