Closed kraleva closed 3 months ago
Good idea and ... great opportunity for a contribution? Only one line to change: https://github.com/aws-samples/cloudfront-authorization-at-edge/blob/efc0aef2199ec690e6ea003b2206bdc1caf3ecf8/template.yaml#L293
Looking forward to the PR :)
Had a look myself and it turned out to be more involving because with Node18 the aws-sdk is no longer available in the Lambda runtime enviroment, so you need to include it yourself (or switch to the V3 SDK which is even more involving). Had an attempt but then ran into this issue https://github.com/npm/cli/issues/4783 when building the React App.
Updated to Node 16 for now
Thank you for the very helpful sample. Node.js 16 has been deprecated, are there any plans to update it?
https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/lambda-runtimes.html
Plans yes, but we didn't get to it yet. If you want to send a PR don't hold back :)
FYI, for anyone looking to deploy these as Lambda's with Node20.x I made progress, but there is still a way to go.
My try to make this work found src/lambda-edge/shared/shared.tsrequired 2 changes:
import SSM = require("@aws-sdk/client-ssm");
const getPathParams = await ssm.getParametersByPathCommand(pathParams).promise();
Then by packaging the provided existing function typescript code with esbuilder with the following tsconfig.json settings:
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"lib": ["ES2022"],
"module": "ES2022",
"moduleResolution": "node",
"target": "ES2022"
},
We also now have this packaged for deployment within terraform automation pipelines using this terraform provider: https://registry.terraform.io/providers/jSherz/node-lambda-packager/latest And the module var set to:
args = [
"--bundle",
"--external:@aws-sdk*",
"--external:axios",
"--external:cookie",
"--external:jsonwebtoken",
"--external:jwks-rsa",
"--external:./error-page/template.html",
"--minify",
"--platform=node",
"--sourcemap",
"--target=es2022",
"--sourcemap=inline",
]
We are only using the following: check-headers, http-headers, parse-auth, refresh-auth, sign-out functions.
After some further testing the above is close, but still has some fundamental backend issues with the transfer to sdk3. Hopefully this is useful to people in the future who go down this rabbit hole. I'll dedicate some more time to this at a later date when I get a chance.
Upgraded to Node v20!
https://github.com/aws-samples/cloudfront-authorization-at-edge/releases/tag/v2.2.1
Hey, first thanks for the project, you provided. It's really cool !
I just wanted to mention, that maybe it might be a good idea to bump the node version of the tsconfig file. Currently, node 20 is already released whereas the project uses the config for node14, which might be suboptimal.