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

feat(cloudfront): write Lambda@Edge with typescript #18836

Closed

Conversation

mmuller88
Copy link
Contributor

@mmuller88 mmuller88 commented Feb 5, 2022

fixes: #12671

As you can see I duplicated a lot from aws-lambda-nodejs/lib/function.ts . It would be great to get rid of that. Let me know how to proceed.

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

@gitpod-io
Copy link

gitpod-io bot commented Feb 5, 2022

@mmuller88
Copy link
Contributor Author

mmuller88 commented Feb 5, 2022

Will start writing the tests if that PR hits interested and after we are happy with the production code part.

@mmuller88
Copy link
Contributor Author

@comcalvi can I have some feedback for how to get rid of those duplicates?

@mmuller88 mmuller88 changed the title feat(cloudfront): write lambda at edge with typescript feat(cloudfront): write Lambda@Edge with typescript Feb 10, 2022
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: aaef381
  • Result: FAILED
  • Build Logs (available for 30 days)

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

@rix0rrr rix0rrr added feature-request A feature should be added or improved. p1 and removed p1 feature-request A feature should be added or improved. @aws-cdk/aws-cloudfront Related to Amazon CloudFront labels Mar 4, 2022
@mmuller88
Copy link
Contributor Author

@rix0rrr @comcalvi what is going on here?

Copy link
Contributor

@comcalvi comcalvi 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 submission. This will need some changes before we can merge it in.

@@ -0,0 +1,208 @@
import * as fs from 'fs';
import * as path from 'path';
import * as cloudfront from '@aws-cdk/aws-cloudfront';
Copy link
Contributor

@comcalvi comcalvi Feb 8, 2022

Choose a reason for hiding this comment

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

I think this import: import * as cloudfront from '@aws-cdk/aws-cloudfront'; is causing the build to fail. This file is in the aws-cloudfront module, so you shouldn't import from @aws-cdk/aws-cloudfront. Instead you should import the classes you need relative to the current directory.

Comment on lines +105 to +113
code: bundling.Bundling.bundle({
...props.bundling ?? {},
architecture,
runtime,
depsLockFilePath,
entry,
projectRoot,
}),
handler: `index.${handler}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is weird...why are we finding all of these values ourselves? The code property is a lambda function code property, which should be created using lambda's existing methods (eg lambda.Code.fromAsset(), or something else). In general, I think we should let the user specify their code directly instead of trying to find it for them.

* 3. A .js file name as the defining file with id as suffix (defining-file.id.js)
* 4. A .mjs file name as the defining file with id as suffix (defining-file.id.mjs)
*/
function findEntry(id: string, entry?: string): string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, I don't think we should be finding any of these files ourselves. The user should be specifying these directly.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's what NodejsFunction does, but the findEntry helper is not exposed for reuse. It makes sense to keep the same behavior for both NodejsFunction and NodejsEdgeFunction.

Comment on lines +19 to +24
* @default - Derived from the name of the defining file and the construct's id.
* If the `NodejsFunction` is defined in `stack.ts` with `my-handler` as id
* (`new NodejsFunction(this, 'my-handler')`), the construct will look at `stack.my-handler.ts`
* and `stack.my-handler.js`.
*/
readonly entry?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

why? This seems to be something the user must have in order for this construct to deploy, so having it be an optional property is confusing. They should specify it directly.

Copy link
Contributor

Choose a reason for hiding this comment

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

The NodejsFunction does the same as well: it looks for a specific entry file based on the file where the NodejsFunction is created.

*
* @default true
*/
readonly awsSdkConnectionReuse?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need this? It's not referenced anywhere in this PR

}

return sites[definingIndex].getFileName();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we get a blank line at EOF?

@mmuller88
Copy link
Contributor Author

@comcalvi thx a lot for looking into that. But please read and try to understand the description as that will help to answer most of your questions!

@aws-cdk-automation
Copy link
Collaborator

This PR has been in BUILD FAILING for 21 days, and looks abandoned. It will be closed in 10 days if no further commits are pushed to it.

@comcalvi
Copy link
Contributor

@mmuller88 before we get into the details of the code duplication, please update the PR so that the code build job succeeds.

@github-actions
Copy link

This PR has been deemed to be abandoned, and will be automatically closed. Please create a new PR for these changes if you think this decision has been made in error.

@github-actions github-actions bot added the closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. label Apr 20, 2022
@github-actions github-actions bot closed this Apr 20, 2022
@mmuller88
Copy link
Contributor Author

mmuller88 commented May 13, 2022

@comcalvi I didn't feel well supported by you. You didn't understand or looked into much of what I was asking for or didn't understand it and clarified that. I kind of lost interest in this PR because of that. You are perhaps quite Junior so then I could understand that. A bit disappointed with you and AWS

@skyrpex
Copy link
Contributor

skyrpex commented May 13, 2022

Similar issue here #14215

@mmuller88
Copy link
Contributor Author

@comcalvi sorry for my stupid words. I think I was a bit frustrated and acted quite childish. I should have acted on your comments better and with more patience. I think I was frustrated that it took you so long for looking over my issue. But of course, the CDK team has lots to do. Again, I am very sorry.

@TheOrangePuff
Copy link

@comcalvi @skyrpex I'm happy to take this PR on. This is a huge problem for us and is holding us back from upgrading to CDK 2.

@comcalvi
Copy link
Contributor

sorry all! I hadn't seen these since the PR was autoclosed.

@mmuller88 @TheOrangePuff do you want me to re-open this PR?

@hugomallet
Copy link

@comcalvi Yes please I think there's still no solution to this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. feature-request A feature should be added or improved. p1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(aws-cloudfront): EdgeFunction NodejsFunction and PythonFunction support
7 participants