Develop Terraform Modules Locally¶
Step-01: Introduction¶
- How to develop Terraform modules locally ?
- How to leverage and use open source Terraform Modules locally if we don't have access from our organization private networks to Terraform Public Registry ?
Step-02: Copy templates from 06-AWS-VPC¶
- Copy
terraform-manifestsfrom06-AWS-VPC\06-02-AWS-VPC-using-Terraform\terraform-manifests\v2-vpc-module-standardized
Step-03: Download Public Registry Terraform Module¶
- Download the VPC module from Terraform Public Registry
Step-04: Create VPC Local Module¶
- Create
modulesfolder in Terraform Working Directoryterraform-manifests - Copy the downloaded VPC module to
modulesfolder with module folder nameaws-vpc - Remove all other unused or un-required files from this downloaded module.
- Update the
sourceargument inc4-02-vpc-module.tf - Also comment
versionargument
Step-05: Execute Terraform Commands¶
# Terraform Initialize
terraform init
Observation:
1. Verify the cli output
2. Verify the .terraform\modules folder
3. It will just have the module.json file referencing to local modules folder where aws-vpc module is present
# Terraform Validate
terraform validate
# Terraform Plan
terraform plan
# Terraform Apply
terraform apply -auto-approve
Step-06: Additional Understanding¶
- If we want to develop local modules in our organization, don't need to build everything from scratch
- Analyze what all open source modules available for us and use them and change those as per our requirement.
- If we don't relevant module, atleast refer these module related code
main.tfto get how the advanced level code they write to build such type of re-usable modules
Step-07: Clean-Up¶
# Terraform Destroy
terraform destroy -auto-approve
# Delete Files
rm -rf .terraform*
rm -rf terraform.tfstate*
🎉 New Course
Ultimate DevOps Real-World Project Implementation on AWS
$15.99
$84.99
81% OFF
MARCH2026
Enroll Now on Udemy →
🎉 Offer

