aws / aws/aws-cdk-cli

cli: cdk deploy returns ok (exit code 0) if DELETE_FAILED

Open
#1,439 5 comments 0 reactions 0 assignees View on GitHub
bug effort/medium p2
Dominant language
TypeScript
Stars
105
Forks
122
Avg merge
1d 17h
Merged PRs (30d)
71

Description

### Describe the bug

I am using cdk deploy resources in an github actions pipeline.
Creating I "new" resource may force us to allow the pipeline role to build the resource (e.g. cloudwatch:PutMetricAlarm)
Removing this resource from the stack then needs the deletion action (e.g. cloudwatch:DeleteAlarm)
Sometime we forget to add the deletion action when adding the build action.

If we later remove the construct from the stack it cannot be deleted and we do not notice because cdk deploy does not throw an error.
The logs show cloudformation not able to delete the resource "DELETE_FAILED", but since the exit code of "cdk deploy" is 0 the pipeline continues.

### Expected Behavior

"cdk deploy" returns exit code != 0 if DELETE_FAILED

### Current Behavior

"cdk deploy" returns exit code = 0 if DELETE_FAILED

### Reproduction Steps

How to reproduce:
- I deploy a stack containing a cloudwatch alarm
- I remove the alarm from the stack
- I deploy the change (cdk deploy)
- Cloudformation tries to delete the alarm but gets DELETE_FAILED (in this case because my deployment role is only allowed to create but not delete the alarm)
- cdk deploy returns with exit code 0 and pipeline continues
- cloudformation stack shows status "Update successful. One or more resources could not be deleted."

### Possible Solution

"cdk deploy" returns exit code = 0 if DELETE_FAILED

### Additional Information/Context

_No response_

### CDK CLI Version

2.39.0

### Framework Version

_No response_

### Node.js Version

v18.0.0

### OS

Ubuntu, iOS

### Language

Typescript

### Language Version

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.