Build reusable Terraform modules for AWS, Azure, and GCP infrastructure following infrastructure-as-code best practices...
This catalog copy contains the inline guidance below, but does not include the following supporting paths. They are external prerequisites, not bundled files:
<support-root>/assets/vpc-module/<support-root>/assets/rds-module/<support-root>/references/azure-modules.md<support-root>/references/gcp-modules.mdAsk for the original supporting material or an existing installation before using a step that depends on these paths; this catalog does not identify a verified download source for them. Resolve each path relative to that installation, inspect its contents, and verify any applicable license and execution prerequisites. Do not run a command or claim a referenced procedure was followed until its required file exists. Do not fabricate the missing scripts or treat an unrelated file with the same name as equivalent. Independent steps fully documented here can proceed within the userβs authorized scope; report any dependent step as unavailable.
Production-ready Terraform module patterns for AWS, Azure, and GCP infrastructure.
Create reusable, well-tested Terraform modules for common cloud infrastructure patterns across multiple cloud providers.
terraform-modules/
βββ aws/
β βββ vpc/
β βββ eks/
β βββ rds/
β βββ s3/
βββ azure/
β βββ vnet/
β βββ aks/
β βββ storage/
βββ gcp/
βββ vpc/
βββ gke/
βββ cloud-sql/
module-name/
βββ main.tf # Main resources
βββ variables.tf # Input variables
βββ outputs.tf # Output values
βββ versions.tf # Provider versions
βββ README.md # Documentation
βββ examples/ # Usage examples
β βββ complete/
β βββ main.tf
β βββ variables.tf
βββ tests/ # Terratest files
βββ module_test.go
main.tf:
resource "aws_vpc" "main" {
cidr_block = var.cidr_block
enable_dns_hostnames = var.enable_dns_hostnames
enable_dns_support = var.enable_dns_support
tags = merge(
{
Name = var.name
},
var.tags
)
}
resource "aws_subnet" "private" {
count = length(var.private_subnet_cidrs)
vpc_id = aws_vpc.main.id
cidr_block = var.private_subnet_cidrs[count.index]
availability_zone = var.availability_zones[count.index]
tags = merge(
{
Name = "${var.name}-private-${count.index + 1}"
Tier = "private"
},
var.tags
)
}
resource "aws_internet_gateway" "main" {
count = var.create_internet_gateway ? 1 : 0
vpc_id = aws_vpc.main.id
tags = merge(
{
Name = "${var.name}-igw"
},
var.tags
)
}
variables.tf:
variable "name" {
description = "Name of the VPC"
type = string
}
variable "cidr_block" {
description = "CIDR block for VPC"
type = string
validation {
condition = can(cidrnetmask(var.cidr_block))
error_message = "CIDR block must be valid IPv4 CIDR notation."
}
}
variable "availability_zones" {
description = "List of availability zones"
type = list(string)
}
variable "private_subnet_cidrs" {
description = "CIDR blocks for private subnets"
type = list(string)
default = []
}
variable "enable_dns_hostnames" {
description = "Enable DNS hostnames in VPC"
type = bool
default = true
}
variable "enable_dns_support" {
type = bool
default = true
}
variable "create_internet_gateway" {
type = bool
default = false
}
variable "tags" {
description = "Additional tags"
type = map(string)
default = {}
}
outputs.tf:
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 "vpc" {
source = "../../modules/aws/vpc"
name = "production"
cidr_block = "10.0.0.0/16"
availability_zones = ["us-west-2a", "us-west-2b", "us-west-2c"]
private_subnet_cidrs = [
"10.0.1.0/24",
"10.0.2.0/24",
"10.0.3.0/24"
]
tags = {
Environment = "production"
ManagedBy = "terraform"
}
}
module "rds" {
source = "../../modules/aws/rds"
identifier = "production-db"
engine = "postgres"
engine_version = "15.3"
instance_class = "db.t3.large"
vpc_id = module.vpc.vpc_id
subnet_ids = module.vpc.private_subnet_ids
tags = {
Environment = "production"
}
}
assets/vpc-module/ - Complete VPC module exampleassets/rds-module/ - RDS module examplereferences/aws-modules.md - AWS module patternsreferences/azure-modules.md - Azure module patternsreferences/gcp-modules.md - GCP module patterns// tests/vpc_test.go
package test
import (
"testing"
"github.com/gruntwork-io/terratest/modules/terraform"
"github.com/stretchr/testify/assert"
)
func TestVPCModule(t *testing.T) {
terraformOptions := &terraform.Options{
TerraformDir: "../examples/complete",
}
defer terraform.Destroy(t, terraformOptions)
terraform.InitAndApply(t, terraformOptions)
vpcID := terraform.Output(t, terraformOptions, "vpc_id")
assert.NotEmpty(t, vpcID)
}
multi-cloud-architecture - For architectural decisionscost-optimization - For cost-effective designsThe VPC fragment does not create routing/NAT or a full private network. Validate every subnet CIDR, non-overlap, VPC containment and sufficient availability-zone entries before planning; route-table/NAT decisions require a separate design. The RDS module and other missing assets cannot be executed from this catalog. Terratest InitAndApply/Destroy create/delete billable infrastructure: use an authorized disposable account/workspace, immutable provider/module pins, cost limits and task-owned cleanup. Confirm current engine/provider compatibility rather than treating historical versions as current recommendations.