Skip to content

Update Terraform aws to v5.41.0 - autoclosed #121

Update Terraform aws to v5.41.0 - autoclosed

Update Terraform aws to v5.41.0 - autoclosed #121

Workflow file for this run

name: AWS Deployment Workflow
on:
- push
- pull_request
env:
AWS_REGION: "us-east-2"
permissions:
id-token: write
issues: write
pull-requests: write
contents: write
jobs:
do_the_cloud:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-terraform@v3
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::260656080889:role/github_wbip
role-session-name: wbip_deploy
aws-region: ${{ env.AWS_REGION }}
- name: Core Infra- Terraform Format
id: fmt
run: terraform -chdir=terraform/core_infra fmt -check
continue-on-error: true
- name: Core Infra-Terraform Init
id: init
run: terraform -chdir=terraform/core_infra init
- name: Core Infra- Terraform Validate
id: validate
run: terraform -chdir=terraform/core_infra validate -no-color
continue-on-error: true
- name: Core Infra- Terraform Plan
id: plan
run: terraform -chdir=terraform/core_infra plan -no-color
continue-on-error: true
- name: Comment on PR
uses: actions/github-script@v7
if: ${{ github.event_name == 'pull_request' }}
env:
PLAN: "terraform\n${{ steps.plan.outputs.stdout }}"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const output = `#### Core Infra Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\`
#### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\`
#### Terraform Validation 🤖\`${{ steps.validate.outcome }}\`
<details><summary>Validation Output</summary>
\`\`\`\n
${{ steps.validate.outputs.stdout }}
\`\`\`
</details>
#### Terraform Plan 📖\`${{ steps.plan.outcome }}\`
<details><summary>Show Plan</summary>
\`\`\`\n
${process.env.PLAN}
\`\`\`
</details>
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.tf_actions_working_dir }}\`, Workflow: \`${{ github.workflow }}\`*`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})
- name: Fail for TF fmt failure
if: ${{ steps.fmt.outcome == 'failure'}}
uses: actions/github-script@v7
with:
script: |
core.setFailed('`terraform fmt` failed!')
- name: Fail for TF Validate failure
if: ${{ steps.validate.outcome == 'failure'}}
uses: actions/github-script@v7
with:
script: |
core.setFailed('`terraform validate` failed!')
- name: Fail for TF Plan failure
if: ${{ steps.plan.outcome == 'failure'}}
uses: actions/github-script@v7
with:
script: |
core.setFailed('`terraform plan` failed!')
- name: Core Infra- Terraform Apply
if: ${{ github.ref == 'refs/heads/main' }}
id: apply
run: terraform -chdir=terraform/core_infra apply -no-color -auto-approve
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Build and tag image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: wbip_wrapper
IMAGE_TAG: ${{ github.sha }}
run: |
cd docker
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
cd -
- name: push image to ECR
if: ${{ github.ref == 'refs/heads/main' }}
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: wbip_wrapper
IMAGE_TAG: ${{ github.sha }}
run: |
cd docker
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
cd -