-
Notifications
You must be signed in to change notification settings - Fork 12
Bundle aws-sdk into the lambda function with tsup #85
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left minor note ;)
| "clean": "rm -rf dist", | ||
| "prebuild": "npm run clean", | ||
| "build": "tsc -p tsconfig.json", | ||
| "build": "tsup src/index.ts", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current CDK configuration packages everything under dist/ directory to zip archive.
Which means, we just need to have dependencies under dist/ directory, like following way:
- move aws-sdk to dep from dev dep
- define "postbuild" hook or combine with build hook to copy dependencies
- e.g.
"postbuild": "cp package*.json dist/ && cd dist && npm ci && cd .."
- that's all. simple, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can do that, but with tsup it's bundled directly into a single file inside dist/index.jsand it has 944kb, don't think we need the whole aws-sdk.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I know that we can get smaller & standalone js bundle, but I don't prefer bundled script unless we really need it because it makes debugging harder (e.g. locations in stacktrace are also minified - we need to bundle, or inline source map and use sourcemap-support like stuffs to restore original locations), and most importantly, we will be using the AWS SDK (v3) bundled with the lambda runtime again in the next release - we have to revert those changes for bundling in the next release
|
@mooyoul @arpadgabor hi, As a open-source contributor and maintainer myself, I understand you owe me nothing. I am not typescript developer myself (yet), so I can't add value to the project/PR. |
|
@mathbunnyru at some point AWS added official CDK support for creating SES identities, see https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ses.Identity.html I'm not positive the official construct does everything this library did, but I didn't find anything missing. If it does have feature parity, perhaps the maintainers here could post a note in the readme and deprecate this package to avoid confusion. |
|
Thank you @jayalfredprufrock, I will take a look. |
|
@jayalfredprufrock As far as I know the Identity class in CDK does not support auto verifying domains. Or did that change in the last couple of months? |
|
@silberistgold In the very beginning it didn't have support, but at some point it was added. I've been using it successfully for 8 months or so. Obviously it did require deleting the existing custom resource and manually removing the verified identities, but once I did that the official package worked just the same as this one and handled the verification process automatically. |
Unfortunately you can't just move dependencies from dev -> prod because the lambda build uses tsc, which does not bundle dependencies. Instead, I used
tsupto generate thedist/index.jsfile required for the lambda. It contains all dependencies, including the used methods from the SDK.