Skip to content
GitHub Discord

AWS Lambda build hook

In this example we hook into the Lambda function build process with hook.postbuild.

This is useful for modifying the generated Lambda function code before it’s uploaded to AWS. It can also be used for uploading the generated sourcemaps to a service like Sentry.

sst.config.ts
new sst.aws.Function("MyFunction", {
url: true,
handler: "index.handler",
hook: {
async postbuild(dir) {
console.log(`postbuild ------- ${dir}`);
},
},
});
index.js
export async function handler(event,) {
console.log(event);
return {
statusCode: 200,
body: 'Hello World',
};
}

View the full example.