From 0aca7f7ccb1a312fa5f15a1edfcd946828c3ba17 Mon Sep 17 00:00:00 2001 From: Hani576 Date: Tue, 1 Jul 2025 10:46:42 +0200 Subject: [PATCH 01/13] Bucket name & Cluster name updated --- terraform/terraform.tf | 2 +- terraform/variables.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/terraform/terraform.tf b/terraform/terraform.tf index 67b75c673..b0ee89d20 100644 --- a/terraform/terraform.tf +++ b/terraform/terraform.tf @@ -27,7 +27,7 @@ terraform { } backend "s3" { - bucket = "gitopsterrastate" + bucket = "vprofileaction-1.7.2025" key = "terraform.tfstate" region = "us-east-2" } 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 2ff973d44c124e373fad00faf8893dc8a8e215ee Mon Sep 17 00:00:00 2001 From: Hani576 Date: Tue, 1 Jul 2025 11:54:15 +0200 Subject: [PATCH 02/13] Staging workflow --- .github/workflows/terraform.yml | 66 +++++++++++++++++++++++++++++++++ 1 file changed, 66 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..e56c7ef01 --- /dev/null +++ b/.github/workflows/terraform.yml @@ -0,0 +1,66 @@ +name: "Vprofile IAC" +on: + push: + branches: + - main + - stage + paths: + - terraform/** + + pull_request: + branches: + - main + paths: + - terraform/** + + +env: + AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}} + AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}} + BUCKET_TF_STATE: ${{secrets.BUCKET_TF_STATE}} + AWS_REGION: us-east-2 + EKS_CLUSTER_NAME: 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 + + + - name: "Terraform Init" + id: Init + run: terraform init -backend-config="bucket=$BUCKET_TF_STATE" + + + - name: "Terraform format" + id: format + 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.tfplan + continue-on-error: true + + + - name: Terraform plan status + if: steps.plan.outcome == 'failure' + run: | + echo "Terraform plan failed. Please check the logs for details." + exit 1 + \ No newline at end of file From cf8290db6febd7a0e0f96c78bfa90ec0859fd3a2 Mon Sep 17 00:00:00 2001 From: Hani576 Date: Tue, 1 Jul 2025 11:58:36 +0200 Subject: [PATCH 03/13] test workflow --- terraform/variables.tf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/terraform/variables.tf b/terraform/variables.tf index 3e49f4a09..12eba6781 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -9,3 +9,6 @@ variable "clusterName" { type = string default = "vprofile-eks" } + + +## \ No newline at end of file From 91e0512e4605e23777c0becbec5f3a01c8ba11e2 Mon Sep 17 00:00:00 2001 From: Hani576 Date: Tue, 1 Jul 2025 12:07:11 +0200 Subject: [PATCH 04/13] test 2 workflow --- .github/workflows/terraform.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index e56c7ef01..a904a1720 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -36,10 +36,12 @@ jobs: - name: "Setup Terraform with specified version on the runner" uses: hashicorp/setup-terraform@v2 + with: + terraform_version: 1.6.6 - name: "Terraform Init" - id: Init + id: init run: terraform init -backend-config="bucket=$BUCKET_TF_STATE" From 55199a587a023852a2e92b488b1d5715f9405a53 Mon Sep 17 00:00:00 2001 From: Hani576 Date: Tue, 1 Jul 2025 12:11:52 +0200 Subject: [PATCH 05/13] test 3 --- .github/workflows/terraform.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index a904a1720..55ced9644 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -37,7 +37,7 @@ jobs: - name: "Setup Terraform with specified version on the runner" uses: hashicorp/setup-terraform@v2 with: - terraform_version: 1.6.6 + terraform_version: 1.6.3 - name: "Terraform Init" From 0c5903b3a38a431b163188878e6ed505fb32067e Mon Sep 17 00:00:00 2001 From: Hani576 Date: Tue, 1 Jul 2025 12:14:48 +0200 Subject: [PATCH 06/13] test 4 --- .github/workflows/terraform.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 55ced9644..893c8f8e8 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -37,8 +37,8 @@ jobs: - name: "Setup Terraform with specified version on the runner" uses: hashicorp/setup-terraform@v2 with: - terraform_version: 1.6.3 - + terraform_version: 1.5.7 + - name: "Terraform Init" id: init From eaf3d3b05f5ddcf13f6b03ace491324a1f50dc7d Mon Sep 17 00:00:00 2001 From: Hani576 Date: Tue, 1 Jul 2025 12:15:52 +0200 Subject: [PATCH 07/13] test 5 --- terraform/terraform.tf | 2 -- 1 file changed, 2 deletions(-) diff --git a/terraform/terraform.tf b/terraform/terraform.tf index b0ee89d20..26795d37e 100644 --- a/terraform/terraform.tf +++ b/terraform/terraform.tf @@ -35,5 +35,3 @@ terraform { required_version = "~> 1.6.3" } ## -## -## From 248605512f2b898ba73e87da61cbc6119a15bd69 Mon Sep 17 00:00:00 2001 From: Hani576 Date: Tue, 1 Jul 2025 12:17:44 +0200 Subject: [PATCH 08/13] test 6 --- .github/workflows/terraform.yml | 2 +- terraform/terraform.tf | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 893c8f8e8..f63518a2d 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -37,7 +37,7 @@ jobs: - name: "Setup Terraform with specified version on the runner" uses: hashicorp/setup-terraform@v2 with: - terraform_version: 1.5.7 + terraform_version: 1.6.3 - name: "Terraform Init" diff --git a/terraform/terraform.tf b/terraform/terraform.tf index 26795d37e..243b45682 100644 --- a/terraform/terraform.tf +++ b/terraform/terraform.tf @@ -35,3 +35,4 @@ terraform { required_version = "~> 1.6.3" } ## +## From 0b46eaefcb4e3dcace6c7830cd6ebe3eb04f234b Mon Sep 17 00:00:00 2001 From: Hani576 Date: Tue, 1 Jul 2025 14:44:18 +0200 Subject: [PATCH 09/13] test stage --- .github/workflows/terraform.yml | 27 ++++++++++++++++++++++++++- terraform/variables.tf | 2 +- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index f63518a2d..37b9e1712 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -65,4 +65,29 @@ jobs: run: | echo "Terraform plan failed. Please check the logs for details." exit 1 - \ No newline at end of file + + + - name: "Terraform apply" + id: apple + if: github.ref == 'refs/heads/main' && github.event_name == 'push' + run: terraform apply -no-color -input=false -auto-approve -parallelism=1 planfile.tfplan + + + - name: "configure aws credentials" + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + + - name: "Configure kubectl" + id: getconfi + if: steps.apple.outcome == 'success' + run: | + aws eks update-kubeconfig --region ${{ env.AWS_REGION }} --name ${{ env.EKS_CLUSTER }} + + + - name: Install Ingress controller + if: steps.apple.outcome == 'success' && steps.getconfig.outcome == 'success' + run: kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.1.3/deploy/static/provider/aws/deploy.yaml + \ No newline at end of file diff --git a/terraform/variables.tf b/terraform/variables.tf index 12eba6781..f8a30ae51 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -11,4 +11,4 @@ variable "clusterName" { } -## \ No newline at end of file +###### \ No newline at end of file From 839f4165b745de629051dbb41289e965fc335f03 Mon Sep 17 00:00:00 2001 From: Hani576 Date: Tue, 1 Jul 2025 15:46:59 +0200 Subject: [PATCH 10/13] test kubectl --- .github/workflows/terraform.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 37b9e1712..cd53da9b8 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -84,7 +84,7 @@ jobs: id: getconfi if: steps.apple.outcome == 'success' run: | - aws eks update-kubeconfig --region ${{ env.AWS_REGION }} --name ${{ env.EKS_CLUSTER }} + aws eks update-kubeconfig --region ${{ env.AWS_REGION }} --name ${{ env.EKS_CLUSTER_NAME }} - name: Install Ingress controller From 41fed44113e84be340d2e3476c91efbe08a1a4cc Mon Sep 17 00:00:00 2001 From: Hani576 Date: Tue, 1 Jul 2025 15:50:50 +0200 Subject: [PATCH 11/13] test kube --- terraform/variables.tf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/terraform/variables.tf b/terraform/variables.tf index f8a30ae51..db98faa82 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -11,4 +11,5 @@ variable "clusterName" { } -###### \ No newline at end of file +#### +##### \ No newline at end of file From 69298245ef88874bab54ea1016178d16844e1338 Mon Sep 17 00:00:00 2001 From: Hani576 Date: Tue, 1 Jul 2025 15:53:44 +0200 Subject: [PATCH 12/13] test 1kube1 --- terraform/variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/variables.tf b/terraform/variables.tf index db98faa82..0d916bff6 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -12,4 +12,4 @@ variable "clusterName" { #### -##### \ No newline at end of file +##+++++++ \ No newline at end of file From ceaf755fe4bf02edc9e85bccf31eaa540fab3fb8 Mon Sep 17 00:00:00 2001 From: Hani576 Date: Tue, 1 Jul 2025 17:27:23 +0200 Subject: [PATCH 13/13] destroy -2 --- .github/workflows/terraform.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index cd53da9b8..75006b08f 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -70,7 +70,7 @@ jobs: - name: "Terraform apply" id: apple if: github.ref == 'refs/heads/main' && github.event_name == 'push' - run: terraform apply -no-color -input=false -auto-approve -parallelism=1 planfile.tfplan + run: terraform destroy -no-color -input=false -auto-approve -parallelism=1 #planfile.tfplan - name: "configure aws credentials"