Configure AWS Lambda source paths with OpenJS Architect
SHAWNHOSEA
Posted on March 16, 2021
Architect originally relied on convention over configuration — meaning you could expect the placement of Lambda function handlers, to appear in default and deterministic locations. Recently, we introduced configurable file paths, which allow you to have more granular configurability over your Architect and Begin projects source code. This might be important for you because you have an existing project structure and conventions or you may need to point your Lambdas at generated build artifacts from something like TypeScript.
Configure source for get /
in package.json
Define the application Infra as Code (IaC) in package.json
under the arc
key.
{
"arc": {
"app": "begin-app",
"http": {
"/": {
"method": "get",
"src": "path/to/code"
}
}
}
}
Configure source for a larger app in package.json
Define IaC for a GraphQL app.
{
"arc": {
"http": {
"/": { "method": "get", "src": "path/to/code"},
"/api": { "method": "post", "src": "path/to/apollo"}
}
}
}
This enables you to configure separate source paths for your code for each Lambda function. It is a good idea to separate your code into single responsibility functions. Less code per function means faster cold-starts and deployments. This also makes sharing code and using transpilers a breeze!
Posted on March 16, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
November 24, 2024