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
https://github.com/stacksimplify/terraform-aws-s3-website.git
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)
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
c1-versions.tf
c2-variables.tf : Review and discuss about changing bucket name due to AWS Unique constraints
c3-s3bucket.tf
c4-outputs.tf
module "website_s3_bucket" {
source = "app.terraform.io/hctaprep/s3-website-internal/aws"
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
Observation:
1. Should fail with error due to cli not having access to Private module registry in Terraform Cloud
# Terraform Login
terraform login
Observation:
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:
https://www.terraform.io/docs/cli/config/config-file.html#credentials-1
https://www.terraform.io/docs/cloud/registry/using.html#configuration# Terraform Initialize
terraform init
Observation:
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