How to cleanup resources when a CodePipeline stage execution fails?

0

I like to implement an integration test stage as part of a CodePipeline CI/CD pipeline. Within this stage I expect to have two actions: 1) deploy the code to an integration environment using CloudFormation and 2) run a suite of integration tests against this deployment. After that the pipeline would move on to other stages like deploying to production for example.

Now assume that the integration test suite fails. How can I ensure that the deployed resources are cleaned up? All documentation and examples I've seen so far don't address this scenario.

Sub-question: Would you recommend having a long-lived integration environment that changes alongside production or would you rather create a fresh integration stack from scratch for each pipeline execution? Arguments for the former would be that you would test the actual stack update that would also be applied to the production stack and it would also be faster if your stack contains resources that take a while to create (DynamoDB tables for example). The drawback would be that in case the integration test suite fails the cleanup would need to revert the applied change set instead of just tearing down the entire stack.

Martin
질문됨 2년 전260회 조회
1개 답변
1

Hey - CodePipeline events can be monitored so that a failure could trigger an action. There is an existing pattern for custom triggers for AWS CodePipeline with AWS Lambda and Amazon CloudWatch Events.

As for your second question, you may also want to consider the costs of running a long-lived integration environment.

profile pictureAWS
Jake
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