Skip to content

Commit 6493a30

Browse files
authored
Merge branch 'main' into fix/tracer_fetch_pathname
2 parents 0de1ea8 + abe27ab commit 6493a30

File tree

105 files changed

+2893
-3091
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+2893
-3091
lines changed

.devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/blob/v0.212.0/containers/javascript-node/.devcontainer/base.Dockerfile
2-
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node@sha256:e2228dfc5285942804c12b897f914e3262e9bba48c2ff473bad8b9fbd9bf7d26
2+
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node@sha256:aedf26ccde02f734a8d8879778f5daac6c71609bb1df1b5a3e9d708f3c2827a2
33

44
# Install fnm to manage Node.js versions
55
RUN curl -fsSL https://fnm.vercel.app/install -o /tmp/install \

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ updates:
4444
- "aws-sdk-client-mock-jest"
4545
aws-cdk:
4646
patterns:
47-
- "@aws-cdk/*"
47+
- "@aws-cdk/cli-lib-alpha"
4848
- "aws-cdk-lib"
4949
- "aws-cdk"
5050
typedoc:

.github/workflows/on_schedule_monthly_roadmap_reminder.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

.github/workflows/ossf_scorecard.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ jobs:
3535
# repo_token: ${{ secrets.SCORECARD_TOKEN }} # read-only fine-grained token to read branch protection settings
3636

3737
- name: "Upload results"
38-
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
38+
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
3939
with:
4040
name: SARIF file
4141
path: results.sarif
4242
retention-days: 5
4343

4444
# Upload the results to GitHub's code scanning dashboard.
4545
- name: "Upload to code-scanning"
46-
uses: github/codeql-action/upload-sarif@f0f3afee809481da311ca3a6ff1ff51d81dbeb24 # v3.26.4
46+
uses: github/codeql-action/upload-sarif@4dd16135b69a43b6c8efb853346f8437d92d3c93 # v3.26.6
4747
with:
4848
sarif_file: results.sarif

.github/workflows/publish_layer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
- name: Zip output
4646
run: zip -r cdk.out.zip layers/cdk.out
4747
- name: Archive CDK artifacts
48-
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
48+
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
4949
with:
5050
name: cdk-layer-artifact
5151
path: cdk.out.zip

.github/workflows/record_pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
script: |
5454
const script = require('.github/scripts/save_pr_details.js')
5555
await script({github, context, core})
56-
- uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
56+
- uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
5757
with:
5858
name: pr
5959
path: pr.txt

.github/workflows/reusable_deploy_layer_stack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ jobs:
9393
cat cdk-layer-stack/${{ matrix.region }}-layer-version.txt
9494
- name: Save Layer ARN artifact
9595
if: ${{ inputs.stage == 'PROD' }}
96-
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
96+
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
9797
with:
9898
name: cdk-layer-stack-${{ matrix.region }}
9999
path: ./cdk-layer-stack/* # NOTE: upload-artifact does not inherit working-directory setting.

.github/workflows/reusable_publish_docs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
- name: Setup dependencies
6060
uses: aws-powertools/actions/.github/actions/cached-node-modules@d406bac5563f1d8c793519a3eedfe620f6a14872
6161
- name: Set up Python
62-
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
62+
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
6363
with:
6464
python-version: "3.12"
6565
- name: Install doc generation dependencies
@@ -96,7 +96,7 @@ jobs:
9696
run: |
9797
cp -r api site/
9898
- name: Create Artifact (Site)
99-
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
99+
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
100100
with:
101101
name: site
102102
path: site

.github/workflows/secure-workflows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ jobs:
3232
- name: Checkout code
3333
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
3434
- name: Ensure 3rd party workflows have SHA pinned
35-
uses: zgosalvez/github-actions-ensure-sha-pinned-actions@b88cd0aad2c36a63e42c71f81cb1958fed95ac87 # v3.0.10
35+
uses: zgosalvez/github-actions-ensure-sha-pinned-actions@3c16e895bb662b4d7e284f032cbe8835a57773cc # v3.0.11
3636
with:
3737
allowlist: slsa-framework/slsa-github-generator

.markdownlintignore

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,4 @@ layers/*/CHANGELOG.md
99
# other files
1010
LICENSE
1111
.github/**
12-
**node_modules/** */
13-
# these will be removed from the ignore and linted in future PRs
14-
packages/batch/README.md
15-
packages/commons/README.md
16-
packages/jmespath/README.md
17-
packages/logger/README.md
18-
packages/metrics/README.md
19-
packages/parameters/README.md
20-
packages/tracer/README.md
12+
**node_modules/** */

