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(route53resolver): FirewallDomainList throws with wildcard domains #16538

Merged
merged 3 commits into from
Sep 21, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ export abstract class FirewallDomains {
*/
public static fromList(list: string[]): FirewallDomains {
for (const domain of list) {
if (!/^[\w-.]+$/.test(domain)) {
throw new Error(`Invalid domain: ${domain}. Valid characters: A-Z, a-z, 0-9, _, -, .`);
if (!/^([\w-.]{1,255}|\*[\w-.]{1,254})$/.test(domain)) {
throw new Error(`Invalid domain: ${domain}. Domain can optionally start with *. Max length of 255. Valid characters: A-Z, a-z, 0-9, _, -, .`);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,19 @@ beforeEach(() => {
test('domain list from strings', () => {
// WHEN
new FirewallDomainList(stack, 'List', {
domains: FirewallDomains.fromList(['first-domain.com', 'second-domain.net']),
domains: FirewallDomains.fromList([
'first-domain.com',
'second-domain.net',
'*.wildcard.com',
]),
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::Route53Resolver::FirewallDomainList', {
Domains: [
'first-domain.com',
'second-domain.net',
'*.wildcard.com',
],
});
});
Expand Down