ci: checks the status of the rollback_complete_stack #331
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: ci | |
on: | |
push: | |
paths-ignore: | |
- '**.md' | |
env: | |
AWS_REGION: us-east-1 | |
jobs: | |
test-create-complete-stack-status: | |
runs-on: ubuntu-latest | |
env: | |
CFN_TEMPLATES: "./test/stacks/test-create-complete-stack.yml\n" | |
steps: | |
- name: clone the repo | |
uses: actions/checkout@v3 | |
- name: configure aws credentials | |
uses: aws-actions/configure-aws-credentials@v1.5.3 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ env.AWS_REGION }} | |
- name: validates all cloudformation templates | |
run: | | |
printf "${{ env.CFN_TEMPLATES }}" | while read template; do | |
aws cloudformation validate-template \ | |
--template-body="file://$template" | |
done | |
- name: configure the environment | |
run: | | |
echo "STACK_NAME=test-create-complete-cfn-check-failed-status" >> $GITHUB_ENV | |
echo "CFN_CHECK_STATUS_CREATE_COMPLETE_BUCKET_NAME=test-create-complete-cfn-check-failed-status-bucket" >> $GITHUB_ENV | |
- name: deploy the create-complete-cfn-check-failed-status stack to "force" CREATE_COMPLETE status | |
run: | | |
aws cloudformation deploy \ | |
--template-file="test/stacks/test-create-complete-stack.yml" \ | |
--stack-name=${{ env.STACK_NAME }} \ | |
--parameter-overrides \ | |
CfnCheckStatusBucketName=${{ env.CFN_CHECK_STATUS_CREATE_COMPLETE_BUCKET_NAME }} \ | |
--capabilities=CAPABILITY_NAMED_IAM \ | |
--no-fail-on-empty-changeset | |
- name: test cfn-check-failed-status with a cloudformation stack in CREATE_COMPLETE status | |
uses: ./ | |
id: checkstatus_create_complete | |
with: | |
cfn-stack-name: ${{ env.STACK_NAME }} | |
- name: validate output message of the status check | |
run: | | |
echo "${{ steps.checkstatus_create_complete.outputs.message }}" | |
- name: delete the create-complete-cfn-check-failed-status test stack | |
run: | | |
aws cloudformation delete-stack \ | |
--stack-name=${{ env.STACK_NAME }} | |
aws s3 rb s3://${{ env.CFN_CHECK_STATUS_CREATE_COMPLETE_BUCKET_NAME }} --force | |
test-rollback-complete-stack-status: | |
runs-on: ubuntu-latest | |
needs: test-create-complete-stack-status | |
env: | |
CFN_TEMPLATES: "./test/stacks/test-rollback-complete-stack.yml\n" | |
steps: | |
- name: clone the repo | |
uses: actions/checkout@v3 | |
- name: configure aws credentials | |
uses: aws-actions/configure-aws-credentials@v1.5.3 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ env.AWS_REGION }} | |
- name: validates all cloudformation templates | |
run: | | |
printf "${{ env.CFN_TEMPLATES }}" | while read template; do | |
aws cloudformation validate-template \ | |
--template-body="file://$template" | |
done | |
- name: configure the environment with two identical bucket name environment variables | |
run: | | |
echo "STACK_NAME=test-rollback-complete-cfn-check-failed-status" >> $GITHUB_ENV | |
echo "CFN_CHECK_STATUS_CREATE_FAILED_BUCKET_NAME=test-rollback-complete-cfn-check-failed-status-bucket" >> $GITHUB_ENV | |
echo "CFN_CHECK_STATUS_CREATE_FAILED_BUCKET_NAME_2=test-rollback-complete-cfn-check-failed-status-bucket" >> $GITHUB_ENV | |
- name: deploy the rollback-complete-cfn-check-failed-status stack | |
continue-on-error: true | |
run: | | |
aws cloudformation deploy \ | |
--template-file="test/stacks/test-rollback-complete-stack.yml" \ | |
--stack-name=${{ env.STACK_NAME }} \ | |
--parameter-overrides \ | |
CfnCheckStatusBucketName=${{ env.CFN_CHECK_STATUS_CREATE_FAILED_BUCKET_NAME }} \ | |
--capabilities=CAPABILITY_NAMED_IAM \ | |
--no-fail-on-empty-changeset | |
- name: test cfn-check-failed-status with a cloudformation stack in ROLLBACK_COMPLETE status | |
uses: ./ | |
id: checkstatus_rollback_complete | |
with: | |
cfn-stack-name: ${{ env.STACK_NAME }} | |
- name: delete the rollback-complete-cfn-check-failed-status test stack | |
run: | | |
aws cloudformation delete-stack \ | |
--stack-name=${{ env.STACK_NAME }} | |
- name: validate output message of the status check | |
run: | | |
echo "${{ steps.checkstatus_rollback_complete.outputs.message }}" | |
test-delete-failed-stack-status: | |
runs-on: ubuntu-latest | |
needs: test-rollback-complete-stack-status | |
env: | |
CFN_TEMPLATES: "./test/stacks/test-delete-failed-stack.yml\n" | |
steps: | |
- name: clone the repo | |
uses: actions/checkout@v3 | |
- name: configure aws credentials | |
uses: aws-actions/configure-aws-credentials@v1.5.3 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ env.AWS_REGION }} | |
- name: validates all cloudformation templates | |
run: | | |
printf "${{ env.CFN_TEMPLATES }}" | while read template; do | |
aws cloudformation validate-template \ | |
--template-body="file://$template" | |
done | |
- name: configure the environment | |
run: | | |
echo "STACK_NAME=test-delete-failed-cfn-check-failed-status" >> $GITHUB_ENV | |
echo "CFN_CHECK_STATUS_DELETE_FAILED_A_BUCKET_NAME=test-delete-failed-cfn-check-failed-status-bucket-a" >> $GITHUB_ENV | |
echo "CFN_CHECK_STATUS_DELETE_FAILED_B_BUCKET_NAME=test-delete-failed-cfn-check-failed-status-bucket-b" >> $GITHUB_ENV | |
- name: deploy the cfn stack | |
run: | | |
aws cloudformation deploy \ | |
--template-file="test/stacks/test-delete-failed-stack.yml" \ | |
--stack-name=${{ env.STACK_NAME }} \ | |
--parameter-overrides \ | |
CfnCheckStatusABucketName=${{ env.CFN_CHECK_STATUS_DELETE_FAILED_A_BUCKET_NAME }} \ | |
CfnCheckStatusBBucketName=${{ env.CFN_CHECK_STATUS_DELETE_FAILED_B_BUCKET_NAME }} \ | |
--capabilities=CAPABILITY_NAMED_IAM \ | |
--no-fail-on-empty-changeset | |
- name: populate buckets of the test stack | |
run: | | |
aws s3 cp test/fixtures/example.txt s3://${{ env.CFN_CHECK_STATUS_DELETE_FAILED_A_BUCKET_NAME }}/ | |
aws s3 cp test/fixtures/example.txt s3://${{ env.CFN_CHECK_STATUS_DELETE_FAILED_B_BUCKET_NAME }}/ | |
- name: deletes test stack (no --force) to force DELETE_FAILED status | |
continue-on-error: true | |
run: | | |
aws cloudformation delete-stack --stack-name=${{ env.STACK_NAME }} | |
- name: test cfn-check-failed-status with a cloudformation stack in DELETE_FAILED status | |
uses: ./ | |
id: checkstatus_delete_failed | |
with: | |
cfn-stack-name: ${{ env.STACK_NAME }} | |
- name: validate output message of the status check | |
run: | | |
echo "${{ steps.checkstatus_delete_failed.outputs.message }}" | |
test-update-rollback-complete-stack-status: | |
runs-on: ubuntu-latest | |
needs: test-delete-failed-stack-status | |
env: | |
CFN_TEMPLATES: "./test/stacks/test-update-rollback-complete-stack.yml\n./test/stacks/test-update-rollback-complete-stack0.yml\n" | |
steps: | |
- name: clone the repo | |
uses: actions/checkout@v3 | |
- name: configure aws credentials | |
uses: aws-actions/configure-aws-credentials@v1.5.3 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ env.AWS_REGION }} | |
- name: validates all cloudformation templates | |
run: | | |
printf "${{ env.CFN_TEMPLATES }}" | while read template; do | |
aws cloudformation validate-template \ | |
--template-body="file://$template" | |
done | |
- name: configure the environment | |
run: | | |
echo "STACK_NAME=test-update-rollback-complete-cfn-check-failed-status" >> $GITHUB_ENV | |
echo "CFN_CHECK_STATUS_UPDATE_ROLLBACK_COMPLETE_BUCKET_NAME=test-update-rollback-complete-cfn-check-failed-status-bucket" >> $GITHUB_ENV | |
- name: deploy the update-rollback-complete-cfn-check-failed-status stack | |
run: | | |
aws cloudformation deploy \ | |
--template-file="test/stacks/test-update-rollback-complete-stack.yml" \ | |
--stack-name=${{ env.STACK_NAME }} \ | |
--parameter-overrides \ | |
CfnCheckStatusBucketName=${{ env.CFN_CHECK_STATUS_UPDATE_ROLLBACK_COMPLETE_BUCKET_NAME }} \ | |
--capabilities=CAPABILITY_NAMED_IAM \ | |
--no-fail-on-empty-changeset | |
- name: redeploy the update-rollback-complete-cfn-check-failed-status stack to force UPDATE_ROLLBACK_COMPLETE status | |
continue-on-error: true | |
run: | | |
aws cloudformation deploy \ | |
--template-file="test/stacks/test-update-rollback-complete-stack0.yml" \ | |
--stack-name=${{ env.STACK_NAME }} \ | |
--parameter-overrides \ | |
CfnCheckStatusBucketName=${{ env.CFN_CHECK_STATUS_UPDATE_ROLLBACK_COMPLETE_BUCKET_NAME }} \ | |
--capabilities=CAPABILITY_NAMED_IAM \ | |
--no-fail-on-empty-changeset | |
- name: test cfn-check-failed-status with a cloudformation stack in UPDATE_ROLLBACK_COMPLETE status | |
uses: ./ | |
id: checkstatus_update_rollback_complete | |
with: | |
cfn-stack-name: ${{ env.STACK_NAME }} | |
- name: validate output message of the status check | |
run: | | |
echo "${{ steps.checkstatus_update_rollback_complete.outputs.message }}" |