Terraform Modules - Step by Step
+ + \ No newline at end of file diff --git a/BACKUP-2024/10-Terraform-Modules/10-02-Terraform-Build-a-Module/Oldv1- backup/v1-create-static-website-on-s3-using-aws-mgmt-console/policy-public-read-access-for-website.json b/BACKUP-2024/10-Terraform-Modules/10-02-Terraform-Build-a-Module/Oldv1- backup/v1-create-static-website-on-s3-using-aws-mgmt-console/policy-public-read-access-for-website.json new file mode 100644 index 00000000..1b47fe4f --- /dev/null +++ b/BACKUP-2024/10-Terraform-Modules/10-02-Terraform-Build-a-Module/Oldv1- backup/v1-create-static-website-on-s3-using-aws-mgmt-console/policy-public-read-access-for-website.json @@ -0,0 +1,16 @@ +{ + "Version": "2012-10-17", + "Statement": [ + { + "Sid": "PublicReadGetObject", + "Effect": "Allow", + "Principal": "*", + "Action": [ + "s3:GetObject" + ], + "Resource": [ + "arn:aws:s3:::mybucket-1045/*" + ] + } + ] +} \ No newline at end of file diff --git a/BACKUP-2024/10-Terraform-Modules/10-02-Terraform-Build-a-Module/Oldv1- backup/v2-host-static-website-on-s3-using-terraform-manifests/main.tf b/BACKUP-2024/10-Terraform-Modules/10-02-Terraform-Build-a-Module/Oldv1- backup/v2-host-static-website-on-s3-using-terraform-manifests/main.tf new file mode 100644 index 00000000..00b2bfcf --- /dev/null +++ b/BACKUP-2024/10-Terraform-Modules/10-02-Terraform-Build-a-Module/Oldv1- backup/v2-host-static-website-on-s3-using-terraform-manifests/main.tf @@ -0,0 +1,30 @@ +# Create S3 Bucket Resource +resource "aws_s3_bucket" "s3_bucket" { + bucket = var.bucket_name + acl = "public-read" + policy = <Terraform Modules - Step by Step
+ + \ No newline at end of file diff --git a/BACKUP-2024/10-Terraform-Modules/10-02-Terraform-Build-a-Module/v1-create-static-website-on-s3-using-aws-mgmt-console/policy-public-read-access-for-website.json b/BACKUP-2024/10-Terraform-Modules/10-02-Terraform-Build-a-Module/v1-create-static-website-on-s3-using-aws-mgmt-console/policy-public-read-access-for-website.json new file mode 100644 index 00000000..1b47fe4f --- /dev/null +++ b/BACKUP-2024/10-Terraform-Modules/10-02-Terraform-Build-a-Module/v1-create-static-website-on-s3-using-aws-mgmt-console/policy-public-read-access-for-website.json @@ -0,0 +1,16 @@ +{ + "Version": "2012-10-17", + "Statement": [ + { + "Sid": "PublicReadGetObject", + "Effect": "Allow", + "Principal": "*", + "Action": [ + "s3:GetObject" + ], + "Resource": [ + "arn:aws:s3:::mybucket-1045/*" + ] + } + ] +} \ No newline at end of file diff --git a/BACKUP-2024/10-Terraform-Modules/10-02-Terraform-Build-a-Module/v2-host-static-website-on-s3-using-terraform-manifests/main.tf b/BACKUP-2024/10-Terraform-Modules/10-02-Terraform-Build-a-Module/v2-host-static-website-on-s3-using-terraform-manifests/main.tf new file mode 100644 index 00000000..00b2bfcf --- /dev/null +++ b/BACKUP-2024/10-Terraform-Modules/10-02-Terraform-Build-a-Module/v2-host-static-website-on-s3-using-terraform-manifests/main.tf @@ -0,0 +1,30 @@ +# Create S3 Bucket Resource +resource "aws_s3_bucket" "s3_bucket" { + bucket = var.bucket_name + acl = "public-read" + policy = <Terraform Modules - Step by Step
+ + \ No newline at end of file diff --git a/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-manifests-oldv1/c1-versions.tf b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-manifests-oldv1/c1-versions.tf new file mode 100644 index 00000000..a305835c --- /dev/null +++ b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-manifests-oldv1/c1-versions.tf @@ -0,0 +1,20 @@ +# Terraform Block +terraform { + required_version = "~> 0.14" # which means any version equal & above 0.14 like 0.15, 0.16 etc and < 1.xx + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 3.0" + } + } +} + +# Provider Block +provider "aws" { + region = var.aws_region + profile = "default" +} +/* +Note-1: AWS Credentials Profile (profile = "default") configured on your local desktop terminal +$HOME/.aws/credentials +*/ diff --git a/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-manifests-oldv1/c2-variables.tf b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-manifests-oldv1/c2-variables.tf new file mode 100644 index 00000000..08ad15d2 --- /dev/null +++ b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-manifests-oldv1/c2-variables.tf @@ -0,0 +1,25 @@ +# Input Variables +variable "aws_region" { + description = "Region in which AWS Resources to be created" + type = string + default = "us-east-1" +} + +## Create Variable for S3 Bucket Name +variable "my_s3_bucket" { + description = "S3 Bucket name that we pass to S3 Custom Module" + type = string + default = "mybucket-1051" +} + +## Create Variable for S3 Bucket Tags +variable "my_s3_tags" { + description = "Tags to set on the bucket" + type = map(string) + default = { + Terraform = "true" + Environment = "dev" + newtag1 = "tag1" + newtag2 = "tag2" + } +} diff --git a/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-manifests-oldv1/c3-s3bucket.tf b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-manifests-oldv1/c3-s3bucket.tf new file mode 100644 index 00000000..d33af476 --- /dev/null +++ b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-manifests-oldv1/c3-s3bucket.tf @@ -0,0 +1,8 @@ +# Call our Custom Terraform Module which we built earlier +module "website_s3_bucket123" { + source = "app.terraform.io/hcta-demo1/s3-website/aws" + version = "1.0.1" + # insert required variables here + bucket_name = var.my_s3_bucket + tags = var.my_s3_tags +} \ No newline at end of file diff --git a/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-manifests-oldv1/c4-outputs.tf b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-manifests-oldv1/c4-outputs.tf new file mode 100644 index 00000000..ac095c12 --- /dev/null +++ b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-manifests-oldv1/c4-outputs.tf @@ -0,0 +1,25 @@ +# Output definitions + +## S3 Bucket ARN +output "website_bucket_arn" { + description = "ARN of the bucket" + value = module.website_s3_bucket.arn +} + +## S3 Bucket Name +output "website_bucket_name" { + description = "Name (id) of the bucket" + value = module.website_s3_bucket.name +} + +## S3 Bucket Domain +output "website_bucket_domain" { + description = "Name (id) of the bucket" + value = module.website_s3_bucket.domain +} + +## S3 Bucket Endpoint +output "website_bucket_endpoint" { + description = "Name (id) of the bucket" + value = module.website_s3_bucket.endpoint +} diff --git a/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-manifests/c1-versions.tf b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-manifests/c1-versions.tf new file mode 100644 index 00000000..cffef5ab --- /dev/null +++ b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-manifests/c1-versions.tf @@ -0,0 +1,20 @@ +# Terraform Block +terraform { + required_version = ">= 1.4" + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 4.0" + } + } +} + +# Provider Block +provider "aws" { + region = var.aws_region + profile = "default" +} +/* +Note-1: AWS Credentials Profile (profile = "default") configured on your local desktop terminal +$HOME/.aws/credentials +*/ diff --git a/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-manifests/c2-variables.tf b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-manifests/c2-variables.tf new file mode 100644 index 00000000..08ad15d2 --- /dev/null +++ b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-manifests/c2-variables.tf @@ -0,0 +1,25 @@ +# Input Variables +variable "aws_region" { + description = "Region in which AWS Resources to be created" + type = string + default = "us-east-1" +} + +## Create Variable for S3 Bucket Name +variable "my_s3_bucket" { + description = "S3 Bucket name that we pass to S3 Custom Module" + type = string + default = "mybucket-1051" +} + +## Create Variable for S3 Bucket Tags +variable "my_s3_tags" { + description = "Tags to set on the bucket" + type = map(string) + default = { + Terraform = "true" + Environment = "dev" + newtag1 = "tag1" + newtag2 = "tag2" + } +} diff --git a/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-manifests/c3-s3bucket.tf b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-manifests/c3-s3bucket.tf new file mode 100644 index 00000000..d33af476 --- /dev/null +++ b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-manifests/c3-s3bucket.tf @@ -0,0 +1,8 @@ +# Call our Custom Terraform Module which we built earlier +module "website_s3_bucket123" { + source = "app.terraform.io/hcta-demo1/s3-website/aws" + version = "1.0.1" + # insert required variables here + bucket_name = var.my_s3_bucket + tags = var.my_s3_tags +} \ No newline at end of file diff --git a/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-manifests/c4-outputs.tf b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-manifests/c4-outputs.tf new file mode 100644 index 00000000..ac095c12 --- /dev/null +++ b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-manifests/c4-outputs.tf @@ -0,0 +1,25 @@ +# Output definitions + +## S3 Bucket ARN +output "website_bucket_arn" { + description = "ARN of the bucket" + value = module.website_s3_bucket.arn +} + +## S3 Bucket Name +output "website_bucket_name" { + description = "Name (id) of the bucket" + value = module.website_s3_bucket.name +} + +## S3 Bucket Domain +output "website_bucket_domain" { + description = "Name (id) of the bucket" + value = module.website_s3_bucket.domain +} + +## S3 Bucket Endpoint +output "website_bucket_endpoint" { + description = "Name (id) of the bucket" + value = module.website_s3_bucket.endpoint +} diff --git a/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-s3-website-module-manifests/LICENSE b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-s3-website-module-manifests/LICENSE new file mode 100644 index 00000000..d955a86d --- /dev/null +++ b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-s3-website-module-manifests/LICENSE @@ -0,0 +1,11 @@ +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. \ No newline at end of file diff --git a/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-s3-website-module-manifests/README.md b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-s3-website-module-manifests/README.md new file mode 100644 index 00000000..90d2ce19 --- /dev/null +++ b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-s3-website-module-manifests/README.md @@ -0,0 +1,4 @@ +# Terraform Module for Private Registry - AWS S3 Static website +- This module provisions AWS S3 buckets configured for static website hosting. +- This will be a demo S3 module + diff --git a/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-s3-website-module-manifests/main.tf b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-s3-website-module-manifests/main.tf new file mode 100644 index 00000000..00b2bfcf --- /dev/null +++ b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-02-Share-Modules-in-Private-Module-Registry/terraform-s3-website-module-manifests/main.tf @@ -0,0 +1,30 @@ +# Create S3 Bucket Resource +resource "aws_s3_bucket" "s3_bucket" { + bucket = var.bucket_name + acl = "public-read" + policy = <Terraform Modules - Step by Step
+ + \ No newline at end of file diff --git a/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-03-Terraform-Cloud-CLI-Driven-Workflow/terraform-manifests-oldv1/c1-versions.tf b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-03-Terraform-Cloud-CLI-Driven-Workflow/terraform-manifests-oldv1/c1-versions.tf new file mode 100644 index 00000000..562ecd36 --- /dev/null +++ b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-03-Terraform-Cloud-CLI-Driven-Workflow/terraform-manifests-oldv1/c1-versions.tf @@ -0,0 +1,27 @@ +# Terraform Block +terraform { + required_version = "~> 0.14" # which means any version equal & above 0.14 like 0.15, 0.16 etc and < 1.xx + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 3.0" + } + } + # Update Terraform Cloud Backend Block Information below + backend "remote" { + organization = "hcta-demo1" + + workspaces { + name = "cli-driven-demo" + } + } +} + +# Provider Block +provider "aws" { + region = var.aws_region +} +/* +Note-1: AWS Credentials Profile (profile = "default") configured on your local desktop terminal +$HOME/.aws/credentials +*/ diff --git a/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-03-Terraform-Cloud-CLI-Driven-Workflow/terraform-manifests-oldv1/c2-variables.tf b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-03-Terraform-Cloud-CLI-Driven-Workflow/terraform-manifests-oldv1/c2-variables.tf new file mode 100644 index 00000000..ec7c12c2 --- /dev/null +++ b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-03-Terraform-Cloud-CLI-Driven-Workflow/terraform-manifests-oldv1/c2-variables.tf @@ -0,0 +1,26 @@ +# Input Variables +variable "aws_region" { + description = "Region in which AWS Resources to be created" + type = string + default = "us-east-1" +} + +## Create Variable for S3 Bucket Name +variable "my_s3_bucket" { + description = "S3 Bucket name that we pass to S3 Custom Module" + type = string + default = "mybucket-1051" +} + +## Create Variable for S3 Bucket Tags +variable "my_s3_tags" { + description = "Tags to set on the bucket" + type = map(string) + default = { + Terraform = "true" + Environment = "dev" + newtag1 = "tag1" + newtag2 = "tag2" + newtag3 = "tag3" # Enable during Step-10 + } +} diff --git a/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-03-Terraform-Cloud-CLI-Driven-Workflow/terraform-manifests-oldv1/c3-s3bucket.tf b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-03-Terraform-Cloud-CLI-Driven-Workflow/terraform-manifests-oldv1/c3-s3bucket.tf new file mode 100644 index 00000000..3a308e0f --- /dev/null +++ b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-03-Terraform-Cloud-CLI-Driven-Workflow/terraform-manifests-oldv1/c3-s3bucket.tf @@ -0,0 +1,8 @@ +# Call our Custom Terraform Module which we built earlier +module "website_s3_bucket" { + source = "app.terraform.io/hcta-demo1/s3-website/aws" + version = "1.0.1" + # insert required variables here + bucket_name = var.my_s3_bucket + tags = var.my_s3_tags +} diff --git a/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-03-Terraform-Cloud-CLI-Driven-Workflow/terraform-manifests-oldv1/c4-outputs.tf b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-03-Terraform-Cloud-CLI-Driven-Workflow/terraform-manifests-oldv1/c4-outputs.tf new file mode 100644 index 00000000..ac095c12 --- /dev/null +++ b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-03-Terraform-Cloud-CLI-Driven-Workflow/terraform-manifests-oldv1/c4-outputs.tf @@ -0,0 +1,25 @@ +# Output definitions + +## S3 Bucket ARN +output "website_bucket_arn" { + description = "ARN of the bucket" + value = module.website_s3_bucket.arn +} + +## S3 Bucket Name +output "website_bucket_name" { + description = "Name (id) of the bucket" + value = module.website_s3_bucket.name +} + +## S3 Bucket Domain +output "website_bucket_domain" { + description = "Name (id) of the bucket" + value = module.website_s3_bucket.domain +} + +## S3 Bucket Endpoint +output "website_bucket_endpoint" { + description = "Name (id) of the bucket" + value = module.website_s3_bucket.endpoint +} diff --git a/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-03-Terraform-Cloud-CLI-Driven-Workflow/terraform-manifests/c1-versions.tf b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-03-Terraform-Cloud-CLI-Driven-Workflow/terraform-manifests/c1-versions.tf new file mode 100644 index 00000000..64de9125 --- /dev/null +++ b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-03-Terraform-Cloud-CLI-Driven-Workflow/terraform-manifests/c1-versions.tf @@ -0,0 +1,27 @@ +# Terraform Block +terraform { + required_version = ">= 1.4" # which means any version equal & above 0.14 like 0.15, 0.16 etc and < 1.xx + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 4.0" + } + } + # Update Terraform Cloud Backend Block Information below + backend "remote" { + organization = "hcta-demo1" + + workspaces { + name = "cli-driven-demo" + } + } +} + +# Provider Block +provider "aws" { + region = var.aws_region +} +/* +Note-1: AWS Credentials Profile (profile = "default") configured on your local desktop terminal +$HOME/.aws/credentials +*/ diff --git a/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-03-Terraform-Cloud-CLI-Driven-Workflow/terraform-manifests/c2-variables.tf b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-03-Terraform-Cloud-CLI-Driven-Workflow/terraform-manifests/c2-variables.tf new file mode 100644 index 00000000..ec7c12c2 --- /dev/null +++ b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-03-Terraform-Cloud-CLI-Driven-Workflow/terraform-manifests/c2-variables.tf @@ -0,0 +1,26 @@ +# Input Variables +variable "aws_region" { + description = "Region in which AWS Resources to be created" + type = string + default = "us-east-1" +} + +## Create Variable for S3 Bucket Name +variable "my_s3_bucket" { + description = "S3 Bucket name that we pass to S3 Custom Module" + type = string + default = "mybucket-1051" +} + +## Create Variable for S3 Bucket Tags +variable "my_s3_tags" { + description = "Tags to set on the bucket" + type = map(string) + default = { + Terraform = "true" + Environment = "dev" + newtag1 = "tag1" + newtag2 = "tag2" + newtag3 = "tag3" # Enable during Step-10 + } +} diff --git a/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-03-Terraform-Cloud-CLI-Driven-Workflow/terraform-manifests/c3-s3bucket.tf b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-03-Terraform-Cloud-CLI-Driven-Workflow/terraform-manifests/c3-s3bucket.tf new file mode 100644 index 00000000..3a308e0f --- /dev/null +++ b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-03-Terraform-Cloud-CLI-Driven-Workflow/terraform-manifests/c3-s3bucket.tf @@ -0,0 +1,8 @@ +# Call our Custom Terraform Module which we built earlier +module "website_s3_bucket" { + source = "app.terraform.io/hcta-demo1/s3-website/aws" + version = "1.0.1" + # insert required variables here + bucket_name = var.my_s3_bucket + tags = var.my_s3_tags +} diff --git a/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-03-Terraform-Cloud-CLI-Driven-Workflow/terraform-manifests/c4-outputs.tf b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-03-Terraform-Cloud-CLI-Driven-Workflow/terraform-manifests/c4-outputs.tf new file mode 100644 index 00000000..ac095c12 --- /dev/null +++ b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-03-Terraform-Cloud-CLI-Driven-Workflow/terraform-manifests/c4-outputs.tf @@ -0,0 +1,25 @@ +# Output definitions + +## S3 Bucket ARN +output "website_bucket_arn" { + description = "ARN of the bucket" + value = module.website_s3_bucket.arn +} + +## S3 Bucket Name +output "website_bucket_name" { + description = "Name (id) of the bucket" + value = module.website_s3_bucket.name +} + +## S3 Bucket Domain +output "website_bucket_domain" { + description = "Name (id) of the bucket" + value = module.website_s3_bucket.domain +} + +## S3 Bucket Endpoint +output "website_bucket_endpoint" { + description = "Name (id) of the bucket" + value = module.website_s3_bucket.endpoint +} diff --git a/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-04-Migrate-State-to-Terraform-Cloud/README.md b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-04-Migrate-State-to-Terraform-Cloud/README.md new file mode 100644 index 00000000..cd8e2817 --- /dev/null +++ b/BACKUP-2024/11-Terraform-Cloud-and-Enterprise-Capabilities/11-04-Migrate-State-to-Terraform-Cloud/README.md @@ -0,0 +1,157 @@ +# Migrate State to Terraform Cloud + +## Step-01: Introduction +- We are going to migrate State to Terraform Cloud + +## Step-02: Review Terraform Manifests +- c1-versions.tf +- c2-variables.tf: + - **Important Note:** No default values provided for variables +- c3-security-groups.tf +- c4-ec2-instance.tf +- c5-outputs.tf +- c6-ami-datasource.tf +- apache-install.sh + + +## Step-03: Execute Terraform Commands (First provision using local backend) +- First provision infra using local backend +- `terraform.tfstate` file will be created in local working directory +- In next steps, migrate it to Terraform Cloud +```t +# Terraform Initialize +terraform init + +# Terraform Validate +terraform validate + +# Terraform Plan +terraform plan + +# Terraform Apply +terraform apply -auto-approve +``` + +## Step-04: Review your local state file +- Review your local `terraform.tfstate` file once + + +## Step-05: Update remote backend in c1-versions.tf Terraform Block +### Step-05-01: Create New Workspace with CLI-Driven workflow +- Create New workspace with CLI-Driven workflow +- Login to [Terraform Cloud](https://app.terraform.io/) +- Select Organization -> hcta-demo1 +- Click on **New Workspace** +- **Choose your workflow:** CLI-Driven Workflow +- **Workspace Name:** state-migration-demo +- Click on **Create Workspace** + +### Step-05-02: Update remote backend in c1-versions.tf Terraform Block +```t +# Template + backend "remote" { + hostname = "app.terraform.io" + organization = "Terraform Sentinel - Demo - V1
\n\n", + "content_base64": null, + "content_disposition": null, + "content_encoding": null, + "content_language": null, + "content_type": "text/html", + "force_destroy": false, + "key": "index.html", + "metadata": null, + "object_lock_legal_hold_status": null, + "object_lock_mode": null, + "object_lock_retain_until_date": null, + "source": null, + "tags": null, + "website_redirect": null, + }, + }, + }, +} + +variables = { + "aws_region": { + "name": "aws_region", + "value": "us-east-1", + }, + "bucket_name": { + "name": "bucket_name", + "value": "mybucket-1061", + }, + "tags": { + "name": "tags", + "value": { + "Environment": "dev", + "Terraform": "true", + "newtag1": "tag1", + "newtag2": "tag2", + }, + }, +} + +resource_changes = { + "aws_s3_bucket.s3_bucket": { + "address": "aws_s3_bucket.s3_bucket", + "change": { + "actions": [ + "create", + ], + "after": { + "acl": "public-read", + "bucket": "mybucket-1061", + "bucket_prefix": null, + "cors_rule": [], + "force_destroy": true, + "grant": [], + "lifecycle_rule": [], + "logging": [], + "object_lock_configuration": [], + "policy": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"PublicReadGetObject\",\n \"Effect\": \"Allow\",\n \"Principal\": \"*\",\n \"Action\": [\n \"s3:GetObject\"\n ],\n \"Resource\": [\n \"arn:aws:s3:::mybucket-1061/*\"\n ]\n }\n ]\n} \n", + "replication_configuration": [], + "server_side_encryption_configuration": [], + "tags": { + "Environment": "dev", + "Terraform": "true", + "newtag1": "tag1", + "newtag2": "tag2", + }, + "website": [ + { + "error_document": "error.html", + "index_document": "index.html", + "redirect_all_requests_to": null, + "routing_rules": null, + }, + ], + }, + "after_unknown": { + "acceleration_status": true, + "arn": true, + "bucket_domain_name": true, + "bucket_regional_domain_name": true, + "cors_rule": [], + "grant": [], + "hosted_zone_id": true, + "id": true, + "lifecycle_rule": [], + "logging": [], + "object_lock_configuration": [], + "region": true, + "replication_configuration": [], + "request_payer": true, + "server_side_encryption_configuration": [], + "tags": {}, + "versioning": true, + "website": [ + {}, + ], + "website_domain": true, + "website_endpoint": true, + }, + "before": null, + }, + "deposed": "", + "index": null, + "mode": "managed", + "module_address": "", + "name": "s3_bucket", + "provider_name": "registry.terraform.io/hashicorp/aws", + "type": "aws_s3_bucket", + }, + "aws_s3_bucket_object.bucket": { + "address": "aws_s3_bucket_object.bucket", + "change": { + "actions": [ + "create", + ], + "after": { + "acl": "public-read", + "cache_control": null, + "content": "\n\nTerraform Sentinel - Demo - V1
\n\n", + "content_base64": null, + "content_disposition": null, + "content_encoding": null, + "content_language": null, + "content_type": "text/html", + "force_destroy": false, + "key": "index.html", + "metadata": null, + "object_lock_legal_hold_status": null, + "object_lock_mode": null, + "object_lock_retain_until_date": null, + "source": null, + "tags": null, + "website_redirect": null, + }, + "after_unknown": { + "bucket": true, + "etag": true, + "id": true, + "kms_key_id": true, + "server_side_encryption": true, + "storage_class": true, + "version_id": true, + }, + "before": null, + }, + "deposed": "", + "index": null, + "mode": "managed", + "module_address": "", + "name": "bucket", + "provider_name": "registry.terraform.io/hashicorp/aws", + "type": "aws_s3_bucket_object", + }, +} + +output_changes = { + "bucket_website_endpoint_url": { + "change": { + "actions": [ + "create", + ], + "after": undefined, + "after_unknown": true, + "before": null, + }, + "name": "bucket_website_endpoint_url", + }, + "endpoint": { + "change": { + "actions": [ + "create", + ], + "after": undefined, + "after_unknown": true, + "before": null, + }, + "name": "endpoint", + }, +} + +raw = { + "configuration": { + "provider_config": { + "aws": { + "expressions": { + "region": { + "references": [ + "var.aws_region", + ], + }, + }, + "name": "aws", + "version_constraint": "~> 3.0", + }, + }, + "root_module": { + "outputs": { + "bucket_website_endpoint_url": { + "expression": { + "references": [ + "aws_s3_bucket.s3_bucket", + ], + }, + }, + "endpoint": { + "description": "Endpoint Information of the bucket", + "expression": { + "references": [ + "aws_s3_bucket.s3_bucket", + ], + }, + }, + }, + "resources": [ + { + "address": "aws_s3_bucket.s3_bucket", + "expressions": { + "acl": { + "constant_value": "public-read", + }, + "bucket": { + "references": [ + "var.bucket_name", + ], + }, + "force_destroy": { + "constant_value": true, + }, + "policy": { + "references": [ + "var.bucket_name", + ], + }, + "tags": { + "references": [ + "var.tags", + ], + }, + "website": [ + { + "error_document": { + "constant_value": "error.html", + }, + "index_document": { + "constant_value": "index.html", + }, + }, + ], + }, + "mode": "managed", + "name": "s3_bucket", + "provider_config_key": "aws", + "schema_version": 0, + "type": "aws_s3_bucket", + }, + { + "address": "aws_s3_bucket_object.bucket", + "expressions": { + "acl": { + "constant_value": "public-read", + }, + "bucket": { + "references": [ + "aws_s3_bucket.s3_bucket", + ], + }, + "content": { + "references": [ + "path.module", + ], + }, + "content_type": { + "constant_value": "text/html", + }, + "key": { + "constant_value": "index.html", + }, + }, + "mode": "managed", + "name": "bucket", + "provider_config_key": "aws", + "schema_version": 0, + "type": "aws_s3_bucket_object", + }, + ], + "variables": { + "aws_region": { + "default": "us-east-1", + "description": "Region in which AWS Resources to be created", + }, + "bucket_name": { + "default": "mybucket-1061", + "description": "Name of the S3 bucket. Must be Unique across AWS", + }, + "tags": { + "default": { + "Environment": "dev", + "Terraform": "true", + "newtag1": "tag1", + "newtag2": "tag2", + }, + "description": "Tages to set on the bucket", + }, + }, + }, + }, + "format_version": "0.1", + "output_changes": { + "bucket_website_endpoint_url": { + "actions": [ + "create", + ], + "after_unknown": true, + "before": null, + }, + "endpoint": { + "actions": [ + "create", + ], + "after_unknown": true, + "before": null, + }, + }, + "planned_values": { + "outputs": { + "bucket_website_endpoint_url": { + "sensitive": false, + }, + "endpoint": { + "sensitive": false, + }, + }, + "root_module": { + "resources": [ + { + "address": "aws_s3_bucket.s3_bucket", + "mode": "managed", + "name": "s3_bucket", + "provider_name": "registry.terraform.io/hashicorp/aws", + "schema_version": 0, + "type": "aws_s3_bucket", + "values": { + "acl": "public-read", + "bucket": "mybucket-1061", + "bucket_prefix": null, + "cors_rule": [], + "force_destroy": true, + "grant": [], + "lifecycle_rule": [], + "logging": [], + "object_lock_configuration": [], + "policy": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"PublicReadGetObject\",\n \"Effect\": \"Allow\",\n \"Principal\": \"*\",\n \"Action\": [\n \"s3:GetObject\"\n ],\n \"Resource\": [\n \"arn:aws:s3:::mybucket-1061/*\"\n ]\n }\n ]\n} \n", + "replication_configuration": [], + "server_side_encryption_configuration": [], + "tags": { + "Environment": "dev", + "Terraform": "true", + "newtag1": "tag1", + "newtag2": "tag2", + }, + "website": [ + { + "error_document": "error.html", + "index_document": "index.html", + "redirect_all_requests_to": null, + "routing_rules": null, + }, + ], + }, + }, + { + "address": "aws_s3_bucket_object.bucket", + "mode": "managed", + "name": "bucket", + "provider_name": "registry.terraform.io/hashicorp/aws", + "schema_version": 0, + "type": "aws_s3_bucket_object", + "values": { + "acl": "public-read", + "cache_control": null, + "content": "\n\nTerraform Sentinel - Demo - V1
\n\n", + "content_base64": null, + "content_disposition": null, + "content_encoding": null, + "content_language": null, + "content_type": "text/html", + "force_destroy": false, + "key": "index.html", + "metadata": null, + "object_lock_legal_hold_status": null, + "object_lock_mode": null, + "object_lock_retain_until_date": null, + "source": null, + "tags": null, + "website_redirect": null, + }, + }, + ], + }, + }, + "resource_changes": [ + { + "address": "aws_s3_bucket.s3_bucket", + "change": { + "actions": [ + "create", + ], + "after": { + "acl": "public-read", + "bucket": "mybucket-1061", + "bucket_prefix": null, + "cors_rule": [], + "force_destroy": true, + "grant": [], + "lifecycle_rule": [], + "logging": [], + "object_lock_configuration": [], + "policy": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"PublicReadGetObject\",\n \"Effect\": \"Allow\",\n \"Principal\": \"*\",\n \"Action\": [\n \"s3:GetObject\"\n ],\n \"Resource\": [\n \"arn:aws:s3:::mybucket-1061/*\"\n ]\n }\n ]\n} \n", + "replication_configuration": [], + "server_side_encryption_configuration": [], + "tags": { + "Environment": "dev", + "Terraform": "true", + "newtag1": "tag1", + "newtag2": "tag2", + }, + "website": [ + { + "error_document": "error.html", + "index_document": "index.html", + "redirect_all_requests_to": null, + "routing_rules": null, + }, + ], + }, + "after_unknown": { + "acceleration_status": true, + "arn": true, + "bucket_domain_name": true, + "bucket_regional_domain_name": true, + "cors_rule": [], + "grant": [], + "hosted_zone_id": true, + "id": true, + "lifecycle_rule": [], + "logging": [], + "object_lock_configuration": [], + "region": true, + "replication_configuration": [], + "request_payer": true, + "server_side_encryption_configuration": [], + "tags": {}, + "versioning": true, + "website": [ + {}, + ], + "website_domain": true, + "website_endpoint": true, + }, + "before": null, + }, + "mode": "managed", + "name": "s3_bucket", + "provider_name": "registry.terraform.io/hashicorp/aws", + "type": "aws_s3_bucket", + }, + { + "address": "aws_s3_bucket_object.bucket", + "change": { + "actions": [ + "create", + ], + "after": { + "acl": "public-read", + "cache_control": null, + "content": "\n\nTerraform Sentinel - Demo - V1
\n\n", + "content_base64": null, + "content_disposition": null, + "content_encoding": null, + "content_language": null, + "content_type": "text/html", + "force_destroy": false, + "key": "index.html", + "metadata": null, + "object_lock_legal_hold_status": null, + "object_lock_mode": null, + "object_lock_retain_until_date": null, + "source": null, + "tags": null, + "website_redirect": null, + }, + "after_unknown": { + "bucket": true, + "etag": true, + "id": true, + "kms_key_id": true, + "server_side_encryption": true, + "storage_class": true, + "version_id": true, + }, + "before": null, + }, + "mode": "managed", + "name": "bucket", + "provider_name": "registry.terraform.io/hashicorp/aws", + "type": "aws_s3_bucket_object", + }, + ], + "terraform_version": "0.14.8", + "variables": { + "aws_region": { + "value": "us-east-1", + }, + "bucket_name": { + "value": "mybucket-1061", + }, + "tags": { + "value": { + "Environment": "dev", + "Terraform": "true", + "newtag1": "tag1", + "newtag2": "tag2", + }, + }, + }, +} diff --git a/BACKUP-2024/12-Terraform-Cloud-and-Sentinel/12-01-Terraform-Cloud-and-Sentinel-Policies/Sentinel-Mocks/run-9rHCA5A7cwvRAox6-sentinel-mocks/mock-tfplan.sentinel b/BACKUP-2024/12-Terraform-Cloud-and-Sentinel/12-01-Terraform-Cloud-and-Sentinel-Policies/Sentinel-Mocks/run-9rHCA5A7cwvRAox6-sentinel-mocks/mock-tfplan.sentinel new file mode 100644 index 00000000..7df65fb7 --- /dev/null +++ b/BACKUP-2024/12-Terraform-Cloud-and-Sentinel/12-01-Terraform-Cloud-and-Sentinel-Policies/Sentinel-Mocks/run-9rHCA5A7cwvRAox6-sentinel-mocks/mock-tfplan.sentinel @@ -0,0 +1,407 @@ +import "strings" +import "types" + +_modules = { + "root": { + "data": {}, + "path": [], + "resources": { + "aws_s3_bucket": { + "s3_bucket": { + 0: { + "applied": { + "acl": "public-read", + "bucket": "mybucket-1061", + "bucket_prefix": null, + "cors_rule": [], + "force_destroy": true, + "grant": [], + "lifecycle_rule": [], + "logging": [], + "object_lock_configuration": [], + "policy": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"PublicReadGetObject\",\n \"Effect\": \"Allow\",\n \"Principal\": \"*\",\n \"Action\": [\n \"s3:GetObject\"\n ],\n \"Resource\": [\n \"arn:aws:s3:::mybucket-1061/*\"\n ]\n }\n ]\n} \n", + "replication_configuration": [], + "server_side_encryption_configuration": [], + "tags": { + "Environment": "dev", + "Terraform": "true", + "newtag1": "tag1", + "newtag2": "tag2", + }, + "website": [ + { + "error_document": "error.html", + "index_document": "index.html", + "redirect_all_requests_to": null, + "routing_rules": null, + }, + ], + }, + "destroy": false, + "diff": { + "acceleration_status": { + "computed": true, + "new": "", + "old": "", + }, + "acl": { + "computed": false, + "new": "public-read", + "old": "", + }, + "arn": { + "computed": true, + "new": "", + "old": "", + }, + "bucket": { + "computed": false, + "new": "mybucket-1061", + "old": "", + }, + "bucket_domain_name": { + "computed": true, + "new": "", + "old": "", + }, + "bucket_prefix": { + "computed": false, + "new": "", + "old": "", + }, + "bucket_regional_domain_name": { + "computed": true, + "new": "", + "old": "", + }, + "cors_rule.#": { + "computed": false, + "new": "0", + "old": "", + }, + "force_destroy": { + "computed": false, + "new": "true", + "old": "", + }, + "grant.#": { + "computed": false, + "new": "0", + "old": "", + }, + "hosted_zone_id": { + "computed": true, + "new": "", + "old": "", + }, + "id": { + "computed": true, + "new": "", + "old": "", + }, + "lifecycle_rule.#": { + "computed": false, + "new": "0", + "old": "", + }, + "logging.#": { + "computed": false, + "new": "0", + "old": "", + }, + "object_lock_configuration.#": { + "computed": false, + "new": "0", + "old": "", + }, + "policy": { + "computed": false, + "new": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"PublicReadGetObject\",\n \"Effect\": \"Allow\",\n \"Principal\": \"*\",\n \"Action\": [\n \"s3:GetObject\"\n ],\n \"Resource\": [\n \"arn:aws:s3:::mybucket-1061/*\"\n ]\n }\n ]\n} \n", + "old": "", + }, + "region": { + "computed": true, + "new": "", + "old": "", + }, + "replication_configuration.#": { + "computed": false, + "new": "0", + "old": "", + }, + "request_payer": { + "computed": true, + "new": "", + "old": "", + }, + "server_side_encryption_configuration.#": { + "computed": false, + "new": "0", + "old": "", + }, + "tags.%": { + "computed": false, + "new": "4", + "old": "", + }, + "tags.Environment": { + "computed": false, + "new": "dev", + "old": "", + }, + "tags.Terraform": { + "computed": false, + "new": "true", + "old": "", + }, + "tags.newtag1": { + "computed": false, + "new": "tag1", + "old": "", + }, + "tags.newtag2": { + "computed": false, + "new": "tag2", + "old": "", + }, + "versioning.#": { + "computed": true, + "new": "", + "old": "", + }, + "website.#": { + "computed": false, + "new": "1", + "old": "", + }, + "website.0.%": { + "computed": false, + "new": "4", + "old": "", + }, + "website.0.error_document": { + "computed": false, + "new": "error.html", + "old": "", + }, + "website.0.index_document": { + "computed": false, + "new": "index.html", + "old": "", + }, + "website.0.redirect_all_requests_to": { + "computed": false, + "new": "", + "old": "", + }, + "website.0.routing_rules": { + "computed": false, + "new": "", + "old": "", + }, + "website_domain": { + "computed": true, + "new": "", + "old": "", + }, + "website_endpoint": { + "computed": true, + "new": "", + "old": "", + }, + }, + "requires_new": false, + }, + }, + }, + "aws_s3_bucket_object": { + "bucket": { + 0: { + "applied": { + "acl": "public-read", + "cache_control": null, + "content": "\n\nTerraform Sentinel - Demo - V1
\n\n", + "content_base64": null, + "content_disposition": null, + "content_encoding": null, + "content_language": null, + "content_type": "text/html", + "force_destroy": false, + "key": "index.html", + "metadata": null, + "object_lock_legal_hold_status": null, + "object_lock_mode": null, + "object_lock_retain_until_date": null, + "source": null, + "tags": null, + "website_redirect": null, + }, + "destroy": false, + "diff": { + "acl": { + "computed": false, + "new": "public-read", + "old": "", + }, + "bucket": { + "computed": true, + "new": "", + "old": "", + }, + "cache_control": { + "computed": false, + "new": "", + "old": "", + }, + "content": { + "computed": false, + "new": "\n\nTerraform Sentinel - Demo - V1
\n\n", + "old": "", + }, + "content_base64": { + "computed": false, + "new": "", + "old": "", + }, + "content_disposition": { + "computed": false, + "new": "", + "old": "", + }, + "content_encoding": { + "computed": false, + "new": "", + "old": "", + }, + "content_language": { + "computed": false, + "new": "", + "old": "", + }, + "content_type": { + "computed": false, + "new": "text/html", + "old": "", + }, + "etag": { + "computed": true, + "new": "", + "old": "", + }, + "force_destroy": { + "computed": false, + "new": "false", + "old": "", + }, + "id": { + "computed": true, + "new": "", + "old": "", + }, + "key": { + "computed": false, + "new": "index.html", + "old": "", + }, + "kms_key_id": { + "computed": true, + "new": "", + "old": "", + }, + "metadata": { + "computed": false, + "new": "", + "old": "", + }, + "object_lock_legal_hold_status": { + "computed": false, + "new": "", + "old": "", + }, + "object_lock_mode": { + "computed": false, + "new": "", + "old": "", + }, + "object_lock_retain_until_date": { + "computed": false, + "new": "", + "old": "", + }, + "server_side_encryption": { + "computed": true, + "new": "", + "old": "", + }, + "source": { + "computed": false, + "new": "", + "old": "", + }, + "storage_class": { + "computed": true, + "new": "", + "old": "", + }, + "tags": { + "computed": false, + "new": "", + "old": "", + }, + "version_id": { + "computed": true, + "new": "", + "old": "", + }, + "website_redirect": { + "computed": false, + "new": "", + "old": "", + }, + }, + "requires_new": false, + }, + }, + }, + }, + }, +} + +module_paths = [ + [], +] + +terraform_version = "0.14.8" + +variables = { + "aws_region": "us-east-1", + "bucket_name": "mybucket-1061", + "tags": { + "Environment": "dev", + "Terraform": "true", + "newtag1": "tag1", + "newtag2": "tag2", + }, +} + +module = func(path) { + if types.type_of(path) is not "list" { + error("expected list, got", types.type_of(path)) + } + + if length(path) < 1 { + return _modules.root + } + + addr = [] + for path as p { + append(addr, "module") + append(addr, p) + } + + return _modules[strings.join(addr, ".")] +} + +data = _modules.root.data +path = _modules.root.path +resources = _modules.root.resources diff --git a/BACKUP-2024/12-Terraform-Cloud-and-Sentinel/12-01-Terraform-Cloud-and-Sentinel-Policies/Sentinel-Mocks/run-9rHCA5A7cwvRAox6-sentinel-mocks/mock-tfrun.sentinel b/BACKUP-2024/12-Terraform-Cloud-and-Sentinel/12-01-Terraform-Cloud-and-Sentinel-Policies/Sentinel-Mocks/run-9rHCA5A7cwvRAox6-sentinel-mocks/mock-tfrun.sentinel new file mode 100644 index 00000000..12c17732 --- /dev/null +++ b/BACKUP-2024/12-Terraform-Cloud-and-Sentinel/12-01-Terraform-Cloud-and-Sentinel-Policies/Sentinel-Mocks/run-9rHCA5A7cwvRAox6-sentinel-mocks/mock-tfrun.sentinel @@ -0,0 +1,38 @@ +id = "run-9rHCA5A7cwvRAox6" +created_at = "2021-03-11T05:23:45.955Z" +message = "Queued manually using Terraform" +commit_sha = undefined +speculative = false +is_destroy = false +target_addrs = null + +variables = { + "AWS_ACCESS_KEY_ID": { + "category": "env", + "sensitive": true, + }, + "AWS_SECRET_ACCESS_KEY": { + "category": "env", + "sensitive": true, + }, +} + +organization = { + "name": "hcta-demo1", +} + +workspace = { + "auto_apply": false, + "created_at": "2021-03-11T05:17:23.298Z", + "description": null, + "id": "ws-T5Br9iTiXeGHpHmJ", + "name": "sentinel-demo1", + "vcs_repo": null, + "working_directory": "", +} + +cost_estimate = { + "delta_monthly_cost": "0.0", + "prior_monthly_cost": "0.0", + "proposed_monthly_cost": "0.0", +} diff --git a/BACKUP-2024/12-Terraform-Cloud-and-Sentinel/12-01-Terraform-Cloud-and-Sentinel-Policies/Sentinel-Mocks/run-9rHCA5A7cwvRAox6-sentinel-mocks/mock-tfstate-v2.sentinel b/BACKUP-2024/12-Terraform-Cloud-and-Sentinel/12-01-Terraform-Cloud-and-Sentinel-Policies/Sentinel-Mocks/run-9rHCA5A7cwvRAox6-sentinel-mocks/mock-tfstate-v2.sentinel new file mode 100644 index 00000000..028a4531 --- /dev/null +++ b/BACKUP-2024/12-Terraform-Cloud-and-Sentinel/12-01-Terraform-Cloud-and-Sentinel-Policies/Sentinel-Mocks/run-9rHCA5A7cwvRAox6-sentinel-mocks/mock-tfstate-v2.sentinel @@ -0,0 +1,5 @@ +terraform_version = undefined + +outputs = {} + +resources = {} diff --git a/BACKUP-2024/12-Terraform-Cloud-and-Sentinel/12-01-Terraform-Cloud-and-Sentinel-Policies/Sentinel-Mocks/run-9rHCA5A7cwvRAox6-sentinel-mocks/mock-tfstate.sentinel b/BACKUP-2024/12-Terraform-Cloud-and-Sentinel/12-01-Terraform-Cloud-and-Sentinel-Policies/Sentinel-Mocks/run-9rHCA5A7cwvRAox6-sentinel-mocks/mock-tfstate.sentinel new file mode 100644 index 00000000..d65a1714 --- /dev/null +++ b/BACKUP-2024/12-Terraform-Cloud-and-Sentinel/12-01-Terraform-Cloud-and-Sentinel-Policies/Sentinel-Mocks/run-9rHCA5A7cwvRAox6-sentinel-mocks/mock-tfstate.sentinel @@ -0,0 +1,9 @@ +// NOTE: AUTO-GENERATED OFF OF NO DATA +// +// This blank file was generated for the tfstate import off of your +// plan, but contains no data as there was no state to generate data +// off of. +// +// Any data fetched using this import will return undefined. To +// effectively use tfstate, please generate the mock data off of a +// plan with existing state. diff --git a/BACKUP-2024/12-Terraform-Cloud-and-Sentinel/12-01-Terraform-Cloud-and-Sentinel-Policies/Sentinel-Mocks/run-9rHCA5A7cwvRAox6-sentinel-mocks/sentinel.json b/BACKUP-2024/12-Terraform-Cloud-and-Sentinel/12-01-Terraform-Cloud-and-Sentinel-Policies/Sentinel-Mocks/run-9rHCA5A7cwvRAox6-sentinel-mocks/sentinel.json new file mode 100644 index 00000000..e48c65f3 --- /dev/null +++ b/BACKUP-2024/12-Terraform-Cloud-and-Sentinel/12-01-Terraform-Cloud-and-Sentinel-Policies/Sentinel-Mocks/run-9rHCA5A7cwvRAox6-sentinel-mocks/sentinel.json @@ -0,0 +1,14 @@ +{ + "mock": { + "tfconfig": "mock-tfconfig.sentinel", + "tfconfig/v1": "mock-tfconfig.sentinel", + "tfconfig/v2": "mock-tfconfig-v2.sentinel", + "tfplan": "mock-tfplan.sentinel", + "tfplan/v1": "mock-tfplan.sentinel", + "tfplan/v2": "mock-tfplan-v2.sentinel", + "tfrun": "mock-tfrun.sentinel", + "tfstate": "mock-tfstate.sentinel", + "tfstate/v1": "mock-tfstate.sentinel", + "tfstate/v2": "mock-tfstate-v2.sentinel" + } +} \ No newline at end of file diff --git a/BACKUP-2024/12-Terraform-Cloud-and-Sentinel/12-01-Terraform-Cloud-and-Sentinel-Policies/terraform-manifests-oldv1/c1-versions.tf b/BACKUP-2024/12-Terraform-Cloud-and-Sentinel/12-01-Terraform-Cloud-and-Sentinel-Policies/terraform-manifests-oldv1/c1-versions.tf new file mode 100644 index 00000000..1c52c2f4 --- /dev/null +++ b/BACKUP-2024/12-Terraform-Cloud-and-Sentinel/12-01-Terraform-Cloud-and-Sentinel-Policies/terraform-manifests-oldv1/c1-versions.tf @@ -0,0 +1,28 @@ +# Terraform Block +terraform { + required_version = "~> 0.14" # which means any version equal & above 0.14 like 0.15, 0.16 etc and < 1.xx + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 3.0" + } + } + # Update backend information as Terraform Cloud + backend "remote" { + organization = "hcta-demo1" + + workspaces { + name = "sentinel-demo1" + } + } + +} + +# Provider Block +provider "aws" { + region = var.aws_region +} +/* +Note-1: AWS Credentials Profile (profile = "default") configured on your local desktop terminal +$HOME/.aws/credentials +*/ diff --git a/BACKUP-2024/12-Terraform-Cloud-and-Sentinel/12-01-Terraform-Cloud-and-Sentinel-Policies/terraform-manifests-oldv1/c2-variables.tf b/BACKUP-2024/12-Terraform-Cloud-and-Sentinel/12-01-Terraform-Cloud-and-Sentinel-Policies/terraform-manifests-oldv1/c2-variables.tf new file mode 100644 index 00000000..d476f6d8 --- /dev/null +++ b/BACKUP-2024/12-Terraform-Cloud-and-Sentinel/12-01-Terraform-Cloud-and-Sentinel-Policies/terraform-manifests-oldv1/c2-variables.tf @@ -0,0 +1,27 @@ +# Input Variables +variable "aws_region" { + description = "Region in which AWS Resources to be created" + type = string + default = "us-east-1" +} + +# Input variable definitions + +variable "bucket_name" { + description = "Name of the S3 bucket. Must be Unique across AWS" + type = string + default = "mybucket-1061" +} + +variable "tags" { + description = "Tages to set on the bucket" + type = map(string) + default = { + Terraform = "true" + #abcdef = "true" + Environment = "dev" + newtag1 = "tag1" + newtag2 = "tag2" + } +} + diff --git a/BACKUP-2024/12-Terraform-Cloud-and-Sentinel/12-01-Terraform-Cloud-and-Sentinel-Policies/terraform-manifests-oldv1/c3-s3bucket.tf b/BACKUP-2024/12-Terraform-Cloud-and-Sentinel/12-01-Terraform-Cloud-and-Sentinel-Policies/terraform-manifests-oldv1/c3-s3bucket.tf new file mode 100644 index 00000000..547af95c --- /dev/null +++ b/BACKUP-2024/12-Terraform-Cloud-and-Sentinel/12-01-Terraform-Cloud-and-Sentinel-Policies/terraform-manifests-oldv1/c3-s3bucket.tf @@ -0,0 +1,40 @@ +# Create S3 Bucket Resource +resource "aws_s3_bucket" "s3_bucket" { + bucket = var.bucket_name + acl = "public-read" + policy = <Terraform Sentinel - Demo - V2
+ +