Last active
November 12, 2024 16:54
-
-
Save perpil/e9b1bb63f7d5534e41f10d9f886a7cb1 to your computer and use it in GitHub Desktop.
Get node lambda runtime build date at run time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { statSync } from "fs"; | |
| let runtimeBuildDate; | |
| try { | |
| runtimeBuildDate = statSync("/var/runtime").mtime; | |
| } catch (e) { | |
| console.error("Unable to determine runtime build date", e); | |
| } | |
| export const handler = async (event) => { | |
| const response = { | |
| statusCode: 200, | |
| body: JSON.stringify({runtimeBuildDate, nodeVersion:process.version}), | |
| }; | |
| return response; | |
| }; |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Snippet from my CDK NodeJsFunction to replace the environment variable
process.env.sdkVersionwith current AWS SDK version at build time using esbuild define: