From 5d688024d8b8fb57ce01d615d3a20371d03972ee Mon Sep 17 00:00:00 2001 From: Joel Wembo Date: Fri, 12 Apr 2024 19:33:58 +0800 Subject: [PATCH] added services and upgraded insance type --- .github/workflows/terraform-aws-ec2-4.yaml | 166 +++++++++--------- .../terraform/variables.tf | 7 + 2 files changed, 90 insertions(+), 83 deletions(-) diff --git a/.github/workflows/terraform-aws-ec2-4.yaml b/.github/workflows/terraform-aws-ec2-4.yaml index ba80438..3358542 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 }} diff --git a/deployments/terraform/terraform-aws-ec2-tf/terraform/variables.tf b/deployments/terraform/terraform-aws-ec2-tf/terraform/variables.tf index e48c51a..59ef062 100644 --- a/deployments/terraform/terraform-aws-ec2-tf/terraform/variables.tf +++ b/deployments/terraform/terraform-aws-ec2-tf/terraform/variables.tf @@ -121,6 +121,13 @@ variable "ingress_rules" { "to_port" = "8585" "protocol" = "tcp" "cidr_blocks" = ["0.0.0.0/0"] + }, + "Django alt Application port" = { + "description" = "For Django alt port" + "from_port" = "8000" + "to_port" = "8000" + "protocol" = "tcp" + "cidr_blocks" = ["0.0.0.0/0"] } "All Ports" = {