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

[@aws-cdk/aws-route53-patterns]: HttpsRedirect throws 'The parameter Comment is too big' #14020

Closed
fbaba-nibtravel opened this issue Apr 7, 2021 · 4 comments · Fixed by #14094
Assignees
Labels
@aws-cdk/aws-cloudfront Related to Amazon CloudFront @aws-cdk/aws-route53-patterns bug This issue is a bug. effort/small Small work item – less than a day of effort good first issue Related to contributions. See CONTRIBUTING.md in-progress This issue is being actively worked on. p1

Comments

@fbaba-nibtravel
Copy link

I'm trying to create a HttpsRedirect on Route53 with CloudFront. When deploying, the CDK is throwing the below error.

The comment itself is auto-generated and the props interface for the HttpsRedirect does not allow to customize the comment. The comment pattern is: Redirect to <target> from <recordName>.

The parameter Comment is too big. (Service: AmazonCloudFront; Status Code: 400; Error Code: InvalidArgument; Request ID: c8ea25db-e10a-4b47-bc81-d1cc818806d9; Proxy: null)
--
  | new CloudFrontWebDistribution (/app/node_modules/@aws-cdk/aws-cloudfront/lib/web-distribution.js:293:30)
  | \_ new HttpsRedirect (/app/node_modules/@aws-cdk/aws-route53-patterns/lib/website-redirect.js:51:30)
  | \_ StorybookAppStack.createRedirect (/app/dist/apps/deploy/src/stacks/storybook.stack.js:50:9)
  | \_ new StorybookAppStack (/app/dist/apps/deploy/src/stacks/storybook.stack.js:12:14)
  | \_ Object.<anonymous> (/app/dist/apps/deploy/src/storybook.app.js:9:1)
  | \_ Module._compile (internal/modules/cjs/loader.js:1063:30)
  | \_ Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
  | \_ Module.load (internal/modules/cjs/loader.js:928:32)
  | \_ Function.Module._load (internal/modules/cjs/loader.js:769:14)
  | \_ Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
  | \_ internal/main/run_main_module.js:17:47

Reproduction Steps

    const dnsSuffix = StackHelper.dnsSuffix(slice);
    const zone = StackHelper.getHostedZone(this);
    const {
      aws_certificatemanager: { Certificate, CertificateValidation },
      aws_route53_patterns: { HttpsRedirect },
    } = base;

    new HttpsRedirect(this, StackHelper.createId('Redirect'), {
      zone: zone,
      recordNames: [`super.large.url.should.help.${application}${dnsSuffix}`],
      targetDomain: `${bucket.bucketWebsiteDomainName}/add/more/blocks/just/to/increase/the/size`,
      certificate: new Certificate(this, 'Certificate', {
        domainName: `${stage}.${DOMAIN}`,
        validation: CertificateValidation.fromDns(zone),
      }),
    });

What did you expect to happen?

Should create the route redirect using AWS CloudFront from a dns to a bucket target url

What actually happened?

The route fails to be created because of a comment property, not an invalid redirect.

Environment

  • CDK CLI Version : 1.95.1
  • Framework Version : 1.95.1
  • Node.js Version : 14.16.0
  • **OS : Linux **
  • Language (Version): TypeScript 4.2.3

Other


This is 🐛 Bug Report

@fbaba-nibtravel fbaba-nibtravel added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 7, 2021
@njlynch njlynch added @aws-cdk/aws-cloudfront Related to Amazon CloudFront p1 effort/small Small work item – less than a day of effort good first issue Related to contributions. See CONTRIBUTING.md and removed needs-triage This issue or PR still needs to be triaged. labels Apr 9, 2021
@njlynch
Copy link
Contributor

njlynch commented Apr 9, 2021

Thanks for the bug report, @fbaba-nibtravel .

This appears to be due to the CloudFront distribution comment having an (undocumented) limit of 128 characters. While we could fix this within the route53-patterns construct, I think a better solution would be to fix this in the Distribution (and CloudFrontWebDistribution) constructs themselves.

The fix here is quite simple -- if the comment passed in is more than 128 characters, trim it down. This would be a great first issue for someone wanting to get started contributing to the CDK.

We would just need to trim the comment in two places:

https://github.com/aws/aws-cdk/blob/master/packages/@aws-cdk/aws-cloudfront/lib/distribution.ts#L290
https://github.com/aws/aws-cdk/blob/master/packages/@aws-cdk/aws-cloudfront/lib/web-distribution.ts#L773

And add a test for each, of course!

PRs welcome!

@hoegertn
Copy link
Contributor

hoegertn commented Apr 9, 2021

@fbaba-nibtravel Do you want to take this? Otherwise, I would look into it.

@fbaba-nibtravel
Copy link
Author

Hi @njlynch, thanks for the reply. I'll give it a go and will shout out if run into any trouble.

@njlynch njlynch added the in-progress This issue is being actively worked on. label Apr 12, 2021
@mergify mergify bot closed this as completed in #14094 Apr 13, 2021
mergify bot pushed a commit that referenced this issue Apr 13, 2021
… (#14094)

fixes #14020

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

hollanddd pushed a commit to hollanddd/aws-cdk that referenced this issue Aug 26, 2021
…4020) (aws#14094)

fixes aws#14020

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-cloudfront Related to Amazon CloudFront @aws-cdk/aws-route53-patterns bug This issue is a bug. effort/small Small work item – less than a day of effort good first issue Related to contributions. See CONTRIBUTING.md in-progress This issue is being actively worked on. p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants