cleanup and rollback your code


Cleanup after Assembly Line Training

Having completed this training module successfully we can now rollback the deployed resources.

To roll back the CDK stacks we use command npx cdk destroy, however, the DynamoDb tables that were created are not deleted and the codebuild reports and report groups for the pipelines are also not terminated and if not deleted first will cause stack termination to fail.

For these reasons we will use scripts, located in the scripts folder, to remove these resources first.

  • Use awsp to authenticate your AWSCLI to the DEV Account to delete the DynamDB table:
    • run script ./scripts/cleanup-dynamodb-tables.sh
  • Use awsp to authenticate your AWSCLI to the TEST Account to delete the DynamDB table:
    • run script ./scripts/cleanup-dynamodb-tables.sh
  • Use awsp to authenticate your AWSCLI to the DEVOPS Account to delete the codebuild reports and report groups created for the pipelines for the dev and test stacks
    • run script ./scripts/cleanup-codebuild-reportgroups.sh

Now we can proceed to terminate the stacks:

  • Use npx cdk list to provide the names of the stacks to be rolled back, ie:

    • ProjectName-pipeline-dev-GLF
    • ProjectName-pipeline-test-GLF
    • ProjectName-pipeline-dev-GLF/ProjectName-Backend/API
    • ProjectName-pipeline-dev-GLF/ProjectName-Frontend/UI
    • ProjectName-pipeline-test-GLF/ProjectName-Backend/API
    • ProjectName-pipeline-test-GLF/ProjectName-Frontend/UI

To remove the deployed dev and test stack resources and pipelines from your Dev and Test Accounts execute:

  • npx cdk destroy ‘ProjectName’-pipeline-test-GLF/‘ProjectName’-Frontend/UI
  • npx cdk destroy ‘ProjectName’-pipeline-test-GLF/‘ProjectName’-Backend/API
  • npx cdk destroy ‘ProjectName’-pipeline-dev-GLF/‘ProjectName’-Frontend/UI
  • npx cdk destroy ‘ProjectName’-pipeline-dev-GLF/‘ProjectName’-Backend/API
  • Rollback both the test and dev pipeline stacks
  • npx cdk destroy --all - Message shows ‘ProjectName’-pipeline-dev-GLF: destroyed

All training resources should now be deleted