I want to create CodeDeploy deployments using AWS CDK. Currently, in the event that a deployment fails, the whole of the CDK stack is rolled back. Is it possible to ignore any failures of the deployment?
For example, here is the output from the cdk deploy
showing the rollback:
test-release-1: deploying...
test-release-1: creating CloudFormation changeset...
0/5 | 00:34:43 | CREATE_IN_PROGRESS | AWS::IAM::Role | test-release-1-CodeDeployRole (testrelease1CodeDeployRole533AAAB6)
0/5 | 00:34:43 | CREATE_IN_PROGRESS | AWS::CodeDeploy::Application | test-release-1-tls_proxy_ir (testrelease1tlsproxyir46F038FD)
0/5 | 00:34:43 | CREATE_IN_PROGRESS | AWS::CDK::Metadata | CDKMetadata
0/5 | 00:34:44 | CREATE_IN_PROGRESS | AWS::IAM::Role | test-release-1-CodeDeployRole (testrelease1CodeDeployRole533AAAB6) Resource creation Initiated
0/5 | 00:34:44 | CREATE_IN_PROGRESS | AWS::CodeDeploy::Application | test-release-1-tls_proxy_ir (testrelease1tlsproxyir46F038FD) Resource creation Initiated
1/5 | 00:34:44 | CREATE_COMPLETE | AWS::CodeDeploy::Application | test-release-1-tls_proxy_ir (testrelease1tlsproxyir46F038FD)
1/5 | 00:34:45 | CREATE_IN_PROGRESS | AWS::CDK::Metadata | CDKMetadata Resource creation Initiated
2/5 | 00:34:45 | CREATE_COMPLETE | AWS::CDK::Metadata | CDKMetadata
3/5 | 00:35:00 | CREATE_COMPLETE | AWS::IAM::Role | test-release-1-CodeDeployRole (testrelease1CodeDeployRole533AAAB6)
3/5 | 00:35:03 | CREATE_IN_PROGRESS | AWS::CodeDeploy::DeploymentGroup | test-release-1-tls_proxy_ir-cdk-test (testrelease1tlsproxyircdktest)
3/5 | 00:35:03 | CREATE_IN_PROGRESS | AWS::CodeDeploy::DeploymentGroup | test-release-1-tls_proxy_ir-cdk-test (testrelease1tlsproxyircdktest) Resource creation Initiated
4/5 | 00:35:34 | CREATE_FAILED | AWS::CodeDeploy::DeploymentGroup | test-release-1-tls_proxy_ir-cdk-test (testrelease1tlsproxyircdktest) Deployment d-7MWZ2VBK1 failed. Status=Failed
C:\Users\JOHN~1.TIP\AppData\Local\Temp\jsii-java-runtime8625275517600395680\jsii-runtime.js:7853:49
\_ Kernel._wrapSandboxCode (C:\Users\JOHN~1.TIP\AppData\Local\Temp\jsii-java-runtime8625275517600395680\jsii-runtime.js:8313:20)
\_ Kernel._create (C:\Users\JOHN~1.TIP\AppData\Local\Temp\jsii-java-runtime8625275517600395680\jsii-runtime.js:7853:26)
\_ Kernel.create (C:\Users\JOHN~1.TIP\AppData\Local\Temp\jsii-java-runtime8625275517600395680\jsii-runtime.js:7600:21)
\_ KernelHost.processRequest (C:\Users\JOHN~1.TIP\AppData\Local\Temp\jsii-java-runtime8625275517600395680\jsii-runtime.js:7388:28)
\_ KernelHost.run (C:\Users\JOHN~1.TIP\AppData\Local\Temp\jsii-java-runtime8625275517600395680\jsii-runtime.js:7328:14)
\_ Immediate._onImmediate (C:\Users\JOHN~1.TIP\AppData\Local\Temp\jsii-java-runtime8625275517600395680\jsii-runtime.js:7331:37)
\_ processImmediate (internal/timers.js:456:21)
4/5 | 00:35:35 | ROLLBACK_IN_PROGRESS | AWS::CloudFormation::Stack | test-release-1 The following resource(s) failed to create: [testrelease1tlsproxyircdktest]. . Rollback requested by user.
4/5 | 00:35:43 | DELETE_IN_PROGRESS | AWS::CodeDeploy::Application | test-release-1-tls_proxy_ir (testrelease1tlsproxyir46F038FD)
4/5 | 00:35:43 | DELETE_IN_PROGRESS | AWS::CDK::Metadata | CDKMetadata
4/5 | 00:35:44 | DELETE_IN_PROGRESS | AWS::CodeDeploy::DeploymentGroup | test-release-1-tls_proxy_ir-cdk-test (testrelease1tlsproxyircdktest)
5/5 | 00:35:44 | DELETE_COMPLETE | AWS::CodeDeploy::DeploymentGroup | test-release-1-tls_proxy_ir-cdk-test (testrelease1tlsproxyircdktest)
6/5 | 00:35:44 | DELETE_COMPLETE | AWS::CodeDeploy::Application | test-release-1-tls_proxy_ir (testrelease1tlsproxyir46F038FD)
6/5 | 00:35:44 | DELETE_IN_PROGRESS | AWS::IAM::Role | test-release-1-CodeDeployRole (testrelease1CodeDeployRole533AAAB6)
7/5 | 00:35:44 | DELETE_COMPLETE | AWS::CDK::Metadata | CDKMetadata
8/5 | 00:35:46 | DELETE_COMPLETE | AWS::IAM::Role | test-release-1-CodeDeployRole (testrelease1CodeDeployRole533AAAB6)
9/5 | 00:35:47 | ROLLBACK_COMPLETE | AWS::CloudFormation::Stack | test-release-1
In the event of a failed deployment, I just want the CDK stack to continue without error, i.e. no rollback. Is this possible and how do I achieve this?
There is an open GitHub issue for that feature in AWS-CDK
:
So setting up the rollback behavior is not something that can be set in CDK for now. You can do it in CLI (--disable-rollback or --rollback-configuration) if this would be any help.