--- name: aws-iac-patterns description: >- Terraform patterns for AWS products that validate against one pinned version of the hashicorp/aws provider: VPC, IAM roles, ECS on Fargate, Lambda, RDS, S3, Secrets Manager and CloudWatch. Use when writing Terraform for an AWS product, before writing the resource. metadata: scope: deployment guidance provider: hashicorp/aws 6.10.0 --- # AWS IaC patterns Every pattern here passes `terraform validate` against `hashicorp/aws 6.10.0`. A test runs that on each of them, so an argument you copy from a pattern is in the right block. ## How to use them 1. Write `assets/versions.tf` to your working copy as `terraform/versions.tf`, unchanged. It pins the provider version these patterns and the `terraform_schema` tool describe. Declare the `region` variable in `terraform/variables.tf`. 2. For each Element in the Target architecture, read the reference for its product with `load_skill_resource` and start from its pattern. Read only the references for products the Target architecture uses. 3. Change the pattern to meet the Element's Checks. For a setting the pattern does not show, call `terraform_schema` with `find` set to its name before you write it. | Product | Reference | | --- | --- | | VPC | `references/vpc.md` | | IAM role | `references/iam-role.md` | | ECS on Fargate | `references/ecs-fargate.md` | | Lambda | `references/lambda.md` | | RDS PostgreSQL | `references/rds.md` | | S3 bucket | `references/s3.md` | | Secrets Manager | `references/secrets-manager.md` | | CloudWatch alarm | `references/cloudwatch.md` | For a product with no reference, use `terraform_schema` to find its resource type and arguments. Never write an argument you haven't confirmed.