Skip to content

Commit

Permalink
DAT-17834 Ephemeral AWS infra for liquibase-test-harness (#220)
Browse files Browse the repository at this point in the history
* 🔧 (.github/workflows/ephemeral-cloud-infra.yml): add support for deploying or destroying the aws test harness infrastructure by introducing a new input variable and setting the corresponding environment variable for Terraform deployment.

* 🔧 (ephemeral-cloud-infra.yml): Add support for deploying or destroying various AWS infrastructure resources such as aws_postgresql, aws_oracle, aws_mariadb, aws_aurora_mysql, aws_mssql, and aws_aurora_postgres. Update environment variable names and corresponding inputs to reflect the changes.

* 📝 (.github/workflows/ephemeral-cloud-infra.yml): update liquibase-infrastructure repository reference to DAT-17834 branch instead of master for better tracking and version control.

* 🔧 (.github/workflows/ephemeral-cloud-infra.yml): pass run_id and run_repo variables to terraform destroy command for better tracking and debugging purposes

* 🔧 (ephemeral-cloud-infra.yml): add support for deploying or destroying the aws_mysql infrastructure by setting TF_VAR_create_aws_mysql based on the inputs provided

* 🔧 (ephemeral-cloud-infra.yml): remove unnecessary enable and disable commands to streamline workflow execution and avoid potential conflicts

* 📝 (.github/workflows/ephemeral-cloud-infra.yml): update checkout ref to 'master' branch for liquibase-infrastructure repository to fix workflow issue

* 🔧 (ephemeral-cloud-infra.yml): Update workflow conditions to always run artifact upload and download steps when deploying or destroying ephemeral stack
  • Loading branch information
jandroav authored May 31, 2024
1 parent 603425b commit e3d587e
Showing 1 changed file with 47 additions and 9 deletions.
56 changes: 47 additions & 9 deletions .github/workflows/ephemeral-cloud-infra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,41 @@ on:
required: false
type: boolean
default: false
aws_postgresql:
description: 'Deploy or destroy the aws_postgresql infrastructure'
required: false
type: boolean
default: false
aws_oracle:
description: 'Deploy or destroy the aws_oracle infrastructure'
required: false
type: boolean
default: false
aws_mariadb:
description: 'Deploy or destroy the aws_mariadb infrastructure'
required: false
type: boolean
default: false
aws_aurora_mysql:
description: 'Deploy or destroy the aws_aurora_mysql infrastructure'
required: false
type: boolean
default: false
aws_mssql:
description: 'Deploy or destroy the aws_mssql infrastructure'
required: false
type: boolean
default: false
aws_aurora_postgres:
description: 'Deploy or destroy the aws_aurora_postgres infrastructure'
required: false
type: boolean
default: false
aws_mysql:
description: 'Deploy or destroy the aws_mysql infrastructure'
required: false
type: boolean
default: false
stack_id:
description: 'The stack ID to destroy'
required: false
Expand Down Expand Up @@ -82,7 +117,7 @@ jobs:
echo "stack_id=$(terraform output -raw ephemeral_stack_id)" >> "$GITHUB_OUTPUT"
- name: Upload Terraform state as artifact
if: ${{ inputs.deploy }}
if: ${{ inputs.deploy && always()}}
uses: actions/upload-artifact@v4
with:
name: terraform-state
Expand All @@ -97,9 +132,15 @@ jobs:
echo "resources_id=$ID" >> "$GITHUB_OUTPUT"
spacectl stack environment setvar --id $EPHEMERAL_STACK_ID TF_VAR_stack_id $ID
spacectl stack environment setvar --id $EPHEMERAL_STACK_ID TF_VAR_create_dynamodb ${{ inputs.dynamodb }}
spacectl stack environment setvar --id $EPHEMERAL_STACK_ID TF_VAR_create_documentdb ${{ inputs.documentdb }}
spacectl stack environment setvar --id $EPHEMERAL_STACK_ID TF_VAR_create_documentdb ${{ inputs.documentdb }}
spacectl stack environment setvar --id $EPHEMERAL_STACK_ID TF_VAR_create_aws_postgresql ${{ inputs.aws_postgresql }}
spacectl stack environment setvar --id $EPHEMERAL_STACK_ID TF_VAR_create_aws_oracle ${{ inputs.aws_oracle }}
spacectl stack environment setvar --id $EPHEMERAL_STACK_ID TF_VAR_create_aws_mariadb ${{ inputs.aws_mariadb }}
spacectl stack environment setvar --id $EPHEMERAL_STACK_ID TF_VAR_create_aws_aurora_mysql ${{ inputs.aws_aurora_mysql }}
spacectl stack environment setvar --id $EPHEMERAL_STACK_ID TF_VAR_create_aws_mssql ${{ inputs.aws_mssql }}
spacectl stack environment setvar --id $EPHEMERAL_STACK_ID TF_VAR_create_aws_aurora_postgres ${{ inputs.aws_aurora_postgres }}
spacectl stack environment setvar --id $EPHEMERAL_STACK_ID TF_VAR_create_aws_mysql ${{ inputs.aws_mysql }}
spacectl stack deploy --id $EPHEMERAL_STACK_ID --auto-confirm
spacectl stack disable --id $EPHEMERAL_STACK_ID
- name: Destroy ephemeral infra
continue-on-error: true
Expand All @@ -108,20 +149,17 @@ jobs:
if: ${{ inputs.destroy }}
working-directory: test-automation-ephemeral/infra
run: |
spacectl stack enable --id ${{ inputs.stack_id }}
spacectl stack task --id ${{ inputs.stack_id }} --tail "terraform destroy -refresh=false -parallelism=10 -auto-approve" || true
spacectl stack disable --id ${{ inputs.stack_id }}
- name: Download Terraform state
if: ${{ inputs.destroy }}
if: ${{ inputs.destroy && always()}}
uses: actions/download-artifact@v4
with:
name: terraform-state
path: test-automation-ephemeral/stack

- name: Destroy ephemeral stack
if: ${{ inputs.destroy }}
if: ${{ inputs.destroy && always()}}
working-directory: test-automation-ephemeral/stack
run: |
spacectl stack enable --id ${{ inputs.stack_id }}
terraform destroy -auto-approve
terraform destroy -auto-approve -var "run_id=${{ github.run_id }}" -var "run_repo=${{ github.repository }}"

0 comments on commit e3d587e

Please sign in to comment.