Skip to content

Commit 4f1c94b

Browse files
authored
fix(crossRegionReference): error message missing stack information (#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*
1 parent 767ac65 commit 4f1c94b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

packages/@aws-cdk/custom-resource-handlers/lib/core/cross-region-ssm-writer-handler/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ async function throwIfAnyInUse(ssm: SSM, parameters: CrossRegionExports): Promis
102102
}));
103103

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

packages/@aws-cdk/custom-resource-handlers/test/core/cross-region-ssm-writer-handler.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable import/no-extraneous-dependencies */
22
import { InvalidResourceId } from '@aws-sdk/client-ssm';
3-
import { SSM_EXPORT_PATH_PREFIX } from '../../lib/core/types';
43
import { handler } from '../../lib/core/cross-region-ssm-writer-handler/index';
4+
import { SSM_EXPORT_PATH_PREFIX } from '../../lib/core/types';
55

66
let mockPutParameter: jest.Mock = jest.fn() ;
77
let mocklistTagsForResource: jest.Mock = jest.fn();
@@ -96,7 +96,7 @@ describe('cross-region-ssm-writer entrypoint', () => {
9696
});
9797

9898
// THEN
99-
await expect(handler(event)).rejects.toThrow(/Exports cannot be updated/);
99+
await expect(handler(event)).rejects.toThrow('Exports cannot be updated: \n/cdk/exports/MyStack/MyExport is in use by stack(s) MyStack');
100100
});
101101

102102
test('Create event does not throw for new parameters', async () => {

0 commit comments

Comments
 (0)