From a7922a7885a4a939ac44d3f88f8db7ea5598d8a9 Mon Sep 17 00:00:00 2001 From: sahils13 Date: Thu, 1 May 2025 16:43:19 +0530 Subject: [PATCH 01/13] Bucket name & Cluster name updated --- terraform/terraform.tf | 4 ++-- terraform/variables.tf | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/terraform/terraform.tf b/terraform/terraform.tf index 67b75c673..6968db2da 100644 --- a/terraform/terraform.tf +++ b/terraform/terraform.tf @@ -27,9 +27,9 @@ terraform { } backend "s3" { - bucket = "gitopsterrastate" + bucket = "appaction13" key = "terraform.tfstate" - region = "us-east-2" + region = "ap-south-1" } required_version = "~> 1.6.3" diff --git a/terraform/variables.tf b/terraform/variables.tf index a41d982a0..f8d9dbd98 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 = "ap-south-1" } variable "clusterName" { description = "Name of the EKS cluster" type = string - default = "kitops-eks" + default = "app13-eks" } From 1ca4bbe20ed49f46f5e23a46f822d70955e6447a Mon Sep 17 00:00:00 2001 From: sahils13 Date: Thu, 1 May 2025 17:50:16 +0530 Subject: [PATCH 02/13] working stage --- .github/workflows/terraform.yml | 64 +++++++++++++++++++++++++++++++++ 1 file changed, 64 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..8720adb0f --- /dev/null +++ b/.github/workflows/terraform.yml @@ -0,0 +1,64 @@ +name: "iac-app13" +on: + push: + branches: + - main + - stage + paths: + - terraform/** + pull_request: + branches: + - main + paths: + - terraform/** + +env: +# credentials for deployment to AWS + AWS_ACCESS_KEY_ID13: ${{ secrets.AWS_ACCESS_KEY_ID13}} + AWS_SECRET_ACCESS_KEY13: ${{ secrets.AWS_SECRET_ACCESS_KEY13}} + +#S3 Bucket for the Terraform state + BUCKET_TF_STATE: ${{ secrets.BUCKET_TF_STATE}} + AWS_REGION: ap-south-1 + EKS_CLUSTER: app13-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 with specified version on the runner + uses: hasicorp/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: Terrafom plan status + if: steps.plan.outcome == 'failure' + run: exit 1 + + + From 042c96b09db32a0467f89185d9428e911b10e2d8 Mon Sep 17 00:00:00 2001 From: sahils13 Date: Thu, 1 May 2025 17:51:38 +0530 Subject: [PATCH 03/13] test workflow --- terraform/variables.tf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/terraform/variables.tf b/terraform/variables.tf index f8d9dbd98..5748800f6 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -9,3 +9,5 @@ variable "clusterName" { type = string default = "app13-eks" } + +## From 46fa2d1906dfd8331db7d61fedf9c9ee5086da73 Mon Sep 17 00:00:00 2001 From: sahils13 Date: Thu, 1 May 2025 18:25:46 +0530 Subject: [PATCH 04/13] test again --- .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 8720adb0f..75ec4ca5e 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -40,7 +40,7 @@ jobs: #terraform_version: 1.6.3 - name: Terraform init - id: = init + id: init run: terraform init -backend-config="bucket=$BUCKET_TF_STATE" - name: Terraform format From de12f578869f5da4a8a3cfa79a6734cb4468c479 Mon Sep 17 00:00:00 2001 From: sahils13 Date: Thu, 1 May 2025 18:36:55 +0530 Subject: [PATCH 05/13] test work --- .github/workflows/terraform.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 75ec4ca5e..db0005c92 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -1,4 +1,4 @@ -name: "iac-app13" +name: iac-app13 on: push: branches: @@ -35,7 +35,7 @@ jobs: uses: actions/checkout@v4 - name: Setup with specified version on the runner - uses: hasicorp/setup-terraform@v2 + uses: hashicorp/setup-terraform@v2 # with: #terraform_version: 1.6.3 @@ -56,7 +56,7 @@ jobs: run: terraform plan -no-color -input=false -out planfile continue-on-error: true - - name: Terrafom plan status + - name: Terraform plan status if: steps.plan.outcome == 'failure' run: exit 1 From 6868ab4100beb2491b26faf871174cb8398b3905 Mon Sep 17 00:00:00 2001 From: sahils13 Date: Thu, 1 May 2025 18:39:17 +0530 Subject: [PATCH 06/13] test again --- .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 db0005c92..d8adaf445 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -1,4 +1,4 @@ -name: iac-app13 +name: "iac-app13" on: push: branches: From 659ad5d3efef8240b9cc86a0cf5570fb7347f3e4 Mon Sep 17 00:00:00 2001 From: sahils13 Date: Thu, 1 May 2025 18:44:39 +0530 Subject: [PATCH 07/13] just test --- terraform/variables.tf | 1 + 1 file changed, 1 insertion(+) diff --git a/terraform/variables.tf b/terraform/variables.tf index 5748800f6..d0210f2d9 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -11,3 +11,4 @@ variable "clusterName" { } ## +## From 87bb46e686cf1bd8aac6cd70dea5db7e0f2f3b67 Mon Sep 17 00:00:00 2001 From: sahils13 Date: Thu, 1 May 2025 18:55:36 +0530 Subject: [PATCH 08/13] final test --- .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 d8adaf445..5fec7c0fe 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -36,8 +36,8 @@ jobs: - name: Setup 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 4c856e1e04515b715ad20c390e7b47c8003ca0e3 Mon Sep 17 00:00:00 2001 From: sahils13 Date: Thu, 1 May 2025 18:56:25 +0530 Subject: [PATCH 09/13] test test --- terraform/variables.tf | 1 + 1 file changed, 1 insertion(+) diff --git a/terraform/variables.tf b/terraform/variables.tf index d0210f2d9..5eb62eabb 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -12,3 +12,4 @@ variable "clusterName" { ## ## +## From 97fc4db7fb502e2e28c54869748d5004745f753d Mon Sep 17 00:00:00 2001 From: sahils13 Date: Thu, 1 May 2025 19:10:41 +0530 Subject: [PATCH 10/13] please run --- .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 5fec7c0fe..6649b51f7 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -14,8 +14,8 @@ on: env: # credentials for deployment to AWS - AWS_ACCESS_KEY_ID13: ${{ secrets.AWS_ACCESS_KEY_ID13}} - AWS_SECRET_ACCESS_KEY13: ${{ secrets.AWS_SECRET_ACCESS_KEY13}} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID13}} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY13}} #S3 Bucket for the Terraform state BUCKET_TF_STATE: ${{ secrets.BUCKET_TF_STATE}} From 9db164a6653d884f0fd4ef763b00344615fef6dc Mon Sep 17 00:00:00 2001 From: sahils13 Date: Thu, 1 May 2025 19:11:34 +0530 Subject: [PATCH 11/13] run --- terraform/variables.tf | 1 + 1 file changed, 1 insertion(+) diff --git a/terraform/variables.tf b/terraform/variables.tf index 5eb62eabb..228a8145c 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -13,3 +13,4 @@ variable "clusterName" { ## ## ## +## From 1a518f4c18b7ca112354f343d56af2f31e5a0493 Mon Sep 17 00:00:00 2001 From: sahils13 Date: Thu, 1 May 2025 19:34:20 +0530 Subject: [PATCH 12/13] steps test --- .github/workflows/terraform.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 6649b51f7..387797840 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -59,6 +59,30 @@ jobs: - 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_ID13 }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY13 }} + 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 + From c901ce5f95e6fc101f193c6dc4a303bec6438815 Mon Sep 17 00:00:00 2001 From: sahils13 Date: Thu, 1 May 2025 19:35:12 +0530 Subject: [PATCH 13/13] steps run --- terraform/variables.tf | 1 + 1 file changed, 1 insertion(+) diff --git a/terraform/variables.tf b/terraform/variables.tf index 228a8145c..432ce2e7c 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -14,3 +14,4 @@ variable "clusterName" { ## ## ## +##