From ac06afe594927d89a1f3d6b9d2832ffa8fa386d2 Mon Sep 17 00:00:00 2001 From: Shikha-1811 Date: Thu, 4 Sep 2025 12:56:47 +0530 Subject: [PATCH 01/13] Update bucket and region --- .github/workflows/terraform.yml | 82 --------------------------------- terraform/main.tf | 2 - terraform/terraform.tf | 10 ++-- terraform/variables.tf | 5 +- 4 files changed, 7 insertions(+), 92 deletions(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index bc7fdbf1a..e69de29bb 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -1,82 +0,0 @@ -name: "Vprofile IAC" -on: - push: - branches: - - main - - stage - paths: - - terraform/** - pull_request: - branches: - - main - paths: - - terraform/** - -env: - # 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: - 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 plan -no-color -input=false -out planfile - continue-on-error: true - - - name: Terraform plan status - if: steps.plan.outcome == 'failure' - run: exit 1 - - - name: Terraform Apply - id: apple - if: github.ref == 'refs/heads/main' && github.event_name == 'push' - run: terraform apply -auto-approve -input=false -parallelism=1 planfile - - - 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: Get Kube config file - id: getconfig - 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 diff --git a/terraform/main.tf b/terraform/main.tf index 94b6fc75a..5e93bd06c 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -12,5 +12,3 @@ data "aws_availability_zones" "available" {} locals { cluster_name = var.clusterName } - -## \ No newline at end of file diff --git a/terraform/terraform.tf b/terraform/terraform.tf index d68901a13..46aa7a481 100644 --- a/terraform/terraform.tf +++ b/terraform/terraform.tf @@ -27,13 +27,13 @@ terraform { } backend "s3" { - bucket = "vprofileactions23" + bucket = "vprofileaction2211" key = "terraform.tfstate" - region = "us-east-2" + region = "us-east-1" } required_version = "~> 1.6.3" } -## -## -## + + + diff --git a/terraform/variables.tf b/terraform/variables.tf index b8fe9d331..35581ff7e 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 = "us-east-1" } variable "clusterName" { @@ -10,5 +10,4 @@ variable "clusterName" { default = "vprofile-eks" } -## -## \ No newline at end of file + From 1aea066c734fa718d3d85359c6cf941c45df1d41 Mon Sep 17 00:00:00 2001 From: Shikha-1811 Date: Thu, 4 Sep 2025 13:22:02 +0530 Subject: [PATCH 02/13] workflows for terrafile --- .github/workflows/terraform.yml | 60 +++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index e69de29bb..c1c081de7 100644 --- a/.github/workflows/terraform.yml +++ b/.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 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-1" + EKS_CLUSTER: vprofile-eks + +jobs: + terraform: + name: "Apply terraform for 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=${{ env.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 Status + if: steps.plan.outcome == 'failure' + run: exit 1 From d9b77b25e669e62c120a1f7b9e0887cf9c2fb857 Mon Sep 17 00:00:00 2001 From: Shikha-1811 Date: Thu, 4 Sep 2025 13:37:52 +0530 Subject: [PATCH 03/13] run workshop --- terraform/main.tf | 1 + 1 file changed, 1 insertion(+) diff --git a/terraform/main.tf b/terraform/main.tf index 5e93bd06c..e6aee627a 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -12,3 +12,4 @@ data "aws_availability_zones" "available" {} locals { cluster_name = var.clusterName } +## \ No newline at end of file From ea6f64ee051499b5f0e1d9da3a0200bde93848ed Mon Sep 17 00:00:00 2001 From: Shikha-1811 Date: Thu, 4 Sep 2025 13:42:36 +0530 Subject: [PATCH 04/13] Test workflow --- terraform/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/main.tf b/terraform/main.tf index e6aee627a..75a438755 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -12,4 +12,4 @@ data "aws_availability_zones" "available" {} locals { cluster_name = var.clusterName } -## \ No newline at end of file + ###### \ No newline at end of file From 132b27fcf9730be2e476cef5ba2002447a9d4984 Mon Sep 17 00:00:00 2001 From: Shikha-1811 Date: Thu, 4 Sep 2025 13:45:41 +0530 Subject: [PATCH 05/13] workflow --- .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 c1c081de7..22fe9116a 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -35,8 +35,8 @@ jobs: - name: Setup Terraform with specified version on the runner uses: hashicorp/setup-terraform@v2 - #with: - # terraform_version: 1.6.3 + with: + terraform_version: 1.6.3 - name: Terraform Init id: init From 1090de556b2bcff92a15e4eeebec24d855cc4b7b Mon Sep 17 00:00:00 2001 From: Shikha-1811 Date: Thu, 4 Sep 2025 13:47:42 +0530 Subject: [PATCH 06/13] Testing --- terraform/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/main.tf b/terraform/main.tf index 75a438755..42cf9c97f 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -12,4 +12,4 @@ data "aws_availability_zones" "available" {} locals { cluster_name = var.clusterName } - ###### \ No newline at end of file +######################### \ No newline at end of file From 43bb3ed2916117f1230288eef9bdb2bf495d3f61 Mon Sep 17 00:00:00 2001 From: Shikha-1811 Date: Thu, 4 Sep 2025 14:03:47 +0530 Subject: [PATCH 07/13] Add apply step in terraform --- .github/workflows/terraform.yml | 21 +++++++++++++++++++++ terraform/main.tf | 1 - 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 22fe9116a..71a7eb37e 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -58,3 +58,24 @@ jobs: - name: Terraform Status if: steps.plan.outcome == 'failure' run: exit 1 + + - name: Terraform Apply + id: apple + if: github.ref == 'refs/heads/main' && github.event_name == 'push' + run: terraform apply -auto-approve -input=false -parallelism=1 planfile + + - 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: Get Kube Config file + id: getconfig + 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/main/deploy/static/provider/aws/deploy.yaml diff --git a/terraform/main.tf b/terraform/main.tf index 42cf9c97f..5e93bd06c 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -12,4 +12,3 @@ data "aws_availability_zones" "available" {} locals { cluster_name = var.clusterName } -######################### \ No newline at end of file From 0ecda66bb07a0e3dba39e86a7c0b57ca816ad28a Mon Sep 17 00:00:00 2001 From: Shikha-1811 Date: Thu, 4 Sep 2025 14:18:12 +0530 Subject: [PATCH 08/13] some deletions --- .github/workflows/terraform.yml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 71a7eb37e..539f0e264 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -63,19 +63,3 @@ jobs: id: apple if: github.ref == 'refs/heads/main' && github.event_name == 'push' run: terraform apply -auto-approve -input=false -parallelism=1 planfile - - - 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: Get Kube Config file - id: getconfig - 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/main/deploy/static/provider/aws/deploy.yaml From 61f49813e4a6a22f9671cce9d7d1d8f8ff1b6fcb Mon Sep 17 00:00:00 2001 From: Shikha-1811 Date: Thu, 4 Sep 2025 14:19:28 +0530 Subject: [PATCH 09/13] terraform apply --- .github/workflows/terraform.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 539f0e264..71a7eb37e 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -63,3 +63,19 @@ jobs: id: apple if: github.ref == 'refs/heads/main' && github.event_name == 'push' run: terraform apply -auto-approve -input=false -parallelism=1 planfile + + - 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: Get Kube Config file + id: getconfig + 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/main/deploy/static/provider/aws/deploy.yaml From b1503b3ae8028d25f21e242eee58f5c0994b5a36 Mon Sep 17 00:00:00 2001 From: Shikha-1811 Date: Thu, 4 Sep 2025 14:20:25 +0530 Subject: [PATCH 10/13] Run workflow --- terraform/main.tf | 1 + 1 file changed, 1 insertion(+) diff --git a/terraform/main.tf b/terraform/main.tf index 5e93bd06c..e6aee627a 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -12,3 +12,4 @@ data "aws_availability_zones" "available" {} locals { cluster_name = var.clusterName } +## \ No newline at end of file From f8cc02b14a5dc9d21831e6e8146b319971ca817a Mon Sep 17 00:00:00 2001 From: Shikha-1811 Date: Thu, 4 Sep 2025 14:37:46 +0530 Subject: [PATCH 11/13] update version --- 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 2c4610920..755d4fe15 100644 --- a/terraform/eks-cluster.tf +++ b/terraform/eks-cluster.tf @@ -3,7 +3,7 @@ module "eks" { version = "19.19.1" cluster_name = local.cluster_name - cluster_version = "1.27" + cluster_version = "1.29" vpc_id = module.vpc.vpc_id subnet_ids = module.vpc.private_subnets From 02a1f0ef758feed034584fa3f623ab8bf7b90caf Mon Sep 17 00:00:00 2001 From: Shikha-1811 Date: Thu, 4 Sep 2025 14:39:50 +0530 Subject: [PATCH 12/13] changes --- .github/workflows/terraform.yml | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 71a7eb37e..22fe9116a 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -58,24 +58,3 @@ jobs: - name: Terraform Status if: steps.plan.outcome == 'failure' run: exit 1 - - - name: Terraform Apply - id: apple - if: github.ref == 'refs/heads/main' && github.event_name == 'push' - run: terraform apply -auto-approve -input=false -parallelism=1 planfile - - - 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: Get Kube Config file - id: getconfig - 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/main/deploy/static/provider/aws/deploy.yaml From b48a943fd2e511068fab47864b8af4ca56b95c26 Mon Sep 17 00:00:00 2001 From: Shikha-1811 Date: Thu, 4 Sep 2025 14:40:29 +0530 Subject: [PATCH 13/13] apply --- .github/workflows/terraform.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 22fe9116a..71a7eb37e 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -58,3 +58,24 @@ jobs: - name: Terraform Status if: steps.plan.outcome == 'failure' run: exit 1 + + - name: Terraform Apply + id: apple + if: github.ref == 'refs/heads/main' && github.event_name == 'push' + run: terraform apply -auto-approve -input=false -parallelism=1 planfile + + - 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: Get Kube Config file + id: getconfig + 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/main/deploy/static/provider/aws/deploy.yaml