Comments (3)
There is very little documentation around this, so putting it out there to help others-
Using CDK you can deploy any Lambda to us-east-1
then reference it as a Lambda@Edge. As long as your lambda does not rely on any functionality not supported by edge lambdas it should work fine. I defined my lamdba as so:
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 cognito-at-edge
NPM package with my lambda, and this works at Edge which is awesome.
The code for my lambda is exactly as it is in my original post, and I reference it during creation of my CloudFront distribution:
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.
from cognito-at-edge.
Can you please explain more about packing props during deploy time? Are you using ssm
?
from cognito-at-edge.
@aiden-sobey
hi! I have created a demo web app using this library for my edge function for cloudfront viewer request.
for bundling, in edge folder run "npm run webpack"
full code could be found at below link! 🚀
https://github.com/unitypark/aws-serverless-demos/tree/main/serverless-web-hosting/cloudfront-http-api-cognito
from cognito-at-edge.
Related Issues (20)
- Read PoolId, clientId from Secrets manager HOT 5
- login redirect with custom state does not work properly HOT 2
- How to get the logged in user in the application HOT 3
- Configurable cookie domains
- Mitigate CSRF attacks
- Make handler methods public
- purpose of disableCookieDomain - as will default to origin domain? HOT 1
- Redirect loop after refresh fetch caused by cookie path HOT 6
- Using cognito-at-edge as a layer on a lambda@edge function HOT 1
- Use as API Gateway Authorizer
- Maintaining Query String HOT 1
- Refresh functionality should not redirect on SPA applications
- Why is the authorization endpoint `/authorize` and not `/oauth2/authorize` ?
- Add `esModuleInterop = true` in tsconfig.json to enable bundle with Vite
- logoutUri does not log out user completely? HOT 4
- Client-side tokens and Error 502 clarification
- Consider using HTTP 307 instead of HTP 302 HOT 1
- TypeError - Cannot read properties of undefined (reading 'querystring')
- 503 ERROR due lambda timeout after tokens are fetched HOT 21
- Lambda with cognito-at-edge too big for CloudFront HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cognito-at-edge.