-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
aws-certificatemanager: invalid cloudformation generated when using wildcard domain to create public certificate #27364
Comments
Upon closer review of the CDK code and test files it looks like this is because we're using the SSM reader and the output Cfn is using the GetAttr. Not sure if this will turn into a "won't fix" or not but lets see. |
Ideally, these do get filtered out. However, since the values are not known at deploy time, we cannot run the necessary logic we have in place - and have to assume the deploy time value will be a viable use case. aws-cdk/packages/aws-cdk-lib/aws-certificatemanager/lib/certificate.ts Lines 318 to 327 in b2a895e
I don't see a great way to implement an official way to work around this with our current API either, unless we add an entirely new prop specifically to signal that this use case is being implemented. @indrora what do you think? Thanks for posting a workaround that works for you 🙂, that workaround should work as long as you are deleting the correct one, just be sure to check the template to see which index in the array to delete. |
Another workaround, If you're deploying with CICD Pipeline you actually can resolve SSM param in pipeline before deploying CDK Github Actions pipeline: - name: ⚙️ Fetch SSM Parameters and set Env variables
uses: dkershner6/aws-ssm-getparameters-action@v2
with:
parameterPairs: '/dns/myDomain = MY_DOMAIN' then, in CDK: const myDomain = process.env.MY_DOMAIN!
const cert = new acm.Certificate(this, 'cert', {
domainName: myDomain,
validation: acm.CertificateValidation.fromDns(zone),
subjectAlternativeNames: [`*.${myDomain}`],
}) |
Describe the bug
When creating a public certificate with a wildcard subdomain, invalid Cfn template is generated and stack creation fails. Cfn includes the same domain validation records twice with exactly the same values which fails when sending the DNS change batch.
Edit: after further investigation, this happens when importing SSM parameters from cross region using the suggested workaround here: https://github.com/henrist/cdk-cross-region-params/blob/master/src/parameter-reader.ts or https://stackoverflow.com/questions/71246435/how-to-read-parameter-store-from-a-different-region-in-cdk. This is a fairly well used way of getting around restrictions with cross-region exports etc.
Expected Behavior
When creating a certificate with wildcard DNS, the correct Cfn is generated and can be deployed.
Expected Cfn output (slightly edited to avoid private information):
Current Behavior
When creating a certificate with wildcard DNS, the incorrect Cfn is generated and can be deployed.
Example Cfn output (slightly edited to avoid private information):
Both of the
DomainValidationOptions
generate the same validation CNAME record. When the call to put records is done, it includes a duplicate record. See the below CloudTrail for example:Reproduction Steps
Possible Solution
Unsure the best way to deal with this to be honest. Potentially need to understand more about the scenarios that domain validation cname records can clash. When they clash, some logic may need to be executed.
The current workaround I've put in place is:
Of course this works for my scenario but may need to be updated for other peoples requirements depending on what domains and alternative domains are requested. It could be improved to read all domains in the list and look specifically for wildcards that need to be removed.
Additional Information/Context
Unsure if it would help since most people won't have access to the case details but this fix was suggested by AWS Support in case 13934396421. This was roughly the response:
CDK CLI Version
2.94.0
Framework Version
No response
Node.js Version
v18.12.1
OS
Ubuntu 22.04.2 LTS
Language
Typescript
Language Version
4.9.5
Other information
Also tested on the latest version of the CDK (
2.99.1
) with the same outcome.Probably related to #15574.
Only seems to be an issue using
HostedZone.fromHostedZoneAttributes
. Other code paths appear to work. Also noted in #9248.This was supposedly fixed in https://github.com/aws/aws-cdk/pull/9291/files but that doesn't appear to be the case.
The text was updated successfully, but these errors were encountered: