Destroy HydroServer AWS Cloud Deployment #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Destroy HydroServer AWS Cloud Deployment | |
on: | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: 'Enter a deployment environment name.' | |
required: true | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
destroy-deployment: | |
runs-on: ubuntu-20.04 | |
environment: ${{ github.event.inputs.environment }} | |
defaults: | |
run: | |
working-directory: ./terraform/aws | |
steps: | |
- name: configureawscredentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/${{ vars.AWS_IAM_ROLE }} | |
role-session-name: create-hydroserver-resources | |
aws-region: ${{ vars.AWS_REGION }} | |
- name: Checkout Repo | |
uses: actions/checkout@v3 | |
with: | |
ref: main | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v1 | |
- name: Terraform Init | |
run: terraform init -backend-config="bucket=${{ vars.TERRAFORM_BUCKET }}" -backend-config="region=${{ vars.AWS_REGION }}" -backend-config="key=state/aws_application_${{ github.event.inputs.environment }}" | |
- name: Terraform Plan | |
id: plan | |
run: terraform plan -destroy -no-color -var instance="${{ github.event.inputs.environment }}" -var region="${{ vars.AWS_REGION }}" | |
continue-on-error: true | |
- name: Terraform Plan Status | |
if: steps.plan.outcome == 'failure' | |
run: exit 1 | |
- name: Terraform Apply | |
run: terraform apply -destroy -auto-approve -var instance="${{ github.event.inputs.environment }}" -var region="${{ vars.AWS_REGION }}" |