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(acm): Allow tokens as a part of the hosted zone name #6685

Merged
merged 2 commits into from Mar 19, 2020
Merged

fix(acm): Allow tokens as a part of the hosted zone name #6685

merged 2 commits into from Mar 19, 2020

Conversation

rhermes62
Copy link
Contributor

This review adds a basic check to not try and validate unresolved tokens when performing validation for the DnsValidatedCertificate construct.

fixes #6133


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 4122146
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 22eed76
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 2576651
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution @rhermes62 ! I have 2 small comments.

@@ -109,7 +109,11 @@ export class DnsValidatedCertificate extends cdk.Resource implements ICertificat
protected validate(): string[] {
const errors: string[] = [];
// Ensure the zone name is a parent zone of the certificate domain name
if (this.domainName !== this.normalizedZoneName && !this.domainName.endsWith('.' + this.normalizedZoneName)) {
if (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This indentation looks a tad weird to me... how about this?

        if (!cdk.Token.isUnresolved(this.normalizedZoneName) &&
              this.domainName !== this.normalizedZoneName &&
              !this.domainName.endsWith('.' + this.normalizedZoneName)) {
            errors.push(`DNS zone ${this.normalizedZoneName} is not authoritative for certificate domain name ${this.domainName}`);
        }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works with me!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code in the current revision is still the same though 🙂

hostedZone: helloDotComZone
});

// a bit of a hack: expect(stack) will trigger validation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice hack with expect, but there's a simpler way :). We have a SynthUtils class with a synthesize method that we use for this kind of situations, so the test becomes:

  'does not try to validate unresolved tokens'(test: Test) {
    const stack = new Stack();

    const helloDotComZone = new PublicHostedZone(stack, 'HelloDotCom', {
      zoneName: Token.asString('hello.com')
    });

    new DnsValidatedCertificate(stack, 'Cert', {
      domainName: 'hello.com',
      hostedZone: helloDotComZone
    });

    test.doesNotThrow(() => {
      SynthUtils.synthesize(stack);
    });

    test.done();
  },

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect! Ill also update test above this that uses that hack (I didn't come up with it but just went along with it haha).

Do you think it's also worth allowing the domainName property in the DnsValidatedCertificate to be a token as well? (For me specifically, I only have/need the zoneName to be a Token but I can see others having the domainName in the DnsValidatedCertificate be a token.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to leave it as it is right now - we can always change it if it's needed.

@mergify mergify bot dismissed skinny85’s stale review March 12, 2020 20:56

Pull request has been modified.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 84ca9be
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 6c4f5db
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: c964d6b
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment has still not been addressed, in spite of being Resolved 🙂.

This review adds a basic check to not try and validate unresolved tokens when performing validation for the `DnsValidatedCertificate` construct.

fixes #6133
@mergify mergify bot dismissed skinny85’s stale review March 17, 2020 03:00

Pull request has been modified.

@rhermes62
Copy link
Contributor Author

This comment has still not been addressed, in spite of being Resolved 🙂.

Just updated! Should show correctly now

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 25948fc
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix @rhermes62 !

@mergify
Copy link
Contributor

mergify bot commented Mar 19, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 991aa3c
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Contributor

mergify bot commented Mar 19, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit acfb6ef into aws:master Mar 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DnsValidatedCertificate: Tokens in the hostedZone property breaks cdk synth
3 participants