From e180099a67b8371f8a11014f11df67f97dafd893 Mon Sep 17 00:00:00 2001 From: Parwez Date: Tue, 9 Sep 2025 19:03:43 +0530 Subject: [PATCH 1/8] Workflow --- .github/terraform.yaml | 82 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 .github/terraform.yaml diff --git a/.github/terraform.yaml b/.github/terraform.yaml new file mode 100644 index 000000000..9bc085d27 --- /dev/null +++ b/.github/terraform.yaml @@ -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 \ No newline at end of file From 88b58ab965ff8be1e051b4f9e21f78f21a05f92c Mon Sep 17 00:00:00 2001 From: Parwez Date: Tue, 9 Sep 2025 19:08:41 +0530 Subject: [PATCH 2/8] Checking workflow --- terraform/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/main.tf b/terraform/main.tf index 94b6fc75a..cc359c87b 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -13,4 +13,4 @@ locals { cluster_name = var.clusterName } -## \ No newline at end of file +## Create EKS Cluster \ No newline at end of file From e07430a50ef8ee6a596ed31c932bc682ccae2acf Mon Sep 17 00:00:00 2001 From: Parwez Date: Tue, 9 Sep 2025 19:29:58 +0530 Subject: [PATCH 3/8] Hello --- terraform/main.tf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/terraform/main.tf b/terraform/main.tf index cc359c87b..cb4cc87d0 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -13,4 +13,6 @@ locals { cluster_name = var.clusterName } -## Create EKS Cluster \ No newline at end of file +## Create EKS Cluster + +## \ No newline at end of file From b2a759a70d402022d4aebe5ec9cbdf08d00c7731 Mon Sep 17 00:00:00 2001 From: Parwez Date: Tue, 9 Sep 2025 19:34:20 +0530 Subject: [PATCH 4/8] Workflow --- .github/{ => workflows}/terraform.yaml | 21 +-------------------- terraform/main.tf | 1 + 2 files changed, 2 insertions(+), 20 deletions(-) rename .github/{ => workflows}/terraform.yaml (59%) diff --git a/.github/terraform.yaml b/.github/workflows/terraform.yaml similarity index 59% rename from .github/terraform.yaml rename to .github/workflows/terraform.yaml index 9bc085d27..7c1915bec 100644 --- a/.github/terraform.yaml +++ b/.github/workflows/terraform.yaml @@ -60,23 +60,4 @@ jobs: 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 \ No newline at end of file + \ No newline at end of file diff --git a/terraform/main.tf b/terraform/main.tf index cb4cc87d0..16e2c179c 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -15,4 +15,5 @@ locals { ## Create EKS Cluster +## ## \ No newline at end of file From e860dbebbaa51cbe4ce2ae4d3155869e7be5383e Mon Sep 17 00:00:00 2001 From: Parwez Date: Tue, 9 Sep 2025 19:38:07 +0530 Subject: [PATCH 5/8] Workflow2 --- README.md | 1 + terraform/terraform.tf | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dcd659f7e..f9f2b31d1 100644 --- a/README.md +++ b/README.md @@ -13,3 +13,4 @@ Terraform version 1.6.3 * terraform apply -auto-approve -input=false -parallelism=1 planfile #### ##### +This is Great \ No newline at end of file diff --git a/terraform/terraform.tf b/terraform/terraform.tf index 67b75c673..25d0180de 100644 --- a/terraform/terraform.tf +++ b/terraform/terraform.tf @@ -27,9 +27,9 @@ terraform { } backend "s3" { - bucket = "gitopsterrastate" + bucket = "vprofileapplication23" key = "terraform.tfstate" - region = "us-east-2" + region = "us-east-1" } required_version = "~> 1.6.3" From c5b82a519ecccfa252a874e4463b2e363106f073 Mon Sep 17 00:00:00 2001 From: Parwez Date: Tue, 9 Sep 2025 19:39:42 +0530 Subject: [PATCH 6/8] Workflow3 --- .github/workflows/terraform.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/terraform.yaml b/.github/workflows/terraform.yaml index 7c1915bec..0b2ef4924 100644 --- a/.github/workflows/terraform.yaml +++ b/.github/workflows/terraform.yaml @@ -36,8 +36,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 22513645723b45d89938e37811dca4be828a7ad6 Mon Sep 17 00:00:00 2001 From: Parwez Date: Tue, 9 Sep 2025 19:40:47 +0530 Subject: [PATCH 7/8] Workflow3 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f9f2b31d1..b76d06749 100644 --- a/README.md +++ b/README.md @@ -13,4 +13,4 @@ Terraform version 1.6.3 * terraform apply -auto-approve -input=false -parallelism=1 planfile #### ##### -This is Great \ No newline at end of file +This may work \ No newline at end of file From fd67088291113d0ae968911f6962c8e609ffe9e2 Mon Sep 17 00:00:00 2001 From: Parwez Date: Tue, 9 Sep 2025 19:42:14 +0530 Subject: [PATCH 8/8] Workflow3 --- terraform/main.tf | 1 + 1 file changed, 1 insertion(+) diff --git a/terraform/main.tf b/terraform/main.tf index 16e2c179c..1d3416b5e 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -15,5 +15,6 @@ locals { ## Create EKS Cluster +## ## ## \ No newline at end of file