Standardize Cloud Infrastructure with Terraform Modules
A skill for building production-ready, reusable Terraform module patterns across AWS, Azure, and GCP infrastructure.
Why it matters
Leverage production-ready Terraform module patterns for AWS, Azure, and GCP to build reusable, well-tested infrastructure components and standardize cloud resource provisioning across your organization.
Outcomes
What it gets done
Generate multi-cloud compatible Terraform modules for common infrastructure patterns.
Implement infrastructure as code best practices with standardized module structures.
Create reusable VPC, EKS/GKE, RDS/Cloud SQL, and Storage modules.
Ensure module quality through validation, testing, and documentation.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/ag-terraform-module-library | bash Overview
Terraform Module Library
Builds production-ready, reusable Terraform modules for AWS, Azure, and GCP with a standard structure, input validation, module composition, and Terratest coverage. Use when building or standardizing reusable Terraform infrastructure modules across cloud providers; not for tasks outside module-library scope.
What it does
This skill creates reusable, well-tested Terraform modules for common cloud infrastructure patterns across AWS, Azure, and GCP. It organizes a module library by provider and resource type - for example aws/vpc, aws/eks, aws/rds, aws/s3, azure/vnet, azure/aks, azure/storage, gcp/vpc, gcp/gke, and gcp/cloud-sql - and enforces a standard internal structure for every module: main.tf for resources, variables.tf for inputs, outputs.tf for exposed values, versions.tf for pinned provider versions, a README.md, an examples/complete/ directory, and a tests/ directory with Terratest Go files.
A worked AWS VPC module shows the pattern end to end: main.tf creates the VPC, private subnets (via count over a CIDR list), and a conditional internet gateway; variables.tf declares typed inputs with descriptions and a validation block that regex-checks the CIDR block format; outputs.tf exposes the VPC ID, subnet IDs, and CIDR block for downstream composition:
output "vpc_id" {
description = "ID of the VPC"
value = aws_vpc.main.id
}
output "private_subnet_ids" {
description = "IDs of private subnets"
value = aws_subnet.private[*].id
}
output "vpc_cidr_block" {
description = "CIDR block of VPC"
value = aws_vpc.main.cidr_block
}
Module composition is shown by wiring a vpc module's outputs (module.vpc.vpc_id, module.vpc.private_subnet_ids) directly into an rds module's inputs, so downstream modules consume upstream module outputs rather than duplicating resource references. Testing uses Terratest: a Go test in tests/vpc_test.go points terraform.Options at the examples/complete directory, runs terraform.InitAndApply, asserts the vpc_id output is non-empty, and defers terraform.Destroy to tear the real infrastructure down after the test regardless of outcome. Reference files for each provider (references/aws-modules.md, references/azure-modules.md, references/gcp-modules.md) and complete example modules (assets/vpc-module/, assets/rds-module/) back the pattern with fuller examples.
When to use - and when NOT to
Use it when building reusable infrastructure components, standardizing cloud resource provisioning, implementing infrastructure-as-code best practices, creating multi-cloud-compatible modules, or establishing organizational Terraform standards. It pairs with multi-cloud-architecture for architectural decisions and cost-optimization for cost-effective designs.
Do not use it for tasks unrelated to Terraform module libraries or that need a different domain or tool outside this scope.
Inputs and outputs
Output is a complete module (resources, typed variables with validation, outputs, pinned versions, documentation, examples, and tests) or guidance applying one of the ten listed best practices: semantic versioning, documenting every variable, providing examples, using validation blocks, exposing important attributes as outputs, pinning provider versions, using locals for computed values, implementing conditional resources with count/for_each, testing with Terratest, and consistent resource tagging.
Who it's for
Platform and infrastructure engineers building or standardizing a reusable Terraform module library across one or more cloud providers for their organization.
FAQ
Common questions
Discussion
Questions & comments ยท 0
Sign In Sign in to leave a comment.