Skip to content

Commit

Permalink
fix(crossRegionReference): error message missing stack information (#…
Browse files Browse the repository at this point in the history
…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*
  • Loading branch information
andreialecu authored Apr 26, 2024
1 parent 767ac65 commit 4f1c94b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ async function throwIfAnyInUse(ssm: SSM, parameters: CrossRegionExports): Promis
}));

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(' ')}`)
const message: string = Array.from(tagResults.entries())
.map((result) => `${result[0]} is in use by stack(s) ${Array.from(result[1]).join(' ')}`)
.join('\n');
throw new Error(`Exports cannot be updated: \n${message}`);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable import/no-extraneous-dependencies */
import { InvalidResourceId } from '@aws-sdk/client-ssm';
import { SSM_EXPORT_PATH_PREFIX } from '../../lib/core/types';
import { handler } from '../../lib/core/cross-region-ssm-writer-handler/index';
import { SSM_EXPORT_PATH_PREFIX } from '../../lib/core/types';

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

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

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

0 comments on commit 4f1c94b

Please sign in to comment.