Skip to content

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

@elliotsegler

Description

@elliotsegler

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

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.investigatingThis issue is being investigated and/or work is in progress to resolve the issue.package/toolsRelated to AWS CDK Tools or CLI

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions