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(certificatemanager): DnsValidatedCertificate does not normalize domains with uppercase letters #26769

Closed
wants to merge 2 commits into from
Closed
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 @@ -177,8 +177,9 @@ export class DnsValidatedCertificate extends CertificateBase implements ICertifi

// https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/specifying-rrset-conditions.html
function addWildcard(domainName: string) {
if (domainName.startsWith('*.')) {
return domainName;
const domain = domainName.toLowerCase();
if (domain.startsWith('*.')) {
return domain;
}
return `*.${domainName}`;
return `*.${domain}`;
}
Original file line number Diff line number Diff line change
Expand Up @@ -352,3 +352,74 @@ testDeprecated('can set removal policy', () => {
CleanupRecords: 'true',
});
});

testDeprecated('normalizes domain names with uppercase characters for policy conditions', () => {
const stack = new Stack();

const exampleDotComZone = new PublicHostedZone(stack, 'ExampleDotCom', {
zoneName: 'example.com',
});

new DnsValidatedCertificate(stack, 'Certificate', {
domainName: 'TEST.example.com',
hostedZone: exampleDotComZone,
subjectAlternativeNames: ['TEST2.example.com'],
cleanupRoute53Records: true,
});

Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', {
PolicyName: 'CertificateCertificateRequestorFunctionServiceRoleDefaultPolicy3C8845BC',
Roles: [
{
Ref: 'CertificateCertificateRequestorFunctionServiceRoleC04C13DA',
},
],
PolicyDocument: {
Version: '2012-10-17',
Statement: [
{
Action: [
'acm:RequestCertificate',
'acm:DescribeCertificate',
'acm:DeleteCertificate',
'acm:AddTagsToCertificate',
],
Effect: 'Allow',
Resource: '*',
},
{
Action: 'route53:GetChange',
Effect: 'Allow',
Resource: '*',
},
{
Action: 'route53:changeResourceRecordSets',
Effect: 'Allow',
Resource: {
'Fn::Join': [
'',
[
'arn:',
{ Ref: 'AWS::Partition' },
':route53:::hostedzone/',
{ Ref: 'ExampleDotCom4D1B83AA' },
],
],
},
Condition: {
'ForAllValues:StringEquals': {
'route53:ChangeResourceRecordSetsRecordTypes': ['CNAME'],
'route53:ChangeResourceRecordSetsActions': ['UPSERT', 'DELETE'],
},
'ForAllValues:StringLike': {
'route53:ChangeResourceRecordSetsNormalizedRecordNames': [
'*.test.example.com',
'*.test2.example.com',
],
},
},
},
],
},
});
});
Loading