aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.68k stars 3.93k forks source link

(aws_cloudfront): (Issue with CloudFrontWebDistribution 'viewercertificate' ) #21125

Closed Shankureddy closed 2 years ago

Shankureddy commented 2 years ago

Describe the bug

Hi I have encountered a strange problem while deploying my infra using cdk V2, my code consists an S3 bucket and Cloudfront distribution as below but when deployed it throws error.

const reactBucket = new s3.Bucket(this, ${id}, { bucketName: my-cfnt-demo-shanku, removalPolicy: RemovalPolicy.DESTROY, //Removing bucket if change needed versioned: false, accessControl: s3.BucketAccessControl.PRIVATE, encryption: s3.BucketEncryption.UNENCRYPTED, blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL, });

const cert = cfnt.ViewerCertificate.fromIamCertificate('xxxx-xxxx-xxxx-xxxx-xxxxxxx',
  {
    aliases: ['my']
  })

  new cfnt.CloudFrontWebDistribution(this, 'MyCfWebDistribution', {
    originConfigs: [
      {
        s3OriginSource: {
          s3BucketSource: reactBucket,
        },
        behaviors : [ {isDefaultBehavior: true} ],
      },
    ],
    viewerCertificate: cert,
  });

} }

Expected Behavior

It should deploy my app without any issues

Current Behavior

2:41:35 p.m. | CREATE_FAILED | AWS::CloudFront::Distribution | MyCfWebDistributio...stribution94DCDF0B Resource handler returned message: "Invalid request provided: 1 validation error detected: Value 'xxxx-xxx-xxxx-xxxxx' at 'serverCertificateId' failed to satisfy constraint: Member must have length less than or equal to 32 (Service: CloudFront, Status Code: 400, Request ID: d711c052-d36 b-43a5-ae36-c7a4d8421a5b)" (RequestToken: cb89b50b-f942-049a-e330-b79c38ee5344, HandlerErrorCode: InvalidRequest)

Note: {"We have the same certificate id from cdk V1 but issue arising now in V2"}

Reproduction Steps

Just create a cdk app and create a cloudfront and deploy it

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.28.1 (build d035432)

Framework Version

No response

Node.js Version

v16.4.0

OS

Mac

Language

Typescript

Language Version

No response

Other information

No response

peterwoodworth commented 2 years ago

We haven't made any changes to any of this behavior recently - If this difference was caused upon upgrading to v2 could you share any difference in synth output from when it was working and now?

Sidenote - we recommend using the Distribution construct rather than CloudFrontWebDistribution - check out a guide on migrating to the new construct! https://docs.aws.amazon.com/cdk/api/v1/docs/aws-cloudfront-readme.html#migrating-from-the-original-cloudfrontwebdistribution-to-the-newer-distribution-construct

github-actions[bot] commented 2 years ago

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

github-actions[bot] commented 2 years ago

⚠️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.