-
Notifications
You must be signed in to change notification settings - Fork 56
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
How to bundle 'cognito-at-edge' with Lambda@Edge function? #38
Comments
There is very little documentation around this, so putting it out there to help others- import * as nambda from "aws-cdk-lib/aws-lambda-nodejs";
import * as lambda from "aws-cdk-lib/aws-lambda";
this.lambda = new nambda.NodejsFunction(this, "auth", {
handler: "handler",
entry: path.join(__dirname, "../src/edge/auth.js"),
runtime: lambda.Runtime.NODEJS_16_X,
timeout: Duration.seconds(5),
logRetention: RetentionDays.ONE_WEEK,
bundling: {
nodeModules: ["cognito-at-edge"],
},
}); This bundles the this.distribution = new cf.Distribution(this, "server", {
...
defaultBehavior: {
edgeLambdas: [
{
eventType: cf.LambdaEdgeEventType.VIEWER_REQUEST,
functionVersion: this.lambda.currentVersion,
}
]
} I've also found a way to package props into the edge lambda at deploy time which is great, acts as a replacement for environment variables which Lambda@Edge does not have. |
Can you please explain more about packing props during deploy time? Are you using |
@aiden-sobey for bundling, in edge folder run "npm run webpack" full code could be found at below link! 🚀 |
Hi, I am using Typescript CDK to deploy a Lambda@Edge function that uses cognito-at-edge.
When the Lambda runs, it returns a 503 error with:
Error: Cannot find module 'cognito-at-edge'
I followed the instructions in the README exactly:
How is this package meant to be bundled with Lambda@Edge? I can't find any instructions in this README, or elsewhere.
The text was updated successfully, but these errors were encountered: