(cdk-cli): Difficult to track `cdk deploy` issues
Describe the bug
Hi, this is between a bug and an annoyance.
When running cdk deploy , any error (in red) will make the deployment to fail.
The error is key to finding a solution.
But the real error disappears (sometimes too quickly) so we need to be trained into:
- See red, pless control-C to halt execution, copy error and do the research to fix it.
This need not to be this way.
Expected Behavior
The summary need to include all the errors.
Current Behavior
Dev/MyStack (Dev-MyStack) failed: Error: The stack named Dev-MyStack failed to deploy: UPDATE_ROLLBACK_COMPLETE
at FullCloudFormationDeployment.monitorDeployment (/Users/user/.nvm/versions/node/v18.17.1/lib/node_modules/aws-cdk/lib/index.js:443:10236)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.deployStack2 [as deployStack] (/Users/user/.nvm/versions/node/v18.17.1/lib/node_modules/aws-cdk/lib/index.js:446:153718)
at async /Users/user/.nvm/versions/node/v18.17.1/lib/node_modules/aws-cdk/lib/index.js:446:137166
Reproduction Steps
(best way to reproduce would be to run into this yourself) (one case: remove a resource that's needed by another stack)
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.93.0 (build 724bd01)
Framework Version
No response
Node.js Version
v18.17.1
OS
Mac OS 13.4
Language
Python
Language Version
Python (3.11)
Other information
No response
I think I know what you're describing - to see the errors you should be able to go to your CloudFormation stack in the console to view the error message in the events tab as a workaround.
The error message in the console is handled by the API call we make to CloudFormation, I'm not sure how easy it would be to make the message persist in the terminal, but it would certainly be helpful if the descriptive error never disappeared
+1 on this one. There's also no log file in cdk.out that stores these error messages. I have to redeploy and quickly copy the error before it gets wiped off the terminal
I often end up going to the events tab of the CloudFormation web console to quickly identify which resource failed, and for what reason. This might be the best way to show this information (the resource name, type, event message) at the end of the deployment, followed by the stack trace
Identifying the resource is just one step. But if you don't know why it is failing, debugging can be very difficult.
this just started to happen to me.
Let's make 100% sure that the resource error is part of the exception that gets thrown. That way, there's no way it doesn't end up in the output.
I am unable to reproduce this bug - I tried by creating a CDK app with an S3 Bucket using a Bucket Name that already exists.
import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { Bucket } from 'aws-cdk-lib/aws-s3';
export class DeployErrorTestStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
new Bucket(this, 'my-bucket', {
bucketName: 'bucket-name-that-already-exists'
})
}
}
After running cdk deploy, I was able to clearly see the resource handler error message in the terminal:
✨ Synthesis time: 3.95s
DeployErrorTestStack: start: Building 0efe21d033e1151a570dc1e09d865c2022f184180b86db587e0373f8f9be0baa:current_account-current_region
DeployErrorTestStack: success: Built 0efe21d033e1151a570dc1e09d865c2022f184180b86db587e0373f8f9be0baa:current_account-current_region
DeployErrorTestStack: start: Publishing 0efe21d033e1151a570dc1e09d865c2022f184180b86db587e0373f8f9be0baa:current_account-current_region
DeployErrorTestStack: success: Published 0efe21d033e1151a570dc1e09d865c2022f184180b86db587e0373f8f9be0baa:current_account-current_region
Stack undefined
DeployErrorTestStack: deploying... [1/1]
DeployErrorTestStack: creating CloudFormation changeset...
10:42:52 AM | CREATE_FAILED | AWS::S3::Bucket | mybucket15D133BF
Resource handler returned message: "source-bucket-groundtruth-56 already exists (Service: S3, Status Code: 0, Request ID: null)" (RequestToken: 8aa26f87-c710-a554-a7f7
-8006b151ab09, HandlerErrorCode: AlreadyExists)
❌ DeployErrorTestStack failed: The stack named DeployErrorTestStack failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE: Resource handler returned message: "source-bucket-groundtruth-56 already exists (Service: S3, Status Code: 0, Request ID: null)" (RequestToken: 8aa26f87-c710-a554-a7f7-8006b151ab09, HandlerErrorCode: AlreadyExists)
@gabriels1234 @ethyaan @melhakim can any of you confirm whether you still encounter this bug? It may have been fixed in a more recent CDK version.
Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one.