Skip to content

Commit

Permalink
Add support for the aws-cn partition when validating notification ARNs.
Browse files Browse the repository at this point in the history
  • Loading branch information
LennartC committed Apr 4, 2024
1 parent b82320b commit c266fe1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/aws-cdk/lib/util/validate-notification-arn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
* Validate SNS topic arn
*/
export function validateSnsTopicArn(arn: string): boolean {
return /^arn:aws:sns:[a-z0-9\-]+:[0-9]+:[a-z0-9\-\_]+$/i.test(arn);
return /^arn:(?:aws|aws-cn):sns:[a-z0-9\-]+:[0-9]+:[a-z0-9\-\_]+$/i.test(arn);
}
5 changes: 5 additions & 0 deletions packages/aws-cdk/test/util/validate-notification-arn.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,10 @@ describe('validate sns arns', () => {
const arn = 'arn:aws:sns:eu-west-1:123456789876:foo-bar_baz';
expect(validateSnsTopicArn(arn)).toEqual(true);
});

test('AWS China partition', () => {
const arn = 'arn:aws-cn:sns:cn-northwest-1:123456789876:foo-bar';
expect(validateSnsTopicArn(arn)).toEqual(true);
});
});

0 comments on commit c266fe1

Please sign in to comment.