Overview
We’ll leverage a Terraform Registry module for AWS VPC creation, which offers a battle-tested, configurable blueprint. Terragrunt will orchestrate calls to Terraform, handling remote state and DRY configurations for each environment. Key benefits:- Reuse and standardization via community module
- Automated remote state management
- Environment-specific inputs for custom network topologies
Prerequisites
- Terraform v1.0+ installed
- Terragrunt v0.35+ installed
- AWS CLI configured with appropriate IAM permissions
Terragrunt Directory Layout
Create a directory structure like:terragrunt.hcl will reference the community VPC module and supply environment-specific variables.
terragrunt.hcl Example
Below is a minimalterragrunt.hcl for the development environment:
Be sure to adjust
cidr, azs, subnet ranges, and tags to match each environment’s constraints and compliance requirements.Deployment Steps
- Change into your environment’s VPC directory:
- Initialize Terragrunt (which bootstraps Terraform modules and remote state):
- Preview the planned changes:
- Apply the configuration to create/update the VPC:
| Command | Description |
|---|---|
terragrunt init | Download modules and configure remote state |
terragrunt plan | Show proposed infrastructure changes |
terragrunt apply | Execute changes to provision or update resources |
Next Steps
- Repeat the
terragrunt applyprocess for the production directory. - Integrate other network components (NAT gateways, security groups).
- Reference Terraform AWS VPC module documentation for advanced options.