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

fix(core): cross region ssm writer update #23356

Merged
merged 2 commits into from Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -30,9 +30,13 @@ export async function handler(event: AWSLambda.CloudFormationCustomResourceEvent
const removedExports = except(oldExports, exports);
await throwIfAnyInUse(ssm, removedExports);
// if the ones we are removing are not in use then delete them
await ssm.deleteParameters({
Names: Object.keys(removedExports),
}).promise();
// skip if no export names are to be deleted
const removedExportsNames = Object.keys(removedExports);
if (removedExportsNames.length > 0) {
await ssm.deleteParameters({
Names: removedExportsNames,
}).promise();
}

// also throw an error if we are creating a new export that already exists for some reason
await throwIfAnyInUse(ssm, newExports);
Expand Down
Expand Up @@ -177,6 +177,7 @@ describe('cross-region-ssm-writer entrypoint', () => {
});
expect(mockPutParameter).toHaveBeenCalledTimes(1);
expect(mocklistTagsForResource).toHaveBeenCalledTimes(1);
expect(mockDeleteParameters).toHaveBeenCalledTimes(0);
});

test('removed exports are deleted', async () => {
Expand Down