From d954980b21de70606bfcc161fb3a76d4fd7e4691 Mon Sep 17 00:00:00 2001 From: dewcxiv Date: Mon, 10 Feb 2025 13:33:28 +0700 Subject: [PATCH 01/10] staging workflow --- terraform/variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/variables.tf b/terraform/variables.tf index a41d982a0..3e49f4a09 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -7,5 +7,5 @@ variable "region" { variable "clusterName" { description = "Name of the EKS cluster" type = string - default = "kitops-eks" + default = "vprofile-eks" } From 83c5e30e92e1b229e47fc8cc2b4173527b4fffd9 Mon Sep 17 00:00:00 2001 From: dewcxiv Date: Mon, 10 Feb 2025 13:35:40 +0700 Subject: [PATCH 02/10] staging workflow --- terraform/.github/workflows/terraform.yml | 60 +++++++++++++++++++++++ terraform/terraform.tf | 4 +- 2 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 terraform/.github/workflows/terraform.yml diff --git a/terraform/.github/workflows/terraform.yml b/terraform/.github/workflows/terraform.yml new file mode 100644 index 000000000..ec35013e0 --- /dev/null +++ b/terraform/.github/workflows/terraform.yml @@ -0,0 +1,60 @@ +name: "Vprofile IAC" +on: + push: + branches: + - main + - stage + paths: + - terraform/** + pull_request: + branches: + - main + paths: + - terraform/** + +env: + # Credentials for deploymenr to AWS + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + # S3 bucket for the Terraform state + BUCKET_IF_STATE: ${{ secrets.BUCKET_TF_STATE }} + AWS_REGION: ap-southeast-2 + EKS_CLUSTER: vprofile-eks + + jobs: + terraform: + name: "Apply terraform code changes" + 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 + #with: + # terraform version: 1.6.3 + + - name: Terraform 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 pln -no-color -input=false -out planfile + continue on error: true + + - name: Terraform plan status + if: steps.plam.outcome == 'failure' + run: exit 1 \ No newline at end of file diff --git a/terraform/terraform.tf b/terraform/terraform.tf index 67b75c673..b416e7731 100644 --- a/terraform/terraform.tf +++ b/terraform/terraform.tf @@ -27,9 +27,9 @@ terraform { } backend "s3" { - bucket = "gitopsterrastate" + bucket = "dewcxivprofileactions" key = "terraform.tfstate" - region = "us-east-2" + region = "ap-southeast-2" } required_version = "~> 1.6.3" From 33f6fb328f13b7a838e6f2ee132fef0a3ce7a7aa Mon Sep 17 00:00:00 2001 From: dewcxiv Date: Mon, 10 Feb 2025 13:38:33 +0700 Subject: [PATCH 03/10] staging workflow --- terraform/.github/workflows/terraform.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/terraform/.github/workflows/terraform.yml b/terraform/.github/workflows/terraform.yml index ec35013e0..cdb1a1a35 100644 --- a/terraform/.github/workflows/terraform.yml +++ b/terraform/.github/workflows/terraform.yml @@ -46,6 +46,7 @@ env: - name: Terraform format id: fmt run: terraform fmt -check + - name: Terraform validate id: validate run: terraform validate From efd025a792b80064acfc02a9fbc195e4bb4e47e0 Mon Sep 17 00:00:00 2001 From: dewcxiv Date: Mon, 10 Feb 2025 13:43:37 +0700 Subject: [PATCH 04/10] fixed jobs --- terraform/.github/workflows/terraform.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/terraform/.github/workflows/terraform.yml b/terraform/.github/workflows/terraform.yml index cdb1a1a35..1ad3a7a4b 100644 --- a/terraform/.github/workflows/terraform.yml +++ b/terraform/.github/workflows/terraform.yml @@ -21,7 +21,7 @@ env: AWS_REGION: ap-southeast-2 EKS_CLUSTER: vprofile-eks - jobs: +jobs: terraform: name: "Apply terraform code changes" runs-on: ubuntu-latest @@ -46,7 +46,7 @@ env: - name: Terraform format id: fmt run: terraform fmt -check - + - name: Terraform validate id: validate run: terraform validate From fb2ca1b8f3b4fffc8c1687df59232c04908f2ab8 Mon Sep 17 00:00:00 2001 From: dewcxiv Date: Mon, 10 Feb 2025 13:46:00 +0700 Subject: [PATCH 05/10] test workflow --- terraform/variables.tf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/terraform/variables.tf b/terraform/variables.tf index 3e49f4a09..576ba161e 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -9,3 +9,5 @@ variable "clusterName" { type = string default = "vprofile-eks" } + +## \ No newline at end of file From c5295e482e7ad7023bbd5f057cedba18dc20f346 Mon Sep 17 00:00:00 2001 From: dewcxiv Date: Mon, 10 Feb 2025 13:57:59 +0700 Subject: [PATCH 06/10] staging workflow fixed --- terraform/.github/workflows/terraform.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/terraform/.github/workflows/terraform.yml b/terraform/.github/workflows/terraform.yml index 1ad3a7a4b..d9387bcb3 100644 --- a/terraform/.github/workflows/terraform.yml +++ b/terraform/.github/workflows/terraform.yml @@ -53,9 +53,9 @@ jobs: - name: Terraform plan id: plan - run: terraform pln -no-color -input=false -out planfile + run: terraform plan -no-color -input=false -out planfile continue on error: true - name: Terraform plan status - if: steps.plam.outcome == 'failure' + if: steps.plan.outcome == 'failure' run: exit 1 \ No newline at end of file From a99c1308adc486a0d9f5666a9d924c68228394c7 Mon Sep 17 00:00:00 2001 From: dewcxiv Date: Mon, 10 Feb 2025 14:03:52 +0700 Subject: [PATCH 07/10] test workflow --- terraform/variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/variables.tf b/terraform/variables.tf index 576ba161e..13e20059a 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -1,7 +1,7 @@ variable "region" { description = "AWS region" type = string - default = "us-east-2" + default = "ap-southeast-2" } variable "clusterName" { From 24ef68eaed790807ca9bca4f336471b8c71b81c3 Mon Sep 17 00:00:00 2001 From: dewcxiv Date: Mon, 10 Feb 2025 14:15:10 +0700 Subject: [PATCH 08/10] fixed jobs --- terraform/.github/workflows/terraform.yml | 48 +++++++++++------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/terraform/.github/workflows/terraform.yml b/terraform/.github/workflows/terraform.yml index d9387bcb3..d56219ed2 100644 --- a/terraform/.github/workflows/terraform.yml +++ b/terraform/.github/workflows/terraform.yml @@ -1,25 +1,25 @@ name: "Vprofile IAC" on: - push: - branches: - - main - - stage - paths: - - terraform/** + push: + branches: + - main + - stage + paths: + - terraform/** pull_request: branches: - - main + - main paths: - - terraform/** + - terraform/** env: - # Credentials for deploymenr to AWS - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - # S3 bucket for the Terraform state - BUCKET_IF_STATE: ${{ secrets.BUCKET_TF_STATE }} - AWS_REGION: ap-southeast-2 - EKS_CLUSTER: vprofile-eks + # Credentials for deployment to AWS + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + # S3 bucket for the Terraform state + BUCKET_TF_STATE: ${{ secrets.BUCKET_TF_STATE}} + AWS_REGION: us-east-2 + EKS_CLUSTER: vprofile-eks jobs: terraform: @@ -27,17 +27,17 @@ jobs: runs-on: ubuntu-latest defaults: run: - shell: bash - working-directory: ./terraform + shell: bash + working-directory: ./terraform steps: - - name: Checkout source code + - name: Checkout source code uses: actions/checkout@v4 - name: Setup Terraform with specified version on the runner uses: hashicorp/setup-terraform@v2 #with: - # terraform version: 1.6.3 + # terraform_version: 1.6.3 - name: Terraform init id: init @@ -50,12 +50,12 @@ jobs: - 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 - + continue-on-error: true + - name: Terraform plan status - if: steps.plan.outcome == 'failure' - run: exit 1 \ No newline at end of file + if: steps.plan.outcome == 'failure' + run: exit 1 \ No newline at end of file From 866da7682ee7093f7ee792d8970787fb33c4ec5f Mon Sep 17 00:00:00 2001 From: dewcxiv Date: Tue, 11 Feb 2025 13:46:44 +0700 Subject: [PATCH 09/10] staging workflows --- terraform/.github/workflows/terraform.yml | 6 +++--- terraform/terraform.tf | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/terraform/.github/workflows/terraform.yml b/terraform/.github/workflows/terraform.yml index d56219ed2..c0689d714 100644 --- a/terraform/.github/workflows/terraform.yml +++ b/terraform/.github/workflows/terraform.yml @@ -35,9 +35,9 @@ jobs: uses: actions/checkout@v4 - name: Setup Terraform with specified version on the runner - uses: hashicorp/setup-terraform@v2 + uses: hashicorp/setup-terraform@v3 #with: - # terraform_version: 1.6.3 + # terraform_version: 1.1.7 - name: Terraform init id: init @@ -58,4 +58,4 @@ jobs: - name: Terraform plan status if: steps.plan.outcome == 'failure' - run: exit 1 \ No newline at end of file + run: exit 1 \ No newline at end of file diff --git a/terraform/terraform.tf b/terraform/terraform.tf index b416e7731..b03098f6f 100644 --- a/terraform/terraform.tf +++ b/terraform/terraform.tf @@ -27,13 +27,12 @@ terraform { } backend "s3" { - bucket = "dewcxivprofileactions" + bucket = "vprofileaction22" key = "terraform.tfstate" region = "ap-southeast-2" } required_version = "~> 1.6.3" } -## -## + ## From f123a0699b88966b4ecb47a539418ae873c51a09 Mon Sep 17 00:00:00 2001 From: dewcxiv Date: Mon, 17 Feb 2025 08:16:28 +0700 Subject: [PATCH 10/10] staging workflow --- terraform/.github/workflows/terraform.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/.github/workflows/terraform.yml b/terraform/.github/workflows/terraform.yml index c0689d714..5c2854022 100644 --- a/terraform/.github/workflows/terraform.yml +++ b/terraform/.github/workflows/terraform.yml @@ -58,4 +58,4 @@ jobs: - name: Terraform plan status if: steps.plan.outcome == 'failure' - run: exit 1 \ No newline at end of file + run: exit 1 \ No newline at end of file