From 1b165d634e1737b44d7c4f7df08d1dfdcb212121 Mon Sep 17 00:00:00 2001 From: Jeswin Date: Sat, 4 Oct 2025 20:26:52 +0800 Subject: [PATCH 1/7] changed terraform and variable tf --- 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..e29405767 100644 --- a/terraform/terraform.tf +++ b/terraform/terraform.tf @@ -27,7 +27,7 @@ terraform { } backend "s3" { - bucket = "gitopsterrastate" + bucket = "vprofileactionsjhez03" 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 e9c0528643f8646387ae8f6f87d47f8d3798e210 Mon Sep 17 00:00:00 2001 From: Jeswin Date: Sat, 4 Oct 2025 20:50:21 +0800 Subject: [PATCH 2/7] staging workflow --- terraform/.github/workflows/terraform.yml | 63 +++++++++++++++++++++++ 1 file changed, 63 insertions(+) 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..723c0a1e7 --- /dev/null +++ b/terraform/.github/workflows/terraform.yml @@ -0,0 +1,63 @@ +#wokflow for Vprofile IAC +name: "Vprofile IAC" +on: + push: + branches: + - main + - stage + paths: + - "terraform/**" + pull_request: + branches: + - main + - stage + paths: + - "terraform/**" + +env: + # Credentials for deployments to AWS + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_ID }} + # 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.7.6 + # cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} + - 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 From 498342464d8cf61810f6fb1e01c2c53a8d9e09cf Mon Sep 17 00:00:00 2001 From: Jeswin Date: Sat, 4 Oct 2025 20:56:08 +0800 Subject: [PATCH 3/7] changed directory of workflows --- {terraform/.github => .github}/workflows/terraform.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {terraform/.github => .github}/workflows/terraform.yml (100%) diff --git a/terraform/.github/workflows/terraform.yml b/.github/workflows/terraform.yml similarity index 100% rename from terraform/.github/workflows/terraform.yml rename to .github/workflows/terraform.yml From a6b8a40ecb37328232dcf2804bd80053cdb4db66 Mon Sep 17 00:00:00 2001 From: Jeswin Date: Sat, 4 Oct 2025 20:59:17 +0800 Subject: [PATCH 4/7] changed terraform version --- terraform/terraform.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/terraform.tf b/terraform/terraform.tf index e29405767..37b80fdab 100644 --- a/terraform/terraform.tf +++ b/terraform/terraform.tf @@ -32,7 +32,7 @@ terraform { region = "us-east-2" } - required_version = "~> 1.6.3" + required_version = "~> 1.13.3" } ## ## From 68c508645d29ea645e71edd3a3ce9122d93583f5 Mon Sep 17 00:00:00 2001 From: Jeswin Date: Sat, 4 Oct 2025 21:18:10 +0800 Subject: [PATCH 5/7] added terraform apply steps --- .github/workflows/terraform.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 723c0a1e7..af157d72d 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -61,3 +61,24 @@ jobs: - name: "Terraform plan status" if: steps.plan.outcome == 'failure' run: exit 1 + + - name: "Terraform Apply" + id: apple + if: github.ref == 'refs/heads/main' && steps.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_ID }} + aws-region: ${{ env.AWS_REGION }} + + - name: "Get Kube config file" + id: getkubeconfig + 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 From 2848d9954eaab2c1d6de30c6a31fa9f203803577 Mon Sep 17 00:00:00 2001 From: Jeswin Date: Sat, 4 Oct 2025 21:19:15 +0800 Subject: [PATCH 6/7] stage test --- terraform/variables.tf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/terraform/variables.tf b/terraform/variables.tf index 3e49f4a09..757aea1e4 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -9,3 +9,7 @@ variable "clusterName" { type = string default = "vprofile-eks" } + + +## +### From a46d07570a051499699b62de7b0efbb7e47b4be8 Mon Sep 17 00:00:00 2001 From: Jeswin Date: Sat, 4 Oct 2025 21:40:58 +0800 Subject: [PATCH 7/7] fixed terraform apply steps to github --- .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 af157d72d..aa8268807 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -64,7 +64,7 @@ jobs: - name: "Terraform Apply" id: apple - if: github.ref == 'refs/heads/main' && steps.event_name == 'push' + if: github.ref == 'refs/heads/main' && github.event_name == 'push' run: terraform apply -auto-approve -input=false -parallelism=1 planfile - name: "Configure AWS credentials"