You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As we have enabled tracing for our Lambda-Funtions, we can visit [AWS X-Ray Console](https://console.aws.amazon.com/xray/home#/traces/) and see [traces](https://docs.aws.amazon.com/xray/latest/devguide/xray-concepts.html#xray-concepts-traces) and a [service map](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-using-xray-maps.html) for our application.
90
+
91
+
As we have enabled tracing for our Lambda-Funtions, you can visit [AWS CloudWatch Console](https://console.aws.amazon.com/cloudwatch/) and see [Traces](https://docs.aws.amazon.com/xray/latest/devguide/xray-concepts.html#xray-concepts-traces) and a [Service Map](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-using-xray-maps.html) for our application.
92
+
93
+
You can also use the AWS SAM CLI to retrieve traces by running `sam traces`.
90
94
91
95
## Use the SAM CLI to build and test locally
92
96
@@ -138,42 +142,49 @@ You can find more information and examples about filtering Lambda function logs
138
142
139
143
## Switch to Lambda Layer
140
144
141
-
This example bundle all your dependencies in a single JS file thanks to esbuild but you can switch the AWSLambdaPowertoolsTypeScript Layer by:
142
-
1. specifying the right ARN in `Layers` list under the function's `Properties`
143
-
1. instructing esbuild to not bundle `@aws-lambda-powertools` under the function `Metadata/BuildProperties`
145
+
In this example we are including AWS Lambda Powertools as a dependency in our function's `package.json`. This is the recommended approach for development and testing. However, for production, you can also use the AWS Lambda Powertools as a Lambda Layer.
144
146
145
-
Learn more about Lambda Layers [here](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html) and about the Lambda Powertools for TypeScript layers [here](https://awslabs.github.io/aws-lambda-powertools-typescript/latest/#lambda-layer).
147
+
To start using the AWS Lambda Powertools as a Lambda Layer, you need to:
148
+
1. Specify the Layer's ARN in `Layers` section under each function's `Properties` section
149
+
2. Instruct `esbuild` to not bundle `@aws-lambda-powertools` under each function's `Metadata/BuildProperties` section
146
150
147
-
Here is the diff of the current sam template leveraging `AWSLambdaPowertoolsTypeScript` layer:
151
+
To do so, open the `template.yaml` file, and **for each Lambda Function**, update the following sections:
Description: A simple example includes a HTTP ost method to add one item to a DynamoDB table.
162
-
Policies:
163
-
@@ -124,6 +126,11 @@ Resources:
164
-
BuildMethod: esbuild
165
-
BuildProperties:
166
-
Minify: true
167
-
+ External:
168
-
+ - '@aws-lambda-powertools/commons'
169
-
+ - '@aws-lambda-powertools/logger'
170
-
+ - '@aws-lambda-powertools/metrics'
171
-
+ - '@aws-lambda-powertools/tracer'
172
-
Target: "es2020"
173
-
Sourcemap: true,
174
-
EntryPoints:
167
+
Metadata:
168
+
# Manage esbuild properties
169
+
BuildMethod: esbuild
170
+
BuildProperties:
171
+
BuildMethod: esbuild
172
+
BuildProperties:
173
+
Minify: true
174
+
Target: "ES2020"
175
+
Sourcemap: true
176
+
External:
177
+
- "@aws-sdk/lib-dynamodb"
178
+
- "@aws-sdk/client-dynamodb"
179
+
+ - "@aws-lambda-powertools/commons"
180
+
+ - "@aws-lambda-powertools/logger'
181
+
+ - "@aws-lambda-powertools/metrics"
182
+
+ - "@aws-lambda-powertools/tracer"
183
+
EntryPoints:
175
184
```
176
185
186
+
Learn more about Lambda Layers [here](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html) and about the Lambda Powertools for TypeScript layers [here](https://awslabs.github.io/aws-lambda-powertools-typescript/latest/#lambda-layer).
187
+
177
188
## Cleanup
178
189
179
190
To delete the sample application that you created, run the command below while in the `examples/sam` directory:
0 commit comments