Skip to content

Share Modules in Private Modules Registry

Step-01: Introduction

  • Create and version a GitHub repository for use in the private module registry
  • Import a module into your organization's private module registry.
  • Construct a root module to consume modules from the private registry.
  • Over the process also learn about terraform login command

Step-02: Create new github Repository for s3-website terraform module

Step-02-01: Craete new Github Repository

  • URL:
  • Click on Create a new repository
  • Follow Naming Conventions for modules
  • Sample: terraform-aws-s3-website
  • Repository Name: terraform-aws-s3-website
  • Description: Terraform Modules to be shared in Private Registry
  • Repo Type: Public / Private
  • Initialize this repository with:
  • UN-CHECK - Add a README file
  • CHECK - Add .gitignore
  • Select .gitignore Template: Terraform
  • CHECK - Choose a license
  • Select License: Apache 2.0 License (Optional)
  • Click on Create repository

Step-02-02: Create New Release Tag 1.0.0 in Repo

  • Go to Right Navigation on github Repo -> Releases -> Create a new release
  • Tag Version: 1.0.0
  • Release Title: Release-1 terraform-aws-s3-website
  • Write: Terraform Module for Private Registry - terraform-aws-s3-website
  • Click on Publish Release

Step-03: Clone Github Repository to Local Desktop

# Clone Github Repo
git clone<YOUR_GITHUB_ID>/<YOUR_REPO>.git
git clone

Step-04: Copy files from terraform-manifests to local repo & Check-In Code

  • Orignial Source Location: 10-Terraform-Modules/10-02-Terraform-Build-a-Module/v3-build-a-module-to-host-static-website-on-aws-s3/modules/aws-s3-static-website-bucket
  • Source Location from this section: terraform-s3-website-module-manifests
  • Destination Location: Newly cloned github repository folder in your local desktop terraform-module-s3-website
  • Check-In code to Remote Repository
# GIT Status
git status

# Git Local Commit
git add .
git commit -am "TF Module Files First Commit"

# Push to Remote Repository
git push

# Verify the same on Remote Repository

Step-05: Add VCS Provider as Github using OAuth App in Terraform Cloud

Step-05-01: Add VCS Provider as Github using OAuth App in Terraform Cloud

  • Login to Terraform Cloud
  • Click on Modules Tab -> Click on Add Module -> Select Github(Custom)
  • Should redirect to URL: in new browser tab
  • Application Name: Terraform Cloud (hctaprep)
  • Homepage URL:
  • Application description: Terraform Cloud Integration with Github using OAuth
  • Authorization callback URL:
  • Click on Register Application
  • Make a note of Client ID: 97e5219d6edd8986817e (Sample for reference)
  • Generate new Client Secret: abcdefghijklmnopqrstuvwxyx

Step-05-02: Add the below in Terraform Cloud

  • Name: github-terraform-modules
  • Client ID: 97e5219d6edd8986817e
  • Client Secret: abcdefghijklmnopqrstuvwxyx
  • Click on Connect and Continue
  • Authorize Terraform Cloud (hctaprep) - Click on Authorize StackSimplify
  • SSH Keypair (Optional): click on Skip and Finish

Step-06: Import the Terraform Module from Github

  • In above step, we have completed the VCS Setup with github
  • Now lets go ahead and import the Terraform module from Github
  • Login to Terraform Cloud
  • Click on Modules Tab -> Click on Add Module -> Select Github(github-terraform-modules) (PRE-POPULATED) -> Select it
  • Choose a Repository: terraform-module-s3-website
  • Click on Publish Module

Step-07: Review newly imported Module

  • Login to Terraform Cloud -> Click on Modules Tab
  • Review the Module Tabs on Terraform Cloud
  • Readme
  • Inputs
  • Outputs
  • Dependencies
  • Resources
  • Also review the following
  • Versions
  • Provision Instructions

Step-08: Create a configuration that uses the Private Registry module using Terraform CLI

Step-08-01: Call Module from Terraform Work Directory (Root Module)

  • CreateTerraform Configuration in Root Module by calling the newly published module in Terraform Private Registry
  • : Review and discuss about changing bucket name due to AWS Unique constraints
module "website_s3_bucket" {
  source  = ""
  version = "1.0.0"
  # insert required variables here
  bucket_name = var.my_s3_bucket
  tags = var.my_s3_tags  

Step-08-02: Execute Terraform Commands

# Terraform Initialize
terraform init
1. Should fail with error due to cli not having access to Private module registry in Terraform Cloud

# Terraform Login
terraform login
1) Should see message |Success! Terraform has obtained and saved an API token.|
2) Verify Terraform credentials file
cat /Users/<YOUR_USER>/.terraform.d/credentials.tfrc.json
cat /Users/kdaida/.terraform.d/credentials.tfrc.json
Additional Reference:

# Terraform Initialize
terraform init
1. Should pass and download modules and providers

# Terraform Validate
terraform validate

# Terraform Format
terraform fmt

# Terraform Plan
terraform plan

# Terraform Apply
terraform apply -auto-approve

# Verify 
1. Bucket has static website hosting enabled
2. Bucket has public read access enabled using policy
3. Bucket has "Block all public access" unchecked

Step-08-03: Upload index.html and test

# Endpoint Format

# Replace Values (Bucket Name, Region)

Step-08-04: Destroy and Clean-Up

# Terraform Destroy
terraform destroy -auto-approve

# Delete Terraform files 
rm -rf .terraform*
rm -rf terraform.tfstate*

Step-09: Create a configuration that uses the Private Registry module using Terraform Cloud & Github


  1. Create Github Repository
  2. Check-In files from terraform-manifests folder in 11-02 section
  3. Create a new Workspace in Terraform Cloud to connect with Github Repository
  4. Execute Queue Plan to apply the changes and test

Step-10: VCS Providers & Terraform Cloud