Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(crossRegionReference): error logging for throwIfAnyInUse fails to log exports in use #29699

Closed
elliotsegler opened this issue Apr 3, 2024 · 3 comments · Fixed by #29961, rwlxxvii/containers#124 or rwlxxvii/containers#140 · May be fixed by NOUIY/aws-solutions-constructs#99 or NOUIY/aws-solutions-constructs#101
Assignees
Labels
bug This issue is a bug. investigating This issue is being investigated and/or work is in progress to resolve the issue. package/tools Related to AWS CDK Tools or CLI

Comments

@elliotsegler
Copy link

Describe the bug

Discovered whilst debugging an issue with cross-stack exports, it looks like the error message logic that would identify which exports are in use by which stack is broken.

if (tagResults.size > 0) {
const message: string = Object.entries(tagResults)
.map((result: [string, string[]]) => `${result[0]} is in use by stack(s) ${result[1].join(' ')}`)
.join('\n');
throw new Error(`Exports cannot be updated: \n${message}`);
}

In my case, there are tagResults but the results aren't mapped into the error message, so you just get a clear line in the error message.

Expected Behavior

The error message to identify which exports are in use by which stacks.

For example:

Received response status [FAILED] from custom resource. Message returned: Error: Exports cannot be updated:
/cdk/exports/MyTestExportStack/MyResourceExport is in use by stack(s) MyTestConsumerStack

at i (/var/task/index.js:4:10)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async P (/var/task/index.js:3:184)
at async Runtime.handler (/var/task/__entrypoint__.js:1:932)

Current Behavior

Error message doesn't include the content

Example

Received response status [FAILED] from custom resource. Message returned: Error: Exports cannot be updated:

at i (/var/task/index.js:4:10)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async P (/var/task/index.js:3:184)
at async Runtime.handler (/var/task/__entrypoint__.js:1:932)

this appears to be the case in a number of issues:
#27251
#28200
#24464
#27902

Reproduction Steps

Create a cross region stack that uses an export, and then try to destroy the exporting stack first

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.118.0 (build a40f2ec)

Framework Version

No response

Node.js Version

v18.9.0

OS

arn:aws:lambda:us-east-1::runtime:464db84005d4f68e67934a6df703e04e6e8782a50ec2882673a8e1c996ab814a

Language

TypeScript

Language Version

No response

Other information

No response

@elliotsegler elliotsegler added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 3, 2024
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Apr 3, 2024
@khushail khushail added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Apr 5, 2024
@khushail khushail self-assigned this Apr 5, 2024
andreialecu added a commit to andreialecu/aws-cdk that referenced this issue Apr 25, 2024
@andreialecu
Copy link
Contributor

PR at #29961 with fix.

@mergify mergify bot closed this as completed in #29961 Apr 26, 2024
mergify bot pushed a commit that referenced this issue Apr 26, 2024
…29961)

### Issue #29699

Closes #29699

### Reason for this change

The logic was incorrectly using `Object.entries()` on a Map. 

### Description of changes

This is a straighforward change to properly handle the map, and an update to tests.

### Description of how you validated changes

Updated test

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@aws-cdk-automation
Copy link
Collaborator

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.

@aws aws locked as resolved and limited conversation to collaborators Jul 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.