From 68e721fe603ac0028dfb2715955a11f6961bcd6e Mon Sep 17 00:00:00 2001 From: goyalxatul Date: Thu, 16 Jan 2025 11:05:00 +0530 Subject: [PATCH 01/18] bucket name and cluster --- terraform/terraform.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/terraform/terraform.tf b/terraform/terraform.tf index 67b75c673..d4d28e0a4 100644 --- a/terraform/terraform.tf +++ b/terraform/terraform.tf @@ -27,9 +27,9 @@ terraform { } backend "s3" { - bucket = "gitopsterrastate" + bucket = "gitopspro" key = "terraform.tfstate" - region = "us-east-2" + region = "us-east-1" } required_version = "~> 1.6.3" From ab87eb1b27b833e9954d8495ed46d88be0887c56 Mon Sep 17 00:00:00 2001 From: goyalxatul Date: Thu, 16 Jan 2025 20:41:53 +0530 Subject: [PATCH 02/18] staging workflows --- .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..e80151863 --- /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-1 + EKS_CLUSTER: vprofile-eks + +jobs: + terraform: + name: "Apply Terraform Code Changes" + runs-on: ubuntu-latest + defaults: + run: + shell: bash + working-directory: ./terraform + + steps: + # Step 1: Check out source code + - name: Checkout source code + uses: actions/checkout@v4 + + # Step 2: Set up Terraform on the runner + - name: Set up Terraform + uses: hashicorp/setup-terraform@v2 + with: + terraform_version: 1.6.3 + + # Step 3: Initialize Terraform + - name: Terraform init + id: init + run: terraform init -backend-config="bucket=${{ env.BUCKET_TF_STATE }}" + + # Step 4: Format check + - name: Terraform format + id: fmt + run: terraform fmt -check + + # Step 5: Validate the Terraform code + - name: Terraform validate + id: validate + run: terraform validate + + # Step 6: Generate a Terraform plan + - name: Terraform plan + id: plan + run: terraform plan -no-color -input=false -out=planfile + + # Step 7: Check if the plan step failed + - name: Terraform plan status + if: steps.plan.outcome == 'failure' + run: exit 1 From 642d30a558adef0e25d62f1313df5246588b36ad Mon Sep 17 00:00:00 2001 From: goyalxatul Date: Thu, 16 Jan 2025 20:46:37 +0530 Subject: [PATCH 03/18] 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..e80151863 --- /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-1 + EKS_CLUSTER: vprofile-eks + +jobs: + terraform: + name: "Apply Terraform Code Changes" + runs-on: ubuntu-latest + defaults: + run: + shell: bash + working-directory: ./terraform + + steps: + # Step 1: Check out source code + - name: Checkout source code + uses: actions/checkout@v4 + + # Step 2: Set up Terraform on the runner + - name: Set up Terraform + uses: hashicorp/setup-terraform@v2 + with: + terraform_version: 1.6.3 + + # Step 3: Initialize Terraform + - name: Terraform init + id: init + run: terraform init -backend-config="bucket=${{ env.BUCKET_TF_STATE }}" + + # Step 4: Format check + - name: Terraform format + id: fmt + run: terraform fmt -check + + # Step 5: Validate the Terraform code + - name: Terraform validate + id: validate + run: terraform validate + + # Step 6: Generate a Terraform plan + - name: Terraform plan + id: plan + run: terraform plan -no-color -input=false -out=planfile + + # Step 7: Check if the plan step failed + - name: Terraform plan status + if: steps.plan.outcome == 'failure' + run: exit 1 From 465c20b4ebcae9afe74e60b9d84c11014cb20b59 Mon Sep 17 00:00:00 2001 From: goyalxatul Date: Thu, 16 Jan 2025 20:55:44 +0530 Subject: [PATCH 04/18] staging workflow --- .github/workflows/terraform.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index e80151863..9faf10856 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -4,14 +4,15 @@ on: push: branches: - main - - _stage + - stage paths: - - 'terraform/**' + - terraform/** + pull_request: branches: - main paths: - - 'terraform/**' + - terraform/** env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} From 86b6c9fa0e63644da6bda0aba140d1b7a3c2da16 Mon Sep 17 00:00:00 2001 From: goyalxatul Date: Thu, 16 Jan 2025 20:59:29 +0530 Subject: [PATCH 05/18] staging 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 9faf10856..3e2f9e8f3 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -38,8 +38,8 @@ jobs: # Step 2: Set up Terraform on the runner - name: Set up Terraform uses: hashicorp/setup-terraform@v2 - with: - terraform_version: 1.6.3 + #with: + #terraform_version: 1.6.3 # Step 3: Initialize Terraform - name: Terraform init From a9264d0cf53a2b76a7b79a2893fa3c252d6fdbb1 Mon Sep 17 00:00:00 2001 From: goyalxatul Date: Thu, 16 Jan 2025 21:02:26 +0530 Subject: [PATCH 06/18] staging workflow --- .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 3e2f9e8f3..97ff5b337 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -61,7 +61,7 @@ jobs: id: plan run: terraform plan -no-color -input=false -out=planfile - # Step 7: Check if the plan step failed + # Step 7: Check if the plan step failed #` - name: Terraform plan status if: steps.plan.outcome == 'failure' run: exit 1 From 6ce2562cbf384e842fedc0b2e1d198673e018725 Mon Sep 17 00:00:00 2001 From: Atul Goyal <123529264+goyalxatul@users.noreply.github.com> Date: Thu, 16 Jan 2025 21:03:36 +0530 Subject: [PATCH 07/18] Create main.yml --- .github/workflows/main.yml | 67 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..3e2f9e8f3 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,67 @@ +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-1 + EKS_CLUSTER: vprofile-eks + +jobs: + terraform: + name: "Apply Terraform Code Changes" + runs-on: ubuntu-latest + defaults: + run: + shell: bash + working-directory: ./terraform + + steps: + # Step 1: Check out source code + - name: Checkout source code + uses: actions/checkout@v4 + + # Step 2: Set up Terraform on the runner + - name: Set up Terraform + uses: hashicorp/setup-terraform@v2 + #with: + #terraform_version: 1.6.3 + + # Step 3: Initialize Terraform + - name: Terraform init + id: init + run: terraform init -backend-config="bucket=${{ env.BUCKET_TF_STATE }}" + + # Step 4: Format check + - name: Terraform format + id: fmt + run: terraform fmt -check + + # Step 5: Validate the Terraform code + - name: Terraform validate + id: validate + run: terraform validate + + # Step 6: Generate a Terraform plan + - name: Terraform plan + id: plan + run: terraform plan -no-color -input=false -out=planfile + + # Step 7: Check if the plan step failed + - name: Terraform plan status + if: steps.plan.outcome == 'failure' + run: exit 1 From 4c6af7d0941ad52f23f360d83206c89eb9d0a81e Mon Sep 17 00:00:00 2001 From: Atul Goyal <123529264+goyalxatul@users.noreply.github.com> Date: Thu, 16 Jan 2025 21:05:00 +0530 Subject: [PATCH 08/18] Update main.yml --- .github/workflows/main.yml | 66 -------------------------------------- 1 file changed, 66 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3e2f9e8f3..8b1378917 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,67 +1 @@ -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-1 - EKS_CLUSTER: vprofile-eks - -jobs: - terraform: - name: "Apply Terraform Code Changes" - runs-on: ubuntu-latest - defaults: - run: - shell: bash - working-directory: ./terraform - - steps: - # Step 1: Check out source code - - name: Checkout source code - uses: actions/checkout@v4 - - # Step 2: Set up Terraform on the runner - - name: Set up Terraform - uses: hashicorp/setup-terraform@v2 - #with: - #terraform_version: 1.6.3 - - # Step 3: Initialize Terraform - - name: Terraform init - id: init - run: terraform init -backend-config="bucket=${{ env.BUCKET_TF_STATE }}" - - # Step 4: Format check - - name: Terraform format - id: fmt - run: terraform fmt -check - - # Step 5: Validate the Terraform code - - name: Terraform validate - id: validate - run: terraform validate - - # Step 6: Generate a Terraform plan - - name: Terraform plan - id: plan - run: terraform plan -no-color -input=false -out=planfile - - # Step 7: Check if the plan step failed - - name: Terraform plan status - if: steps.plan.outcome == 'failure' - run: exit 1 From 281f38b0890520262dab397f32a233132efe98d9 Mon Sep 17 00:00:00 2001 From: goyalxatul Date: Thu, 16 Jan 2025 21:05:35 +0530 Subject: [PATCH 09/18] ok --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 8b1378917..000000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1 +0,0 @@ - From 3415b63103d5341e28b0c9f8933f308eb92d6906 Mon Sep 17 00:00:00 2001 From: goyalxatul Date: Thu, 16 Jan 2025 21:10:28 +0530 Subject: [PATCH 10/18] staging --- .github/workflows/terraform.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 97ff5b337..b539820fd 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -15,11 +15,11 @@ on: - 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-1 - EKS_CLUSTER: vprofile-eks +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-1 +EKS_CLUSTER: vprofile-eks jobs: terraform: From a23072b2bd60342bb09733fdba454d2e76f06bc5 Mon Sep 17 00:00:00 2001 From: goyalxatul Date: Thu, 16 Jan 2025 21:19:09 +0530 Subject: [PATCH 11/18] stagin --- .github/workflows/terraform.yml | 125 +++++++++++++++----------------- 1 file changed, 58 insertions(+), 67 deletions(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index b539820fd..43499e012 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -1,67 +1,58 @@ -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-1 -EKS_CLUSTER: vprofile-eks - -jobs: - terraform: - name: "Apply Terraform Code Changes" - runs-on: ubuntu-latest - defaults: - run: - shell: bash - working-directory: ./terraform - - steps: - # Step 1: Check out source code - - name: Checkout source code - uses: actions/checkout@v4 - - # Step 2: Set up Terraform on the runner - - name: Set up Terraform - uses: hashicorp/setup-terraform@v2 - #with: - #terraform_version: 1.6.3 - - # Step 3: Initialize Terraform - - name: Terraform init - id: init - run: terraform init -backend-config="bucket=${{ env.BUCKET_TF_STATE }}" - - # Step 4: Format check - - name: Terraform format - id: fmt - run: terraform fmt -check - - # Step 5: Validate the Terraform code - - name: Terraform validate - id: validate - run: terraform validate - - # Step 6: Generate a Terraform plan - - name: Terraform plan - id: plan - run: terraform plan -no-color -input=false -out=planfile - - # Step 7: Check if the plan step failed #` - - name: Terraform plan status - if: steps.plan.outcome == 'failure' - run: exit 1 +--- + 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-1 + 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: Set up Terraform + uses: hashicorp/setup-terraform@v2 + + - 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 + + - name: Terraform plan status + if: steps.plan.outcome == 'failure' + run: exit 1 + From 50e47a05b8156d126c86b78ddc880dd517fc7eaa Mon Sep 17 00:00:00 2001 From: Atul Goyal <123529264+goyalxatul@users.noreply.github.com> Date: Thu, 16 Jan 2025 21:29:17 +0530 Subject: [PATCH 12/18] Create terrafor.yml --- .github/workflows/terrafor.yml | 57 ++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/terrafor.yml diff --git a/.github/workflows/terrafor.yml b/.github/workflows/terrafor.yml new file mode 100644 index 000000000..3d64c68b5 --- /dev/null +++ b/.github/workflows/terrafor.yml @@ -0,0 +1,57 @@ +--- + 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-1 + 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: Set up Terraform + uses: hashicorp/setup-terraform@v2 + + - 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 + + - name: Terraform plan status + if: steps.plan.outcome == 'failure' + run: exit 1 From 4189e4637b7c529295cfb231d022793f14d2141a Mon Sep 17 00:00:00 2001 From: goyalxatul Date: Thu, 16 Jan 2025 21:30:36 +0530 Subject: [PATCH 13/18] ss --- .github/workflows/terrafor.yml | 57 ---------------------------------- 1 file changed, 57 deletions(-) delete mode 100644 .github/workflows/terrafor.yml diff --git a/.github/workflows/terrafor.yml b/.github/workflows/terrafor.yml deleted file mode 100644 index 3d64c68b5..000000000 --- a/.github/workflows/terrafor.yml +++ /dev/null @@ -1,57 +0,0 @@ ---- - 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-1 - 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: Set up Terraform - uses: hashicorp/setup-terraform@v2 - - - 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 - - - name: Terraform plan status - if: steps.plan.outcome == 'failure' - run: exit 1 From 0c7bff158023dfc4c1aba39efd13281104eadabd Mon Sep 17 00:00:00 2001 From: goyalxatul Date: Thu, 16 Jan 2025 21:32:42 +0530 Subject: [PATCH 14/18] staging --- .github/workflows/terraform.yml | 119 ++++++++++++++++---------------- 1 file changed, 61 insertions(+), 58 deletions(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 43499e012..4d3778925 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -1,58 +1,61 @@ ---- - 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-1 - 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: Set up Terraform - uses: hashicorp/setup-terraform@v2 - - - 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 - - - name: Terraform plan status - if: steps.plan.outcome == 'failure' - run: exit 1 - +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 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 From 5f5bad9e24bbb890136bba39329e46079ae2f8ec Mon Sep 17 00:00:00 2001 From: goyalxatul Date: Thu, 16 Jan 2025 23:23:39 +0530 Subject: [PATCH 15/18] staging --- .github/workflows/terraform.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 4d3778925..dee20cf0d 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -59,3 +59,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' && 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 From c03bdab6a3183a5af20c1fbdc901021f459934ee Mon Sep 17 00:00:00 2001 From: Atul Goyal <123529264+goyalxatul@users.noreply.github.com> Date: Thu, 16 Jan 2025 23:26:48 +0530 Subject: [PATCH 16/18] Create main.yml --- .github/workflows/main.yml | 82 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..bc7fdbf1a --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,82 @@ +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 From c59f2d5a3f7f8e9675f1e8f273816027c325134a Mon Sep 17 00:00:00 2001 From: goyalxatul Date: Thu, 16 Jan 2025 23:28:08 +0530 Subject: [PATCH 17/18] cleared --- .github/workflows/main.yml | 82 --------------------------------- .github/workflows/terraform.yml | 82 --------------------------------- 2 files changed, 164 deletions(-) delete mode 100644 .github/workflows/main.yml delete mode 100644 .github/workflows/terraform.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index bc7fdbf1a..000000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -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/.github/workflows/terraform.yml b/.github/workflows/terraform.yml deleted file mode 100644 index dee20cf0d..000000000 --- a/.github/workflows/terraform.yml +++ /dev/null @@ -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-1 - 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 From 7c02fd9aaea4b809f1880ab8ea3b4500a296d4d6 Mon Sep 17 00:00:00 2001 From: Atul Goyal <123529264+goyalxatul@users.noreply.github.com> Date: Thu, 16 Jan 2025 23:28:58 +0530 Subject: [PATCH 18/18] Create terraform.yml --- .github/workflows/terraform.yml | 83 +++++++++++++++++++++++++++++++++ 1 file changed, 83 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..5143d9e6a --- /dev/null +++ b/.github/workflows/terraform.yml @@ -0,0 +1,83 @@ +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 +