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

CDK does not add existing Cloudfront as trigger to Lambd@Edge? #20494

Closed
jatinmehrotra opened this issue May 25, 2022 · 3 comments
Closed

CDK does not add existing Cloudfront as trigger to Lambd@Edge? #20494

jatinmehrotra opened this issue May 25, 2022 · 3 comments
Labels
@aws-cdk/aws-cloudfront Related to Amazon CloudFront bug This issue is a bug. effort/medium Medium work item – several days of effort p2

Comments

@jatinmehrotra
Copy link

Describe the bug

I am using CDK v1,
Whenever i am trying to update my Lambda@edge function, the Lambda@edge stack is created with function, lambda role but it does not add EXISTING Cloudfront distribution.

Expected Behavior

Ideally when i update my lambda code, the new lambda@edge stack should automatically have trigger as existing cloudfront distribution.

Current Behavior

After i update lambda code, CDK creates new lambda@edge stack which has iam role, but does not have cloudfront as trigger.

Reproduction Steps

Lambda@edge code

const uriRedirector = new cloudfront.experimental.EdgeFunction(
      this,
      'UriRedirector',
      {
        code: lambda.Code.fromAsset('dist/events/object-cache/uri-redirector'),
        runtime: lambda.Runtime.NODEJS_14_X,
        handler: 'index.handle',
      }
    )

Cloudfront code

this.distribution = new cloudfront.Distribution(this, 'Distribution', {
      defaultBehavior: {
        origin: s3Origin,
        edgeLambdas: [
          {
            functionVersion: uriRedirector.currentVersion,
            eventType: cloudfront.LambdaEdgeEventType.ORIGIN_REQUEST,
          },
        ],
        originRequestPolicy: defaultBehaviourOriginRequestPolicy,
        viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.HTTPS_ONLY,
        allowedMethods: cloudfront.AllowedMethods.ALLOW_ALL,
      },
      
      ....

Possible Solution

Is it due to cdk v1?

Additional Information/Context

No response

CDK CLI Version

1.153

Framework Version

No response

Node.js Version

14.17.6

OS

macOS

Language

Typescript

Language Version

4.4.3

Other information

No response

@jatinmehrotra jatinmehrotra added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 25, 2022
@github-actions github-actions bot added the @aws-cdk/aws-cloudfront Related to Amazon CloudFront label May 25, 2022
@jatinmehrotra
Copy link
Author

jatinmehrotra commented May 27, 2022

Update :-
Update :- I tried replicating code into another environment and looks like it works as it should,
However in above mentioned environment where issue is happening, it always create new lambda@edge stack on updating lambda code instead it should create. a new version on the exsiting lambda@edge stack with cloudfront as trigger.

i do have code which was used while change cloudfront API's , could this be a problem

const cfnDistribution = this.distribution.node
      .defaultChild as cloudfront.CfnDistribution
    cfnDistribution.overrideLogicalId(props.oldDistributionLogicalId)

@comcalvi comcalvi added effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Jun 20, 2022
@comcalvi comcalvi removed their assignment Jun 20, 2022
@comcalvi comcalvi added the p2 label Jun 20, 2022
@khushail
Copy link
Contributor

khushail commented Jun 5, 2024

@jatinmehrotra , the CDK V1 is deprecated and we no longer provide updates on this.

AWS CDK v1 will enter Maintenance Mode after June 1, 2022. After this date, v1 releases will contain new and updated resource level “L1” constructs, critical bug fixes, and security updates only. We will not publish new features or minor bug fixes to v1. See the [AWS SDKs and Tools maintenance policy](https://docs.aws.amazon.com/sdkref/latest/guide/maint-policy.html) for more detail on what this means.

Maintenance mode has a duration of 12 months. On June 1, 2023, CDK v1 will reach end-of-support. After this date, the AWS CDK v1 will no longer receive updates or releases. Previously published releases will continue to be available via public package managers and the code will remain on GitHub. Use of a CDK version which has reached end-of-support is done at your own discretion. We recommend you upgrade to the new major version.

Migration guide - https://docs.aws.amazon.com/cdk/v2/guide/migrating-v2.html

I am closing this issue as its related to V1. Please feel free to reopen if you face the similar issue in CDK V2.

@khushail khushail closed this as completed Jun 5, 2024
Copy link

github-actions bot commented Jun 5, 2024

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

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 bug This issue is a bug. effort/medium Medium work item – several days of effort p2
Projects
None yet
Development

No branches or pull requests

3 participants