docs/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# version 9.5.2
2-
FROM squidfunk/mkdocs-material@sha256:a73e4bbbccb09e5374cef28ebe68511c166222274f8486b25ad467ec1f5e8bbe
2+
FROM squidfunk/mkdocs-material@sha256:a2e3a31c00cfe1dd2dae83ba21dbfa2c04aee2fa2414275c230c27b91a4eda09
33

44
COPY requirements.txt /tmp/
55
RUN pip install --require-hashes -r /tmp/requirements.txt

docs/core/logger.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,25 @@ We prioritise log level settings in this order:
542542

543543
In the event you have set a log level in Powertools to a level that is lower than the ACL setting, we will output a warning log message informing you that your messages will be discarded by Lambda.
544544

545+
### Reordering log keys position
546+
547+
You can change the order of [standard Logger keys](#standard-structured-keys) or any keys that will be appended later at runtime via the `logRecordOrder` parameter.
548+
549+
!!! note
550+
This feature is available only in the default log formatter and not with custom log formatters.
551+
552+
=== "reorderLogKeys.ts"
553+
554+
```typescript hl_lines="5 10"
555+
--8<-- "examples/snippets/logger/reorderLogKeys.ts"
556+
```
557+
558+
=== "reorderLogKeysOutput.json"
559+
560+
```json hl_lines="2-3"
561+
--8<-- "examples/snippets/logger/reorderLogKeysOutput.json"
562+
```
563+
545564
### Setting timestamp to custom Timezone
546565

547566
By default, Logger emits records with the default Lambda timestamp in **UTC**, i.e. `2016-06-20T12:08:10.000Z`

docs/overrides/main.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
{% block announce %}
1111
On September 1st, 2024 v1 of Powertools for AWS Lambda (TypeScript) <a
12-
href="https://github.com/aws-powertools/powertools-lambda-typescript/issues/2224" target="_blank">will reach
12+
href="https://github.com/aws-powertools/powertools-lambda-typescript/issues/2224" target="_blank">has reached
1313
End-of-Life</a>. We recommend you to <a href="https://docs.powertools.aws.dev/lambda/typescript/latest/upgrade/"
1414
target="_blank">upgrade to v2</a>.
1515
{% endblock %}

docs/requirements.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
mike==1.1.2
2-
mkdocs-material==9.5.32
2+
mkdocs-material==9.5.34
33
mkdocs-git-revision-date-plugin==0.3.2
44
mkdocs-exclude==1.0.2

docs/requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,9 @@ mkdocs-get-deps==0.2.0 \
235235
mkdocs-git-revision-date-plugin==0.3.2 \
236236
--hash=sha256:2e67956cb01823dd2418e2833f3623dee8604cdf223bddd005fe36226a56f6ef
237237
# via -r requirements.in
238-
mkdocs-material==9.5.32 \
239-
--hash=sha256:38ed66e6d6768dde4edde022554553e48b2db0d26d1320b19e2e2b9da0be1120 \
240-
--hash=sha256:f3704f46b63d31b3cd35c0055a72280bed825786eccaf19c655b44e0cd2c6b3f
238+
mkdocs-material==9.5.34 \
239+
--hash=sha256:1e60ddf716cfb5679dfd65900b8a25d277064ed82d9a53cd5190e3f894df7840 \
240+
--hash=sha256:54caa8be708de2b75167fd4d3b9f3d949579294f49cb242515d4653dbee9227e
241241
# via -r requirements.in
242242
mkdocs-material-extensions==1.3.1 \
243243
--hash=sha256:10c9511cea88f568257f960358a467d12b970e1f7b2c0e5fb2bb48cab1928443 \

docs/upgrade.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: Guide to update between major Powertools for AWS Lambda (TypeScript
77

88
## End of support v1
99

10-
!!! warning "On March 13th, 2024, Powertools for AWS Lambda (TypeScript) v1 entered maintenance mode, and will reach end-of-life on September 1st, 2024. If you are still using v1, we strongly recommend you to read our upgrade guide and update to the latest version."
10+
!!! warning "On March 13th, 2024, Powertools for AWS Lambda (TypeScript) v1 entered maintenance mode, and has reached End-of-Life on September 1st, 2024. If you are still using v1, we strongly recommend you to upgrade to the latest version."
1111

1212
Given our commitment to all of our customers using Powertools for AWS Lambda (TypeScript), we will keep npm v1 releases and documentation 1.x versions to prevent any disruption.
1313

examples/app/README.md

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,61 @@
22

33
This is a deployable CDK app that deploys AWS Lambda functions as part of a CloudFormation stack. These Lambda functions use the utilities made available as part of Powertools for AWS Lambda (TypeScript) to demonstrate their usage.
44

5-
> **Note**
6-
> You will need to have a valid AWS Account in order to deploy these resources. These resources may incur costs to your AWS Account. The cost from **some services** are covered by the [AWS Free Tier](https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&all-free-tier.sort-order=asc&awsf.Free%20Tier%20Types=*all&awsf.Free%20Tier%20Categories=*all) but not all of them. If you don't have an AWS Account follow [these instructions to create one](https://aws.amazon.com/premiumsupport/knowledge-center/create-and-activate-aws-account/).
5+
> [!Warning]
6+
> You will need to have a valid AWS Account in order to deploy these resources. Many of the services in the example are covered [AWS Free Tier](https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&all-free-tier.sort-order=asc&awsf.Free%20Tier%20Types=*all&awsf.Free%20Tier%20Categories=*all) but you may incur charges if you exceed the free tier limits.
7+
If you don't have an AWS Account follow [these instructions to create one](https://aws.amazon.com/premiumsupport/knowledge-center/create-and-activate-aws-account/).
78

89
The example functions, located in the `functions` folder, are frontend by a REST API that is deployed using AWS API Gateway.
910

1011
The API has three endpoints:
1112

12-
* `POST /` - Adds an item to the DynamoDB table
13-
* `GET /` - Retrieves all items from the DynamoDB table
14-
* `GET /{id}` - Retrieves a specific item from the DynamoDB table
13+
* `POST /` - Adds an item to the DynamoDB table
14+
* `GET /` - Retrieves all items from the DynamoDB table
15+
* `GET /{id}` - Retrieves a specific item from the DynamoDB table
1516

1617
## Deploying the stack
1718

18-
* Navigate to this location of the repo in your terminal (`examples/cdk`)
19-
* `npm ci`
20-
* `npm run cdk deploy --all --profile <YOUR_AWS_PROFILE>`
19+
> [!Note]
20+
> The `examples/app` directory where this example is located is part of a monorepo. If you are interested in deploying the example only, follow the instructions below.
21+
> If instead you are working on the monorepo and want to deploy the example, follow the instructions in the [CONTRIBUTING](../../CONTRIBUTING.md#dev-setup) doc, then run `npm run cdk deploy -w examples/app` from the project's root.
2122
22-
Note: Prior to deploying you may need to run `cdk bootstrap aws://<YOU_AWS_ACCOUNT_ID>/<AWS_REGION> --profile <YOUR_AWS_PROFILE>` if you have not already bootstrapped your account for CDK.
23+
If this is the first time you're using CDK in your AWS Account & AWS Region, you may need to run `npm run cdk bootstrap aws://<YOU_AWS_ACCOUNT_ID>/<AWS_REGION> --profile <YOUR_AWS_PROFILE>` to bootstrap your account for CDK.
2324

24-
> **Note**
25-
> You can find your API Gateway Endpoint URL in the output values displayed after deployment.
25+
Then, still from within the `examples/app` directory, run the following commands:
26+
27+
* `npm i --prefix ./` to install the dependencies
28+
* `npm run cdk deploy` and follow the prompts to deploy the stack
29+
30+
When the deployment is complete, you will see the output values that include the API Gateway Endpoint URL.
2631

2732
## Execute the functions via API Gateway
2833

2934
Use the API Gateway Endpoint URL from the output values to execute the functions. First, let's add two items to the DynamoDB Table by running:
3035

3136
```bash
32-
curl -XPOST --header 'Content-Type: application/json' --data '{"id":"myfirstitem","name":"Some Name for the first item"}' https://randomid12345.execute-api.eu-central-1.amazonaws.com/prod/
33-
curl -XPOST --header 'Content-Type: application/json' --data '{"id":"myseconditem","name":"Some Name for the second item"}' https://randomid1245.execute-api.eu-central-1.amazonaws.com/prod/
37+
curl -XPOST --header 'Content-Type: application/json' --data '{"id":"myfirstitem","name":"Some Name for the first item"}' https://<api-id>.execute-api.eu-central-1.amazonaws.com/prod/
38+
curl -XPOST --header 'Content-Type: application/json' --data '{"id":"myseconditem","name":"Some Name for the second item"}' https://<api-id>.execute-api.eu-central-1.amazonaws.com/prod/
3439
````
3540

3641
Now, let's retrieve all items by running:
3742
3843
```sh
39-
curl -XGET https://randomid12345.execute-api.eu-central-1.amazonaws.com/prod/
44+
curl -XGET https://<api-id>.execute-api.eu-central-1.amazonaws.com/prod/
4045
```
4146
4247
And finally, let's retrieve a specific item by running:
48+
4349
```bash
44-
curl -XGET https://randomid12345.execute-api.eu-central-1.amazonaws.com/prod/myseconditem/
50+
curl -XGET https://<api-id>.execute-api.eu-central-1.amazonaws.com/prod/myseconditem/
4551
```
4652

4753
## Observe the outputs in AWS CloudWatch & X-Ray
4854

4955
### CloudWatch
5056

5157
If we check the logs in CloudWatch, we can see that the logs are structured like this
52-
```
58+
59+
```text
5360
2022-04-26T17:00:23.808Z e8a51294-6c6a-414c-9777-6b0f24d8739b DEBUG
5461
{
5562
"level": "DEBUG",
@@ -62,10 +69,11 @@ If we check the logs in CloudWatch, we can see that the logs are structured like
6269

6370
By having structured logs like this, we can easily search and analyse them in [CloudWatch Logs Insight](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AnalyzingLogData.html). Run the following query to get all messages for a specific `awsRequestId`:
6471

65-
````
72+
````text
6673
filter awsRequestId="bcd50969-3a55-49b6-a997-91798b3f133a"
6774
| fields timestamp, message
6875
````
76+
6977
### AWS X-Ray
7078

7179
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.
@@ -76,4 +84,4 @@ To delete the sample application that you created, run the command below while i
7684

7785
```bash
7886
cdk destroy
79-
```
87+
```

examples/app/cdk/example-stack.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { dirname, join } from 'node:path';
2+
import { fileURLToPath } from 'node:url';
13
import { RemovalPolicy, Stack, type StackProps } from 'aws-cdk-lib';
24
import { LambdaIntegration, RestApi } from 'aws-cdk-lib/aws-apigateway';
35
import {
@@ -21,6 +23,12 @@ import { StringParameter } from 'aws-cdk-lib/aws-ssm';
2123
import type { Construct } from 'constructs';
2224
import { FunctionWithLogGroup } from './function-with-logstream-construct.js';
2325

26+
// Get the current file URL
27+
const __filename = fileURLToPath(import.meta.url);
28+
29+
// Get the current directory
30+
const __dirname = dirname(__filename);
31+
2432
export class PowertoolsExampleStack extends Stack {
2533
public constructor(scope: Construct, id: string, props?: StackProps) {
2634
super(scope, id, props);
@@ -80,7 +88,7 @@ export class PowertoolsExampleStack extends Stack {
8088
* Because we are using ESM and tree shake, we create an optimized bundle.
8189
*/
8290
const putItemFn = new FunctionWithLogGroup(this, 'put-item-fn', {
83-
entry: './functions/put-item.ts',
91+
entry: join(__dirname, '..', './functions/put-item.ts'),
8492
functionName: 'powertools-example-put-item',
8593
bundling: {
8694
minify: true,
@@ -124,7 +132,7 @@ export class PowertoolsExampleStack extends Stack {
124132
* in a centralized way across all your functions.
125133
*/
126134
const getAllItemsFn = new FunctionWithLogGroup(this, 'get-all-items-fn', {
127-
entry: './functions/get-all-items.ts',
135+
entry: join(__dirname, '..', './functions/get-all-items.ts'),
128136
functionName: 'powertools-example-get-all-items',
129137
layers: [powertoolsLayer], // we use the powertools layer
130138
bundling: {
@@ -150,7 +158,7 @@ export class PowertoolsExampleStack extends Stack {
150158
* dependencies in it.
151159
*/
152160
const getByIdFn = new FunctionWithLogGroup(this, 'get-by-id-fn', {
153-
entry: './functions/get-by-id.ts',
161+
entry: join(__dirname, '..', './functions/get-by-id.ts'),
154162
functionName: 'powertools-example-get-by-id',
155163
bundling: {
156164
minify: true,
@@ -172,7 +180,7 @@ export class PowertoolsExampleStack extends Stack {
172180
this,
173181
'process-items-stream-fn',
174182
{
175-
entry: './functions/process-items-stream.ts',
183+
entry: join(__dirname, '..', './functions/process-items-stream.ts'),
176184
functionName: 'powertools-example-process-items-stream',
177185
layers: [powertoolsLayer],
178186
bundling: {

examples/app/functions/commons/helpers/scan-items.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { DebugLogger } from '#types';
66
/**
77
* Scan the DynamoDB table and return all items.
88
*
9-
* @note this function is purposefully not paginated to keep the example simple
9+
* this function is purposefully not paginated to keep the example simple
1010
*
1111
* @param logger A logger instance
1212
*/

examples/app/jest.config.cjs

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)