You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create Terraform Modules locally. In this repository, you will find a step-by-step guide on developing and using Terraform modules locally, ideal for environments where access to the Terraform Public Registry is restricted from organizational private networks. The guide covers everything from downloading modules from the Terraform Public Registry to creating and executing local modules in your own environment.
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-manifests from 06-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 modules folder in Terraform Working Directory terraform-manifests
Copy the downloaded VPC module to modules folder with module folder name aws-vpc
Remove all other unused or un-required files from this downloaded module.
Update the source argument in c4-02-vpc-module.tf
Also comment version argument
# Create VPC Terraform Module
module "vpc" {
source = "./modules/aws-vpc"#version = "2.78.0"### BELOW Terraform code is truncated and will be available in c4-02-vpc-module.tf
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.tf to get how the advanced level code they write to build such type of re-usable modules
This repository provides a detailed guide on how to develop and utilize Terraform modules locally, particularly useful when access to the Terraform Public Registry is restricted from organizational private networks.