Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved to V2 Of Powertools Library #20

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions lib/serverless-typescript-demo-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export class ServerlessTypescriptDemoStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);

// Use this toggle to switch between using the Lambda Layer and building the library into the function.
const useLayer = true;

const productsTable = new aws_dynamodb.Table(this, "Products", {
tableName: "Products",
partitionKey: {
Expand All @@ -34,13 +37,24 @@ export class ServerlessTypescriptDemoStack extends Stack {
};

const esBuildSettings = {
minify: true
minify: true,
externalModules: useLayer ? [
'@aws-lambda-powertools/*',
'@aws-sdk/*',
] : [],
}

const powertoolsLayer = aws_lambda.LayerVersion.fromLayerVersionArn(
this,
'PowertoolsLayer',
`arn:aws:lambda:${Stack.of(this).region}:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:5`
);

const functionSettings = {
handler: "handler",
runtime: aws_lambda.Runtime.NODEJS_16_X,
runtime: aws_lambda.Runtime.NODEJS_18_X,
memorySize: 256,
layers: useLayer ? [powertoolsLayer] : [],
environment: {
TABLE_NAME: productsTable.tableName,
...envVariables
Expand Down Expand Up @@ -129,4 +143,4 @@ export class ServerlessTypescriptDemoStack extends Stack {
value: `${api.url}products`,
});
}
}
}
Loading