From b85e06a28384f6c0b9c6cbe553c97cce2c1162b4 Mon Sep 17 00:00:00 2001 From: Piers Karsenbarg Date: Tue, 25 Oct 2022 16:59:48 +0100 Subject: [PATCH 1/3] Added Pulumi code to deploy lambda with powertools --- docs/index.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/docs/index.md b/docs/index.md index 25ac163ad2..7a335a7424 100644 --- a/docs/index.md +++ b/docs/index.md @@ -186,6 +186,33 @@ You can include Lambda Powertools Lambda Layer using [AWS Lambda Console](https: } ``` + === "Pulumi" + + ```typescript hl_lines="11" + import * as pulumi from "@pulumi/pulumi"; + import * as aws from "@pulumi/aws"; + + const role = new aws.iam.Role("role", { + assumeRolePolicy: aws.iam.assumeRolePolicyForPrincipal(aws.iam.Principals.LambdaPrincipal), + managedPolicyArns: [aws.iam.ManagedPolicies.AWSLambdaBasicExecutionRole] + }); + + const lambdaFunction = new aws.lambda.Function("function", { + layers: [ + pulumi.interpolate`arn:aws:lambda:${aws.getRegionOutput().name}:094274105915:layer:AWSLambdaPowertoolsTypeScript:3` + ], + code: new pulumi.asset.AssetArchive({ + ".": new pulumi.asset.FileArchive("./app") + }), + tracingConfig: { + mode: "Active" + }, + runtime: aws.lambda.Runtime.NodeJS16dX, + handler: "index.handler", + role: role.arn + }); + ``` + === "Amplify" ```zsh From 1a25c9506cfc91883d417478488866b3ae4006a8 Mon Sep 17 00:00:00 2001 From: Piers Karsenbarg Date: Wed, 26 Oct 2022 16:07:52 +0100 Subject: [PATCH 2/3] Update docs/index.md Co-authored-by: Leandro Damascena --- docs/index.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/index.md b/docs/index.md index 7a335a7424..ec68270283 100644 --- a/docs/index.md +++ b/docs/index.md @@ -201,9 +201,7 @@ You can include Lambda Powertools Lambda Layer using [AWS Lambda Console](https: layers: [ pulumi.interpolate`arn:aws:lambda:${aws.getRegionOutput().name}:094274105915:layer:AWSLambdaPowertoolsTypeScript:3` ], - code: new pulumi.asset.AssetArchive({ - ".": new pulumi.asset.FileArchive("./app") - }), + code: new pulumi.asset.FileArchive("lambda_function_payload.zip"), tracingConfig: { mode: "Active" }, From 16f6d7cd7cbdda9eeaaa8a1576570155ea18de7f Mon Sep 17 00:00:00 2001 From: Piers Karsenbarg Date: Wed, 26 Oct 2022 16:14:56 +0100 Subject: [PATCH 3/3] Update docs/index.md Co-authored-by: Leandro Damascena --- docs/index.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/index.md b/docs/index.md index ec68270283..9de2ce403c 100644 --- a/docs/index.md +++ b/docs/index.md @@ -207,7 +207,8 @@ You can include Lambda Powertools Lambda Layer using [AWS Lambda Console](https: }, runtime: aws.lambda.Runtime.NodeJS16dX, handler: "index.handler", - role: role.arn + role: role.arn, + architectures: ["x86_64"] }); ```