From 2f3c419f6aabf814a276c514cd084a624752b6f5 Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 00:06:59 -0500 Subject: [PATCH 01/38] Add Github actions - Initial version --- .github/workflows/terraform.yml | 57 +++++++++++++++++++++++++++++++++ terraform/eks-cluster.tf | 8 ++--- terraform/main.tf | 1 - terraform/terraform.tf | 8 ++--- terraform/variables.tf | 4 +-- terraform/vpc.tf | 8 ++--- 6 files changed, 71 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/terraform.yml diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml new file mode 100644 index 000000000..12d2299de --- /dev/null +++ b/.github/workflows/terraform.yml @@ -0,0 +1,57 @@ +name: "Github Actions IAC" +on: + push: + branches: + - main + - stage + paths: + - terraform/** + pull_request: + branches: + - main + paths: + - terraform/** + +env: + # CREDENTIALS for AWS deployment + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY_ID }} + BUCKET_TF_STATE: ${{ secrets.BUCKET_TF_STATE }} + AWS_REGION: us-east-1 + EKS_CLUSTER: tantech-gitops-eks + jobs: + terraform: + name: "Apply Terraform code chnages" + runs-on: ubuntu-latest + defaults: + run: + shell: bash + working-directory: ./terraform + steps: + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Setup Terraform with specified version on the runner + uses: hashicorp/setup-terraform@v2 + + - name: Terrafornm init + id: init + run: terraform init -backend-config="bucket=$BUCKET_TF_STATE" + + - name: Terraform format + id: fmt + run: terraform fmt -check + + - name: Terraform validate + id: validate + run: terraform validate + + - name: Terraform plan + id: plan + run: terraform plan -no-color -input=false -out planfile + continue-on-error: true + + - name: Terraform plan status + if: steps.plan.outcome == 'fail' + run: exit 1 + \ No newline at end of file diff --git a/terraform/eks-cluster.tf b/terraform/eks-cluster.tf index 2c4610920..3e03d8fa0 100644 --- a/terraform/eks-cluster.tf +++ b/terraform/eks-cluster.tf @@ -18,17 +18,17 @@ module "eks" { one = { name = "node-group-1" - instance_types = ["t3.small"] + instance_types = ["t2.micro"] min_size = 1 - max_size = 3 - desired_size = 2 + max_size = 2 + desired_size = 12 } two = { name = "node-group-2" - instance_types = ["t3.small"] + instance_types = ["t2.micro"] min_size = 1 max_size = 2 diff --git a/terraform/main.tf b/terraform/main.tf index 94b6fc75a..884ef5ac8 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -13,4 +13,3 @@ locals { cluster_name = var.clusterName } -## \ No newline at end of file diff --git a/terraform/terraform.tf b/terraform/terraform.tf index 67b75c673..9aed55f1c 100644 --- a/terraform/terraform.tf +++ b/terraform/terraform.tf @@ -22,17 +22,17 @@ terraform { kubernetes = { source = "hashicorp/kubernetes" - version = "~> 2.23.0" + version = "~> 2.33.0" } } backend "s3" { - bucket = "gitopsterrastate" + bucket = "tantech-gitactionstf-backend" key = "terraform.tfstate" - region = "us-east-2" + region = "us-east-1" } - required_version = "~> 1.6.3" + required_version = "~> 1.9.6" } ## ## diff --git a/terraform/variables.tf b/terraform/variables.tf index a41d982a0..eccdfc6d2 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -1,11 +1,11 @@ variable "region" { description = "AWS region" type = string - default = "us-east-2" + default = "us-east-1" } variable "clusterName" { description = "Name of the EKS cluster" type = string - default = "kitops-eks" + default = "tantech-gitops-eks" } diff --git a/terraform/vpc.tf b/terraform/vpc.tf index 5775ce1c3..064f352e9 100644 --- a/terraform/vpc.tf +++ b/terraform/vpc.tf @@ -2,13 +2,13 @@ module "vpc" { source = "terraform-aws-modules/vpc/aws" version = "5.1.2" - name = "vprofile-eks" + name = "tantech-gitops-eks-vpc" - cidr = "172.20.0.0/16" + cidr = "172.28.0.0/16" azs = slice(data.aws_availability_zones.available.names, 0, 3) - private_subnets = ["172.20.1.0/24", "172.20.2.0/24", "172.20.3.0/24"] - public_subnets = ["172.20.4.0/24", "172.20.5.0/24", "172.20.6.0/24"] + private_subnets = ["172.28.1.0/24", "172.28.2.0/24", "172.28.3.0/24"] + public_subnets = ["172.28.4.0/24", "172.28.5.0/24", "172.28.6.0/24"] enable_nat_gateway = true single_nat_gateway = true From a829c18eb9c5a1d62dc9d5ad555f340b0fdaf982 Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 00:08:24 -0500 Subject: [PATCH 02/38] Adding modified file --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index a7eba6d64..95975da4a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .terraform* DS_Store +.DS_Store From b2671c3e929bc19679039d76c32614c4d298a99f Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 00:11:02 -0500 Subject: [PATCH 03/38] Adding modified terraform workflow file --- ".github\\workflows/terraform.yml" | 57 ++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 ".github\\workflows/terraform.yml" diff --git "a/.github\\workflows/terraform.yml" "b/.github\\workflows/terraform.yml" new file mode 100644 index 000000000..175be26e2 --- /dev/null +++ "b/.github\\workflows/terraform.yml" @@ -0,0 +1,57 @@ +name: "Github Actions IAC" +on: + push: + branches: + - main + - stage + paths: + - terraform/** + pull_request: + branches: + - main + paths: + - terraform/** + +env: + # CREDENTIALS for AWS deployment + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY_ID }} + BUCKET_TF_STATE: ${{ secrets.BUCKET_TF_STATE }} + AWS_REGION: us-east-1 + EKS_CLUSTER: tantech-gitops-eks +jobs: + terraform: + name: "Apply Terraform code chnages" + runs-on: ubuntu-latest + defaults: + run: + shell: bash + working-directory: ./terraform + steps: + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Setup Terraform with specified version on the runner + uses: hashicorp/setup-terraform@v2 + + - name: Terrafornm init + id: init + run: terraform init -backend-config="bucket=$BUCKET_TF_STATE" + + - name: Terraform format + id: fmt + run: terraform fmt -check + + - name: Terraform validate + id: validate + run: terraform validate + + - name: Terraform plan + id: plan + run: terraform plan -no-color -input=false -out planfile + continue-on-error: true + + - name: Terraform plan status + if: steps.plan.outcome == 'fail' + run: exit 1 + \ No newline at end of file From 7c81f5848007fc5818176577451920440073a253 Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 00:13:05 -0500 Subject: [PATCH 04/38] Add ## in variables.tf to trigger build --- terraform/variables.tf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/terraform/variables.tf b/terraform/variables.tf index eccdfc6d2..9afec94c1 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -9,3 +9,5 @@ variable "clusterName" { type = string default = "tantech-gitops-eks" } + +## From 75bf183c1fda67cbb6d704df16169c9adbfe1220 Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 00:16:41 -0500 Subject: [PATCH 05/38] Adding modified terraform workflow file --- ".github\\workflows/terraform.yml" | 58 +++++++++++++++--------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git "a/.github\\workflows/terraform.yml" "b/.github\\workflows/terraform.yml" index 175be26e2..482fe9116 100644 --- "a/.github\\workflows/terraform.yml" +++ "b/.github\\workflows/terraform.yml" @@ -20,38 +20,38 @@ env: AWS_REGION: us-east-1 EKS_CLUSTER: tantech-gitops-eks jobs: - terraform: - name: "Apply Terraform code chnages" - runs-on: ubuntu-latest - defaults: - run: - shell: bash - working-directory: ./terraform - steps: - - name: Checkout source code - uses: actions/checkout@v4 + terraform: + name: "Apply Terraform code chnages" + runs-on: ubuntu-latest + defaults: + run: + shell: bash + working-directory: ./terraform + steps: + - name: Checkout source code + uses: actions/checkout@v4 - - name: Setup Terraform with specified version on the runner - uses: hashicorp/setup-terraform@v2 + - name: Setup Terraform with specified version on the runner + uses: hashicorp/setup-terraform@v2 - - name: Terrafornm init - id: init - run: terraform init -backend-config="bucket=$BUCKET_TF_STATE" - - - name: Terraform format - id: fmt - run: terraform fmt -check + - name: Terrafornm init + id: init + run: terraform init -backend-config="bucket=$BUCKET_TF_STATE" + + - name: Terraform format + id: fmt + run: terraform fmt -check - - name: Terraform validate - id: validate - run: terraform validate + - name: Terraform validate + id: validate + run: terraform validate - - name: Terraform plan - id: plan - run: terraform plan -no-color -input=false -out planfile - continue-on-error: true + - name: Terraform plan + id: plan + run: terraform plan -no-color -input=false -out planfile + continue-on-error: true - - name: Terraform plan status - if: steps.plan.outcome == 'fail' - run: exit 1 + - name: Terraform plan status + if: steps.plan.outcome == 'fail' + run: exit 1 \ No newline at end of file From e6c210f3190ecd14113e7288d385819c380abe84 Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 00:19:27 -0500 Subject: [PATCH 06/38] Adding modified terraform workflow file --- ".github\\workflows/terraform.yml" | 58 +++++++++++++++--------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git "a/.github\\workflows/terraform.yml" "b/.github\\workflows/terraform.yml" index 482fe9116..175be26e2 100644 --- "a/.github\\workflows/terraform.yml" +++ "b/.github\\workflows/terraform.yml" @@ -20,38 +20,38 @@ env: AWS_REGION: us-east-1 EKS_CLUSTER: tantech-gitops-eks jobs: - terraform: - name: "Apply Terraform code chnages" - runs-on: ubuntu-latest - defaults: - run: - shell: bash - working-directory: ./terraform - steps: - - name: Checkout source code - uses: actions/checkout@v4 + terraform: + name: "Apply Terraform code chnages" + runs-on: ubuntu-latest + defaults: + run: + shell: bash + working-directory: ./terraform + steps: + - name: Checkout source code + uses: actions/checkout@v4 - - name: Setup Terraform with specified version on the runner - uses: hashicorp/setup-terraform@v2 + - name: Setup Terraform with specified version on the runner + uses: hashicorp/setup-terraform@v2 - - name: Terrafornm init - id: init - run: terraform init -backend-config="bucket=$BUCKET_TF_STATE" - - - name: Terraform format - id: fmt - run: terraform fmt -check + - name: Terrafornm init + id: init + run: terraform init -backend-config="bucket=$BUCKET_TF_STATE" + + - name: Terraform format + id: fmt + run: terraform fmt -check - - name: Terraform validate - id: validate - run: terraform validate + - name: Terraform validate + id: validate + run: terraform validate - - name: Terraform plan - id: plan - run: terraform plan -no-color -input=false -out planfile - continue-on-error: true + - name: Terraform plan + id: plan + run: terraform plan -no-color -input=false -out planfile + continue-on-error: true - - name: Terraform plan status - if: steps.plan.outcome == 'fail' - run: exit 1 + - name: Terraform plan status + if: steps.plan.outcome == 'fail' + run: exit 1 \ No newline at end of file From 62d1cdb3f5ae212d5d7a671fc8453ae65aace38b Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 00:19:59 -0500 Subject: [PATCH 07/38] Remove ## in variables.tf to trigger build --- terraform/variables.tf | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/terraform/variables.tf b/terraform/variables.tf index 9afec94c1..a7e525f78 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -8,6 +8,4 @@ variable "clusterName" { description = "Name of the EKS cluster" type = string default = "tantech-gitops-eks" -} - -## +} \ No newline at end of file From 445059929d48dd57c5852be2cbf8a44ee02b2f0c Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 00:23:08 -0500 Subject: [PATCH 08/38] Adding modified terraform workflow file --- ".github\\workflows/terraform.yml" | 36 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git "a/.github\\workflows/terraform.yml" "b/.github\\workflows/terraform.yml" index 175be26e2..44f53f997 100644 --- "a/.github\\workflows/terraform.yml" +++ "b/.github\\workflows/terraform.yml" @@ -31,27 +31,27 @@ jobs: - name: Checkout source code uses: actions/checkout@v4 - - name: Setup Terraform with specified version on the runner - uses: hashicorp/setup-terraform@v2 + # - name: Setup Terraform with specified version on the runner + # uses: hashicorp/setup-terraform@v2 - - name: Terrafornm init - id: init - run: terraform init -backend-config="bucket=$BUCKET_TF_STATE" + # - name: Terrafornm init + # id: init + # run: terraform init -backend-config="bucket=$BUCKET_TF_STATE" - - name: Terraform format - id: fmt - run: terraform fmt -check + # - name: Terraform format + # id: fmt + # run: terraform fmt -check - - name: Terraform validate - id: validate - run: terraform validate + # - name: Terraform validate + # id: validate + # run: terraform validate - - name: Terraform plan - id: plan - run: terraform plan -no-color -input=false -out planfile - continue-on-error: true + # - name: Terraform plan + # id: plan + # run: terraform plan -no-color -input=false -out planfile + # continue-on-error: true - - name: Terraform plan status - if: steps.plan.outcome == 'fail' - run: exit 1 + # - name: Terraform plan status + # if: steps.plan.outcome == 'fail' + # run: exit 1 \ No newline at end of file From f1bd0987269b15c908fefa7fc4b0b0b1e05ff704 Mon Sep 17 00:00:00 2001 From: sankalp-it <31386876+sankalp-it@users.noreply.github.com> Date: Mon, 21 Oct 2024 00:33:28 -0500 Subject: [PATCH 09/38] Delete .github/workflows directory Unwanted --- .github/workflows/terraform.yml | 57 --------------------------------- 1 file changed, 57 deletions(-) delete mode 100644 .github/workflows/terraform.yml diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml deleted file mode 100644 index 12d2299de..000000000 --- a/.github/workflows/terraform.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: "Github Actions IAC" -on: - push: - branches: - - main - - stage - paths: - - terraform/** - pull_request: - branches: - - main - paths: - - terraform/** - -env: - # CREDENTIALS for AWS deployment - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY_ID }} - BUCKET_TF_STATE: ${{ secrets.BUCKET_TF_STATE }} - AWS_REGION: us-east-1 - EKS_CLUSTER: tantech-gitops-eks - jobs: - terraform: - name: "Apply Terraform code chnages" - runs-on: ubuntu-latest - defaults: - run: - shell: bash - working-directory: ./terraform - steps: - - name: Checkout source code - uses: actions/checkout@v4 - - - name: Setup Terraform with specified version on the runner - uses: hashicorp/setup-terraform@v2 - - - name: Terrafornm init - id: init - run: terraform init -backend-config="bucket=$BUCKET_TF_STATE" - - - name: Terraform format - id: fmt - run: terraform fmt -check - - - name: Terraform validate - id: validate - run: terraform validate - - - name: Terraform plan - id: plan - run: terraform plan -no-color -input=false -out planfile - continue-on-error: true - - - name: Terraform plan status - if: steps.plan.outcome == 'fail' - run: exit 1 - \ No newline at end of file From 410a013e06b83bc6f60e76906a1d1271b0271b14 Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 00:34:26 -0500 Subject: [PATCH 10/38] Modified file --- terraform/variables.tf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/terraform/variables.tf b/terraform/variables.tf index a7e525f78..ad08bbbed 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -8,4 +8,6 @@ variable "clusterName" { description = "Name of the EKS cluster" type = string default = "tantech-gitops-eks" -} \ No newline at end of file +} + +## \ No newline at end of file From 963e71c181fa05104a3fe795b3f1590317533e56 Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 00:38:26 -0500 Subject: [PATCH 11/38] Add modified file --- terraform/variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/variables.tf b/terraform/variables.tf index ad08bbbed..5b4d6e3df 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -10,4 +10,4 @@ variable "clusterName" { default = "tantech-gitops-eks" } -## \ No newline at end of file +### \ No newline at end of file From 46aef189843590d26fe6a9b681f19a5a65f551bc Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 00:41:36 -0500 Subject: [PATCH 12/38] Add modified file --- ".github\\workflows/terraform.yml" | 36 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git "a/.github\\workflows/terraform.yml" "b/.github\\workflows/terraform.yml" index 44f53f997..175be26e2 100644 --- "a/.github\\workflows/terraform.yml" +++ "b/.github\\workflows/terraform.yml" @@ -31,27 +31,27 @@ jobs: - name: Checkout source code uses: actions/checkout@v4 - # - name: Setup Terraform with specified version on the runner - # uses: hashicorp/setup-terraform@v2 + - name: Setup Terraform with specified version on the runner + uses: hashicorp/setup-terraform@v2 - # - name: Terrafornm init - # id: init - # run: terraform init -backend-config="bucket=$BUCKET_TF_STATE" + - name: Terrafornm init + id: init + run: terraform init -backend-config="bucket=$BUCKET_TF_STATE" - # - name: Terraform format - # id: fmt - # run: terraform fmt -check + - name: Terraform format + id: fmt + run: terraform fmt -check - # - name: Terraform validate - # id: validate - # run: terraform validate + - name: Terraform validate + id: validate + run: terraform validate - # - name: Terraform plan - # id: plan - # run: terraform plan -no-color -input=false -out planfile - # continue-on-error: true + - name: Terraform plan + id: plan + run: terraform plan -no-color -input=false -out planfile + continue-on-error: true - # - name: Terraform plan status - # if: steps.plan.outcome == 'fail' - # run: exit 1 + - name: Terraform plan status + if: steps.plan.outcome == 'fail' + run: exit 1 \ No newline at end of file From b47152f1612ae391fb5c6278c0e66645938116b4 Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 00:45:00 -0500 Subject: [PATCH 13/38] deleted: ".github\\workflows/terraform.yml" --- ".github\\workflows/terraform.yml" | 57 ------------------------------ 1 file changed, 57 deletions(-) delete mode 100644 ".github\\workflows/terraform.yml" diff --git "a/.github\\workflows/terraform.yml" "b/.github\\workflows/terraform.yml" deleted file mode 100644 index 175be26e2..000000000 --- "a/.github\\workflows/terraform.yml" +++ /dev/null @@ -1,57 +0,0 @@ -name: "Github Actions IAC" -on: - push: - branches: - - main - - stage - paths: - - terraform/** - pull_request: - branches: - - main - paths: - - terraform/** - -env: - # CREDENTIALS for AWS deployment - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY_ID }} - BUCKET_TF_STATE: ${{ secrets.BUCKET_TF_STATE }} - AWS_REGION: us-east-1 - EKS_CLUSTER: tantech-gitops-eks -jobs: - terraform: - name: "Apply Terraform code chnages" - runs-on: ubuntu-latest - defaults: - run: - shell: bash - working-directory: ./terraform - steps: - - name: Checkout source code - uses: actions/checkout@v4 - - - name: Setup Terraform with specified version on the runner - uses: hashicorp/setup-terraform@v2 - - - name: Terrafornm init - id: init - run: terraform init -backend-config="bucket=$BUCKET_TF_STATE" - - - name: Terraform format - id: fmt - run: terraform fmt -check - - - name: Terraform validate - id: validate - run: terraform validate - - - name: Terraform plan - id: plan - run: terraform plan -no-color -input=false -out planfile - continue-on-error: true - - - name: Terraform plan status - if: steps.plan.outcome == 'fail' - run: exit 1 - \ No newline at end of file From d0eb2d2016b109647a66eb35746941dfb15ac441 Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 01:02:06 -0500 Subject: [PATCH 14/38] Add terraform.yml file --- .github/workflows/terraform.yml | 57 +++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/terraform.yml diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml new file mode 100644 index 000000000..175be26e2 --- /dev/null +++ b/.github/workflows/terraform.yml @@ -0,0 +1,57 @@ +name: "Github Actions IAC" +on: + push: + branches: + - main + - stage + paths: + - terraform/** + pull_request: + branches: + - main + paths: + - terraform/** + +env: + # CREDENTIALS for AWS deployment + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY_ID }} + BUCKET_TF_STATE: ${{ secrets.BUCKET_TF_STATE }} + AWS_REGION: us-east-1 + EKS_CLUSTER: tantech-gitops-eks +jobs: + terraform: + name: "Apply Terraform code chnages" + runs-on: ubuntu-latest + defaults: + run: + shell: bash + working-directory: ./terraform + steps: + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Setup Terraform with specified version on the runner + uses: hashicorp/setup-terraform@v2 + + - name: Terrafornm init + id: init + run: terraform init -backend-config="bucket=$BUCKET_TF_STATE" + + - name: Terraform format + id: fmt + run: terraform fmt -check + + - name: Terraform validate + id: validate + run: terraform validate + + - name: Terraform plan + id: plan + run: terraform plan -no-color -input=false -out planfile + continue-on-error: true + + - name: Terraform plan status + if: steps.plan.outcome == 'fail' + run: exit 1 + \ No newline at end of file From 04cff834013355c3e5adb617d3ec322223e232ec Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 01:04:58 -0500 Subject: [PATCH 15/38] Remove file --- .github/workflows/terraform.yml | 57 --------------------------------- 1 file changed, 57 deletions(-) delete mode 100644 .github/workflows/terraform.yml diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml deleted file mode 100644 index 175be26e2..000000000 --- a/.github/workflows/terraform.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: "Github Actions IAC" -on: - push: - branches: - - main - - stage - paths: - - terraform/** - pull_request: - branches: - - main - paths: - - terraform/** - -env: - # CREDENTIALS for AWS deployment - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY_ID }} - BUCKET_TF_STATE: ${{ secrets.BUCKET_TF_STATE }} - AWS_REGION: us-east-1 - EKS_CLUSTER: tantech-gitops-eks -jobs: - terraform: - name: "Apply Terraform code chnages" - runs-on: ubuntu-latest - defaults: - run: - shell: bash - working-directory: ./terraform - steps: - - name: Checkout source code - uses: actions/checkout@v4 - - - name: Setup Terraform with specified version on the runner - uses: hashicorp/setup-terraform@v2 - - - name: Terrafornm init - id: init - run: terraform init -backend-config="bucket=$BUCKET_TF_STATE" - - - name: Terraform format - id: fmt - run: terraform fmt -check - - - name: Terraform validate - id: validate - run: terraform validate - - - name: Terraform plan - id: plan - run: terraform plan -no-color -input=false -out planfile - continue-on-error: true - - - name: Terraform plan status - if: steps.plan.outcome == 'fail' - run: exit 1 - \ No newline at end of file From 421e5cab6807fce20523e520c3ad205583a6a606 Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 01:09:44 -0500 Subject: [PATCH 16/38] Correct the files --- ".github\\workflows/terraform.yml" | 57 ++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 ".github\\workflows/terraform.yml" diff --git "a/.github\\workflows/terraform.yml" "b/.github\\workflows/terraform.yml" new file mode 100644 index 000000000..175be26e2 --- /dev/null +++ "b/.github\\workflows/terraform.yml" @@ -0,0 +1,57 @@ +name: "Github Actions IAC" +on: + push: + branches: + - main + - stage + paths: + - terraform/** + pull_request: + branches: + - main + paths: + - terraform/** + +env: + # CREDENTIALS for AWS deployment + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY_ID }} + BUCKET_TF_STATE: ${{ secrets.BUCKET_TF_STATE }} + AWS_REGION: us-east-1 + EKS_CLUSTER: tantech-gitops-eks +jobs: + terraform: + name: "Apply Terraform code chnages" + runs-on: ubuntu-latest + defaults: + run: + shell: bash + working-directory: ./terraform + steps: + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Setup Terraform with specified version on the runner + uses: hashicorp/setup-terraform@v2 + + - name: Terrafornm init + id: init + run: terraform init -backend-config="bucket=$BUCKET_TF_STATE" + + - name: Terraform format + id: fmt + run: terraform fmt -check + + - name: Terraform validate + id: validate + run: terraform validate + + - name: Terraform plan + id: plan + run: terraform plan -no-color -input=false -out planfile + continue-on-error: true + + - name: Terraform plan status + if: steps.plan.outcome == 'fail' + run: exit 1 + \ No newline at end of file From 99f55dc64cbe79bbc1f250371d943791428a5b59 Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 01:11:40 -0500 Subject: [PATCH 17/38] Add comment to file --- terraform/variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/variables.tf b/terraform/variables.tf index 5b4d6e3df..ad08bbbed 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -10,4 +10,4 @@ variable "clusterName" { default = "tantech-gitops-eks" } -### \ No newline at end of file +## \ No newline at end of file From 0f7635a634eca28b97ef606284a7d6b9cec348b5 Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 08:37:06 -0500 Subject: [PATCH 18/38] Added comment --- terraform/variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/variables.tf b/terraform/variables.tf index ad08bbbed..5b4d6e3df 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -10,4 +10,4 @@ variable "clusterName" { default = "tantech-gitops-eks" } -## \ No newline at end of file +### \ No newline at end of file From 08a5976ecfc2840397b8664ce3faf87be8f92388 Mon Sep 17 00:00:00 2001 From: sankalp-it <31386876+sankalp-it@users.noreply.github.com> Date: Mon, 21 Oct 2024 08:40:29 -0500 Subject: [PATCH 19/38] Delete .github\workflows directory --- ".github\\workflows/terraform.yml" | 57 ------------------------------ 1 file changed, 57 deletions(-) delete mode 100644 ".github\\workflows/terraform.yml" diff --git "a/.github\\workflows/terraform.yml" "b/.github\\workflows/terraform.yml" deleted file mode 100644 index 175be26e2..000000000 --- "a/.github\\workflows/terraform.yml" +++ /dev/null @@ -1,57 +0,0 @@ -name: "Github Actions IAC" -on: - push: - branches: - - main - - stage - paths: - - terraform/** - pull_request: - branches: - - main - paths: - - terraform/** - -env: - # CREDENTIALS for AWS deployment - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY_ID }} - BUCKET_TF_STATE: ${{ secrets.BUCKET_TF_STATE }} - AWS_REGION: us-east-1 - EKS_CLUSTER: tantech-gitops-eks -jobs: - terraform: - name: "Apply Terraform code chnages" - runs-on: ubuntu-latest - defaults: - run: - shell: bash - working-directory: ./terraform - steps: - - name: Checkout source code - uses: actions/checkout@v4 - - - name: Setup Terraform with specified version on the runner - uses: hashicorp/setup-terraform@v2 - - - name: Terrafornm init - id: init - run: terraform init -backend-config="bucket=$BUCKET_TF_STATE" - - - name: Terraform format - id: fmt - run: terraform fmt -check - - - name: Terraform validate - id: validate - run: terraform validate - - - name: Terraform plan - id: plan - run: terraform plan -no-color -input=false -out planfile - continue-on-error: true - - - name: Terraform plan status - if: steps.plan.outcome == 'fail' - run: exit 1 - \ No newline at end of file From c900ba62799970e0d6d21f1bc2e80ab57fef8328 Mon Sep 17 00:00:00 2001 From: sankalp-it <31386876+sankalp-it@users.noreply.github.com> Date: Mon, 21 Oct 2024 08:42:26 -0500 Subject: [PATCH 20/38] Create terraform.yml --- .github/workflows/terraform.yml | 57 +++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/terraform.yml diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml new file mode 100644 index 000000000..9be8997b7 --- /dev/null +++ b/.github/workflows/terraform.yml @@ -0,0 +1,57 @@ +name: "Github Actions IAC" +on: + push: + branches: + - main + - stage + paths: + - terraform/** + pull_request: + branches: + - main + paths: + - terraform/** + +env: + # CREDENTIALS for AWS deployment + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY_ID }} + BUCKET_TF_STATE: ${{ secrets.BUCKET_TF_STATE }} + AWS_REGION: us-east-1 + EKS_CLUSTER: tantech-gitops-eks +jobs: + terraform: + name: "Apply Terraform code chnages" + runs-on: ubuntu-latest + defaults: + run: + shell: bash + working-directory: ./terraform + steps: + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Setup Terraform with specified version on the runner + uses: hashicorp/setup-terraform@v2 + + - name: Terrafornm init + id: init + run: terraform init -backend-config="bucket=$BUCKET_TF_STATE" + + - name: Terraform format + id: fmt + run: terraform fmt -check + + - name: Terraform validate + id: validate + run: terraform validate + + - name: Terraform plan + id: plan + run: terraform plan -no-color -input=false -out planfile + continue-on-error: true + + - name: Terraform plan status + if: steps.plan.outcome == 'fail' + run: exit 1 + From 76928a1540db715afd91d109a78f269ec3aa2ac6 Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 08:43:54 -0500 Subject: [PATCH 21/38] Added comment --- terraform/variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/variables.tf b/terraform/variables.tf index 5b4d6e3df..ad08bbbed 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -10,4 +10,4 @@ variable "clusterName" { default = "tantech-gitops-eks" } -### \ No newline at end of file +## \ No newline at end of file From 9c02f1c3a4ec42e9545d254472c0b1544db9d76c Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 09:36:48 -0500 Subject: [PATCH 22/38] Add the AWS Credentials configuration step --- .github/workflows/terraform.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 9be8997b7..8a04f11a0 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -14,8 +14,8 @@ on: env: # CREDENTIALS for AWS deployment - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY_ID }} + #AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + #AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY_ID }} BUCKET_TF_STATE: ${{ secrets.BUCKET_TF_STATE }} AWS_REGION: us-east-1 EKS_CLUSTER: tantech-gitops-eks @@ -30,6 +30,13 @@ jobs: steps: - name: Checkout source code uses: actions/checkout@v4 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 - name: Setup Terraform with specified version on the runner uses: hashicorp/setup-terraform@v2 From 40e99508e16b91b04c8d6ab7490af2b23436523b Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 09:37:23 -0500 Subject: [PATCH 23/38] Added comment --- terraform/variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/variables.tf b/terraform/variables.tf index ad08bbbed..5b4d6e3df 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -10,4 +10,4 @@ variable "clusterName" { default = "tantech-gitops-eks" } -## \ No newline at end of file +### \ No newline at end of file From 6d7025429c62e912a9231e5d4a4be16a91eb4762 Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 10:26:39 -0500 Subject: [PATCH 24/38] Add infracost configuration --- .github/workflows/terraform.yml | 9 ++++++++- terraform/variables.tf | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 8a04f11a0..df601f4b2 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -30,13 +30,20 @@ jobs: steps: - name: Checkout source code uses: actions/checkout@v4 - + - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v2 with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: us-east-1 + + - name: Setup Infracost + uses: infracost/actions/setup@v3 + # See https://github.com/infracost/actions/tree/master/setup for other inputs + # If you can't use this action, use Docker image infracost/infracost:ci-0.10 + with: + api-key: ${{ secrets.INFRACOST_API_KEY }} - name: Setup Terraform with specified version on the runner uses: hashicorp/setup-terraform@v2 diff --git a/terraform/variables.tf b/terraform/variables.tf index 5b4d6e3df..ad08bbbed 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -10,4 +10,4 @@ variable "clusterName" { default = "tantech-gitops-eks" } -### \ No newline at end of file +## \ No newline at end of file From 631651fdcd1d6cf23675ebe4fa7115b6cc708055 Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 10:38:06 -0500 Subject: [PATCH 25/38] Add infracost cost estimation --- .github/workflows/terraform.yml | 17 ++++++++++++++++- terraform/variables.tf | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index df601f4b2..57d021721 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -28,6 +28,14 @@ jobs: shell: bash working-directory: ./terraform steps: + - name: Set GIT REPO env variable + run: | + echo "REPO_NAME=${GITHUB_REPOSITORY#$GITHUB_REPOSITORY_OWNER/}" >> $GITHUB_ENV + + - name: ECHO Repo name + run: | + echo $REPO_NAME + - name: Checkout source code uses: actions/checkout@v4 @@ -37,7 +45,7 @@ jobs: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: us-east-1 - + - name: Setup Infracost uses: infracost/actions/setup@v3 # See https://github.com/infracost/actions/tree/master/setup for other inputs @@ -45,6 +53,13 @@ jobs: with: api-key: ${{ secrets.INFRACOST_API_KEY }} + # Generate Infracost JSON file as the baseline. + - name: Generate Infracost cost estimate baseline + run: | + infracost breakdown --path=./terraform \ + --format=json \ + --out-file=/tmp/infracost-base.json + - name: Setup Terraform with specified version on the runner uses: hashicorp/setup-terraform@v2 diff --git a/terraform/variables.tf b/terraform/variables.tf index ad08bbbed..5b4d6e3df 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -10,4 +10,4 @@ variable "clusterName" { default = "tantech-gitops-eks" } -## \ No newline at end of file +### \ No newline at end of file From b69c19f0ad93c2cdbb23be6da8c9ead4ff645087 Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 10:41:10 -0500 Subject: [PATCH 26/38] Add infracost cost estimation --- .github/workflows/terraform.yml | 7 +++---- terraform/variables.tf | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 57d021721..a39255198 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -28,6 +28,9 @@ jobs: shell: bash working-directory: ./terraform steps: + - name: Checkout source code + uses: actions/checkout@v4 + - name: Set GIT REPO env variable run: | echo "REPO_NAME=${GITHUB_REPOSITORY#$GITHUB_REPOSITORY_OWNER/}" >> $GITHUB_ENV @@ -35,10 +38,6 @@ jobs: - name: ECHO Repo name run: | echo $REPO_NAME - - - name: Checkout source code - uses: actions/checkout@v4 - - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v2 with: diff --git a/terraform/variables.tf b/terraform/variables.tf index 5b4d6e3df..ad08bbbed 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -10,4 +10,4 @@ variable "clusterName" { default = "tantech-gitops-eks" } -### \ No newline at end of file +## \ No newline at end of file From acfd1185ae7383bb0bbeb267f4e8edcad256650a Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 10:45:37 -0500 Subject: [PATCH 27/38] Add infracost cost estimation --- .github/workflows/terraform.yml | 18 +++++++++++++++++- terraform/variables.tf | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index a39255198..5c91f9b8a 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -30,7 +30,7 @@ jobs: steps: - name: Checkout source code uses: actions/checkout@v4 - + - name: Set GIT REPO env variable run: | echo "REPO_NAME=${GITHUB_REPOSITORY#$GITHUB_REPOSITORY_OWNER/}" >> $GITHUB_ENV @@ -59,6 +59,7 @@ jobs: --format=json \ --out-file=/tmp/infracost-base.json + - name: Setup Terraform with specified version on the runner uses: hashicorp/setup-terraform@v2 @@ -79,6 +80,21 @@ jobs: run: terraform plan -no-color -input=false -out planfile continue-on-error: true + # Posts a comment to the PR using the 'update' behavior. + # This creates a single comment and updates it. The "quietest" option. + # The other valid behaviors are: + # delete-and-new - Delete previous comments and create a new one. + # hide-and-new - Minimize previous comments and create a new one. + # new - Create a new cost estimate comment on every push. + # See https://www.infracost.io/docs/features/cli_commands/#comment-on-pull-requests for other options. + - name: Post Infracost comment + run: | + infracost comment github --path=/tmp/infracost.json \ + --repo=$GITHUB_REPOSITORY \ + --github-token=${{ github.token }} \ + --pull-request=${{ github.event.pull_request.number }} \ + --behavior=update + - name: Terraform plan status if: steps.plan.outcome == 'fail' run: exit 1 diff --git a/terraform/variables.tf b/terraform/variables.tf index ad08bbbed..5b4d6e3df 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -10,4 +10,4 @@ variable "clusterName" { default = "tantech-gitops-eks" } -## \ No newline at end of file +### \ No newline at end of file From 0438163fc15e56d5b4000647c50d2243626cd981 Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 10:48:16 -0500 Subject: [PATCH 28/38] Add infracost cost estimation --- .github/workflows/terraform.yml | 12 +++++++++--- terraform/variables.tf | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 5c91f9b8a..1ed648743 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -87,14 +87,20 @@ jobs: # hide-and-new - Minimize previous comments and create a new one. # new - Create a new cost estimate comment on every push. # See https://www.infracost.io/docs/features/cli_commands/#comment-on-pull-requests for other options. + # - name: Post Infracost comment + # run: | + # infracost comment github --path=/tmp/infracost.json \ + # --repo=$GITHUB_REPOSITORY \ + # --github-token=${{ github.token }} \ + # --pull-request=${{ github.event.pull_request.number }} \ + # --behavior=update - name: Post Infracost comment run: | infracost comment github --path=/tmp/infracost.json \ --repo=$GITHUB_REPOSITORY \ --github-token=${{ github.token }} \ - --pull-request=${{ github.event.pull_request.number }} \ - --behavior=update - + --commit \ + --behavior=update - name: Terraform plan status if: steps.plan.outcome == 'fail' run: exit 1 diff --git a/terraform/variables.tf b/terraform/variables.tf index 5b4d6e3df..ad08bbbed 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -10,4 +10,4 @@ variable "clusterName" { default = "tantech-gitops-eks" } -### \ No newline at end of file +## \ No newline at end of file From 97fa6356c6e2274f7d54b13c0c6bbef4bd1f14c1 Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 10:50:39 -0500 Subject: [PATCH 29/38] Add infracost cost estimation --- .github/workflows/terraform.yml | 2 +- terraform/variables.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 1ed648743..7fc8e9234 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -96,7 +96,7 @@ jobs: # --behavior=update - name: Post Infracost comment run: | - infracost comment github --path=/tmp/infracost.json \ + infracost comment github --path=/tmp/infracost-base.json \ --repo=$GITHUB_REPOSITORY \ --github-token=${{ github.token }} \ --commit \ diff --git a/terraform/variables.tf b/terraform/variables.tf index ad08bbbed..35e287e2a 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -10,4 +10,4 @@ variable "clusterName" { default = "tantech-gitops-eks" } -## \ No newline at end of file +##@ \ No newline at end of file From 26ad80983f97b384c6ab15208e5496360a76a4a1 Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 10:57:49 -0500 Subject: [PATCH 30/38] Add infracost cost estimation --- .github/workflows/terraform.yml | 4 +++- terraform/variables.tf | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 7fc8e9234..6b7d2b486 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -34,6 +34,8 @@ jobs: - name: Set GIT REPO env variable run: | echo "REPO_NAME=${GITHUB_REPOSITORY#$GITHUB_REPOSITORY_OWNER/}" >> $GITHUB_ENV + echo "sha_short=$(git rev-parse --short "$GITHUB_SHA")" >> "$GITHUB_ENV" + echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> "$GITHUB_ENV" - name: ECHO Repo name run: | @@ -99,7 +101,7 @@ jobs: infracost comment github --path=/tmp/infracost-base.json \ --repo=$GITHUB_REPOSITORY \ --github-token=${{ github.token }} \ - --commit \ + --commit=$GITHUB_SHA \ --behavior=update - name: Terraform plan status if: steps.plan.outcome == 'fail' diff --git a/terraform/variables.tf b/terraform/variables.tf index 35e287e2a..ad08bbbed 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -10,4 +10,4 @@ variable "clusterName" { default = "tantech-gitops-eks" } -##@ \ No newline at end of file +## \ No newline at end of file From b5e7e3243c302c4e1383f39d7b81d5f153cc2582 Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 11:01:13 -0500 Subject: [PATCH 31/38] Add infracost cost estimation --- .github/workflows/terraform.yml | 14 ++++++-------- terraform/variables.tf | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 6b7d2b486..df2aa568f 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -54,14 +54,6 @@ jobs: with: api-key: ${{ secrets.INFRACOST_API_KEY }} - # Generate Infracost JSON file as the baseline. - - name: Generate Infracost cost estimate baseline - run: | - infracost breakdown --path=./terraform \ - --format=json \ - --out-file=/tmp/infracost-base.json - - - name: Setup Terraform with specified version on the runner uses: hashicorp/setup-terraform@v2 @@ -82,6 +74,12 @@ jobs: run: terraform plan -no-color -input=false -out planfile continue-on-error: true + # Generate Infracost JSON file as the baseline. + - name: Generate Infracost cost estimate baseline + run: | + infracost breakdown --path=./terraform \ + --format=json \ + --out-file=/tmp/infracost-base.json # Posts a comment to the PR using the 'update' behavior. # This creates a single comment and updates it. The "quietest" option. # The other valid behaviors are: diff --git a/terraform/variables.tf b/terraform/variables.tf index ad08bbbed..5b4d6e3df 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -10,4 +10,4 @@ variable "clusterName" { default = "tantech-gitops-eks" } -## \ No newline at end of file +### \ No newline at end of file From 294f2a3b447b26a611625244a9f3f267cf86ed08 Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 11:22:22 -0500 Subject: [PATCH 32/38] Add infracost cost estimation --- .github/workflows/terraform.yml | 2 +- terraform/variables.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index df2aa568f..1fef7ab11 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -77,7 +77,7 @@ jobs: # Generate Infracost JSON file as the baseline. - name: Generate Infracost cost estimate baseline run: | - infracost breakdown --path=./terraform \ + infracost breakdown --path=. \ --format=json \ --out-file=/tmp/infracost-base.json # Posts a comment to the PR using the 'update' behavior. diff --git a/terraform/variables.tf b/terraform/variables.tf index 5b4d6e3df..ad08bbbed 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -10,4 +10,4 @@ variable "clusterName" { default = "tantech-gitops-eks" } -### \ No newline at end of file +## \ No newline at end of file From be8ece64e245ab525bb4c24e6c55fb49904ad2cd Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 12:06:03 -0500 Subject: [PATCH 33/38] Add infracost cost estimation --- .github/workflows/terraform.yml | 8 ++++++++ terraform/variables.tf | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 1fef7ab11..2f06e629a 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -19,6 +19,7 @@ env: BUCKET_TF_STATE: ${{ secrets.BUCKET_TF_STATE }} AWS_REGION: us-east-1 EKS_CLUSTER: tantech-gitops-eks + TF_PLANS_DIR: tfplans/gitops jobs: terraform: name: "Apply Terraform code chnages" @@ -74,6 +75,13 @@ jobs: run: terraform plan -no-color -input=false -out planfile continue-on-error: true + - name: Print Workspace folder tree + uses: jaywcjlove/github-action-folder-tree@main + with: + exclude: "node_modules|dist|.git|.husky" + path: ./ + depth: 3 + # Generate Infracost JSON file as the baseline. - name: Generate Infracost cost estimate baseline run: | diff --git a/terraform/variables.tf b/terraform/variables.tf index ad08bbbed..5b4d6e3df 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -10,4 +10,4 @@ variable "clusterName" { default = "tantech-gitops-eks" } -## \ No newline at end of file +### \ No newline at end of file From 95cd9c222ba070e25f506fd793a49efa4c9df303 Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 12:13:43 -0500 Subject: [PATCH 34/38] Add infracost cost estimation --- .github/workflows/terraform.yml | 11 +++++++---- terraform/variables.tf | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 2f06e629a..dad0c0c3f 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -81,13 +81,16 @@ jobs: exclude: "node_modules|dist|.git|.husky" path: ./ depth: 3 - + # Generate Infracost JSON file as the baseline. + # - name: Generate Infracost cost estimate baseline + # run: | + # infracost breakdown --path=. \ + # --format=json \ + # --out-file=/tmp/infracost-base.json - name: Generate Infracost cost estimate baseline run: | - infracost breakdown --path=. \ - --format=json \ - --out-file=/tmp/infracost-base.json + infracost breakdown --path=. # Posts a comment to the PR using the 'update' behavior. # This creates a single comment and updates it. The "quietest" option. # The other valid behaviors are: diff --git a/terraform/variables.tf b/terraform/variables.tf index 5b4d6e3df..ad08bbbed 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -10,4 +10,4 @@ variable "clusterName" { default = "tantech-gitops-eks" } -### \ No newline at end of file +## \ No newline at end of file From 442c9cb7d8a0660e360fc617e91b21651cf2f92e Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 12:23:07 -0500 Subject: [PATCH 35/38] Add infracost cost estimation --- .github/workflows/terraform.yml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index dad0c0c3f..dfeec3730 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -75,6 +75,13 @@ jobs: run: terraform plan -no-color -input=false -out planfile continue-on-error: true + # Generate Infracost JSON file as the baseline. + - name: Generate Infracost cost estimate baseline + run: | + infracost breakdown --path=. \ + --format=json \ + --out-file=infracost-base.json + - name: Print Workspace folder tree uses: jaywcjlove/github-action-folder-tree@main with: @@ -82,15 +89,10 @@ jobs: path: ./ depth: 3 - # Generate Infracost JSON file as the baseline. # - name: Generate Infracost cost estimate baseline # run: | - # infracost breakdown --path=. \ - # --format=json \ - # --out-file=/tmp/infracost-base.json - - name: Generate Infracost cost estimate baseline - run: | - infracost breakdown --path=. + # infracost breakdown --path=. + # Posts a comment to the PR using the 'update' behavior. # This creates a single comment and updates it. The "quietest" option. # The other valid behaviors are: @@ -107,7 +109,7 @@ jobs: # --behavior=update - name: Post Infracost comment run: | - infracost comment github --path=/tmp/infracost-base.json \ + infracost comment github --path=infracost-base.json \ --repo=$GITHUB_REPOSITORY \ --github-token=${{ github.token }} \ --commit=$GITHUB_SHA \ From 627a54eedb1cc3c7c4c5fd2b5074a7913fed1c7c Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 12:24:36 -0500 Subject: [PATCH 36/38] Add infracost cost estimation --- terraform/variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/variables.tf b/terraform/variables.tf index ad08bbbed..5b4d6e3df 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -10,4 +10,4 @@ variable "clusterName" { default = "tantech-gitops-eks" } -## \ No newline at end of file +### \ No newline at end of file From f5f2979f7b36f0c1665960f3e0ff2609fdbbf0b5 Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 13:17:14 -0500 Subject: [PATCH 37/38] Add infracost cost diff on pull request estimation --- .github/workflows/terraform.yml | 14 ++++++++++++-- terraform/variables.tf | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index dfeec3730..7d3f3225f 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -82,6 +82,15 @@ jobs: --format=json \ --out-file=infracost-base.json + # Generate an Infracost diff and save it to a JSON file. + - name: Generate Infracost diff + if: github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'synchronize') + run: | + infracost diff --path=. \ + --format=json \ + --compare-to=infracost-base.json \ + --out-file=infracost.json + - name: Print Workspace folder tree uses: jaywcjlove/github-action-folder-tree@main with: @@ -108,11 +117,12 @@ jobs: # --pull-request=${{ github.event.pull_request.number }} \ # --behavior=update - name: Post Infracost comment + if: github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'synchronize') run: | - infracost comment github --path=infracost-base.json \ + infracost comment github --path=infracost.json \ --repo=$GITHUB_REPOSITORY \ --github-token=${{ github.token }} \ - --commit=$GITHUB_SHA \ + --pull-request=${{ github.event.pull_request.number }} \ --behavior=update - name: Terraform plan status if: steps.plan.outcome == 'fail' diff --git a/terraform/variables.tf b/terraform/variables.tf index 5b4d6e3df..ad08bbbed 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -10,4 +10,4 @@ variable "clusterName" { default = "tantech-gitops-eks" } -### \ No newline at end of file +## \ No newline at end of file From f6299187f930597a0ce67e248c9982890f733fe7 Mon Sep 17 00:00:00 2001 From: Praveen Sankuratri Date: Mon, 21 Oct 2024 13:24:10 -0500 Subject: [PATCH 38/38] Chnage the number of AWS instances in EKS cluster --- terraform/eks-cluster.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/eks-cluster.tf b/terraform/eks-cluster.tf index 3e03d8fa0..76a19dbad 100644 --- a/terraform/eks-cluster.tf +++ b/terraform/eks-cluster.tf @@ -22,7 +22,7 @@ module "eks" { min_size = 1 max_size = 2 - desired_size = 12 + desired_size = 2 } two = {