From 04cf28130008fbc6d9eac016a535a1104bb83b7f Mon Sep 17 00:00:00 2001 From: Joel Wembo Date: Mon, 15 Apr 2024 01:23:57 +0800 Subject: [PATCH] destroy all running instances and resources --- .github/workflows/terraform-aws-ec2-4.yaml | 166 ++++++++++----------- 1 file changed, 83 insertions(+), 83 deletions(-) diff --git a/.github/workflows/terraform-aws-ec2-4.yaml b/.github/workflows/terraform-aws-ec2-4.yaml index fac2727..96eeb63 100644 --- a/.github/workflows/terraform-aws-ec2-4.yaml +++ b/.github/workflows/terraform-aws-ec2-4.yaml @@ -1,101 +1,101 @@ -# name: "Terraform Pipeline Provision EC2" +name: "Terraform Pipeline Provision EC2" -# on: -# push: -# branches: ['master' , 'main'] -# pull_request: -# branches: ['master', 'main'] +on: + push: + branches: ['master' , 'main'] + pull_request: + branches: ['master', 'main'] -# permissions: -# contents: write +permissions: + contents: write -# env: -# # verbosity setting for Terraform logs -# TF_LOG: INFO -# # Credentials for deployment to AWS -# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} -# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} -# TF_CLOUD_ORGANIZATION: "prodxcloud" -# TF_WORKSPACE: "prodxcloud" -# TF_API_TOKEN: ${{ secrets.TF_API_TOKEN}} -# CONFIG_DIRECTORY: "./deployments/terraform/terraform-aws-ec2-tf/terraform/" +env: + # verbosity setting for Terraform logs + TF_LOG: INFO + # Credentials for deployment to AWS + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + TF_CLOUD_ORGANIZATION: "prodxcloud" + TF_WORKSPACE: "prodxcloud" + TF_API_TOKEN: ${{ secrets.TF_API_TOKEN}} + CONFIG_DIRECTORY: "./deployments/terraform/terraform-aws-ec2-tf/terraform/" -# jobs: -# terraform: -# name: "Terraform Pipeline Provision EC2 with S3 Bucket" -# runs-on: ubuntu-latest -# defaults: -# run: -# shell: bash -# # We keep Terraform files in the terraform directory. -# working-directory: ./deployments/terraform/terraform-aws-ec2-tf/terraform +jobs: + terraform: + name: "Terraform Pipeline Provision EC2 with S3 Bucket" + runs-on: ubuntu-latest + defaults: + run: + shell: bash + # We keep Terraform files in the terraform directory. + working-directory: ./deployments/terraform/terraform-aws-ec2-tf/terraform -# steps: -# - name: Checkout the repository to the runner -# uses: actions/checkout@v2 + steps: + - name: Checkout the repository to the runner + uses: actions/checkout@v2 -# - name: Setup Terraform with specified version on the runner -# uses: hashicorp/setup-terraform@v2 -# with: -# terraform_version: 1.3.0 + - name: Setup Terraform with specified version on the runner + uses: hashicorp/setup-terraform@v2 + with: + terraform_version: 1.3.0 -# - name: Terraform init -# id: init -# run: terraform init -lock=false -# # env: -# # TF_CLI_ARGS_init: '-backend-config="token=${{ secrets.TF_API_TOKEN }}"' + - name: Terraform init + id: init + run: terraform init -lock=false + # env: + # TF_CLI_ARGS_init: '-backend-config="token=${{ secrets.TF_API_TOKEN }}"' -# - name: Terraform format -# id: fmt -# run: terraform fmt + - name: Terraform format + id: fmt + run: terraform fmt -# - name: Terraform validate -# id: validate -# run: terraform validate -# env: -# GITHUB_TOKEN: ${{ secrets.G_TOKEN}} -# TFE_TOKEN: ${{ secrets.TF_API_TOKEN }} + - name: Terraform validate + id: validate + run: terraform validate + env: + GITHUB_TOKEN: ${{ secrets.G_TOKEN}} + TFE_TOKEN: ${{ secrets.TF_API_TOKEN }} -# # - uses: actions/github-script@v6 -# # # if: github.event_name == 'pull_request' -# # env: -# # PLAN: "terraform\n${{ steps.plan.outputs.stdout }}" -# # with: -# # script: | -# # const output = `#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\` -# # #### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\` -# # #### Terraform Validation 🤖\`${{ steps.validate.outcome }}\` -# # #### Terraform Plan 📖\`${{ steps.plan.outcome }}\` + # - uses: actions/github-script@v6 + # # if: github.event_name == 'pull_request' + # env: + # PLAN: "terraform\n${{ steps.plan.outputs.stdout }}" + # with: + # script: | + # const output = `#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\` + # #### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\` + # #### Terraform Validation 🤖\`${{ steps.validate.outcome }}\` + # #### Terraform Plan 📖\`${{ steps.plan.outcome }}\` -# #
Show Plan + #
Show Plan -# # \`\`\`\n -# # ${process.env.PLAN} -# # \`\`\` + # \`\`\`\n + # ${process.env.PLAN} + # \`\`\` -# #
-# # *Pushed by: @${{ github.actor }}, Action: \`${{ github.event_name }}\`*`; + #
+ # *Pushed by: @${{ github.actor }}, Action: \`${{ github.event_name }}\`*`; -# # github.rest.issues.createComment({ -# # issue_number: context.issue.number, -# # owner: context.repo.owner, -# # repo: context.repo.repo, -# # body: output -# # }) + # github.rest.issues.createComment({ + # issue_number: context.issue.number, + # owner: context.repo.owner, + # repo: context.repo.repo, + # body: output + # }) -# # - name: Terraform Plan Status -# # if: steps.plan.outcome == 'failure' -# # run: exit 1 + # - name: Terraform Plan Status + # if: steps.plan.outcome == 'failure' + # run: exit 1 -# - name: Terraform Apply -# # if: github.ref == 'refs/heads/master' && github.event_name == 'push' -# run: terraform apply -auto-approve -input=false -lock=false -# env: -# TFE_TOKEN: ${{ secrets.TF_API_TOKEN }} + # - name: Terraform Apply + # # if: github.ref == 'refs/heads/master' && github.event_name == 'push' + # run: terraform apply -auto-approve -input=false -lock=false + # env: + # TFE_TOKEN: ${{ secrets.TF_API_TOKEN }} -# # - name: Terraform Destroy All Resources -# # # if: github.ref == 'refs/heads/master' && github.event_name == 'push' -# # run: terraform destroy -auto-approve -input=false -lock=false -# # env: -# # TFE_TOKEN: ${{ secrets.TF_API_TOKEN }} + - name: Terraform Destroy All Resources + # if: github.ref == 'refs/heads/master' && github.event_name == 'push' + run: terraform destroy -auto-approve -input=false -lock=false + env: + TFE_TOKEN: ${{ secrets.TF_API_TOKEN }}