Skip to content

Commit 2295b0b

Browse files
authored
Merge branch 'main' into 2122-not-throw-full-batch-failure
2 parents 37bd666 + d76eb1d commit 2295b0b

File tree

72 files changed

+1907
-2124
lines changed

Some content is hidden

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

72 files changed

+1907
-2124
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ body:
6969
options:
7070
- 20.x
7171
- 18.x
72-
- 16.x
7372
validations:
7473
required: true
7574
- type: dropdown

.github/actions/cached-node-modules/action.yml

-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ outputs:
1414
runs:
1515
using: "composite"
1616
steps:
17-
- name: Install npm
18-
# We need to keep this npm version until we drop Node.js 16 support because Node.js 16 doesn't support npm 10
19-
run: npm i -g npm@next-9
20-
shell: bash
2117
- name: Cache node modules
2218
id: cache-node-modules
2319
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0

.github/dependabot.yml

+8-4
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,18 @@ updates:
3636
- dependency-name: "@middy/core"
3737
update-types: [ "version-update:semver-major" ]
3838
groups:
39-
aws-sdk:
39+
aws-sdk-v3:
4040
patterns:
41-
- "@aws-sdk/**"
42-
- "@smithy/**"
41+
- "@aws-sdk/*"
42+
- "@smithy/*"
4343
- "aws-sdk-client-mock"
4444
- "aws-sdk-client-mock-jest"
4545
aws-cdk:
4646
patterns:
47-
- "@aws-cdk/**"
47+
- "@aws-cdk/*"
4848
- "aws-cdk-lib"
4949
- "aws-cdk"
50+
typedoc:
51+
patterns:
52+
- "typedoc"
53+
- "typedoc-plugin-*"

.github/workflows/codeql.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
schedule:
9+
- cron: "0 0 * * 1"
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
analyze:
16+
name: Analyze
17+
runs-on: ubuntu-latest
18+
permissions:
19+
actions: read
20+
contents: read
21+
security-events: write
22+
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
language: ["typescript"]
27+
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
31+
32+
# Initializes the CodeQL tools for scanning.
33+
- name: Initialize CodeQL
34+
uses: github/codeql-action/init@e5f05b81d5b6ff8cfa111c80c22c5fd02a384118 # v3.23.0
35+
with:
36+
languages: ${{ matrix.language }}
37+
38+
- name: Setup NodeJS
39+
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
40+
with:
41+
node-version: ${{ matrix.version }}
42+
cache: "npm"
43+
- name: Setup dependencies
44+
uses: ./.github/actions/cached-node-modules
45+
with:
46+
nodeVersion: 20
47+
48+
- name: Perform CodeQL Analysis
49+
uses: github/codeql-action/analyze@e5f05b81d5b6ff8cfa111c80c22c5fd02a384118 # v3.23.0
50+
with:
51+
category: "/language:${{matrix.language}}"

.github/workflows/ossf_scorecard.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ jobs:
4343

4444
# Upload the results to GitHub's code scanning dashboard.
4545
- name: "Upload to code-scanning"
46-
uses: github/codeql-action/upload-sarif@23acc5c183826b7a8a97bce3cecc52db901f8251 # v3.25.10
46+
uses: github/codeql-action/upload-sarif@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11
4747
with:
4848
sarif_file: results.sarif

.github/workflows/reusable-run-linting-check-and-unit-tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
NODE_ENV: dev
1414
strategy:
1515
matrix:
16-
version: [16, 18, 20]
16+
version: [18, 20]
1717
fail-fast: false
1818
steps:
1919
- name: Checkout code

.github/workflows/reusable_deploy_layer_stack.yml

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ jobs:
4141
"us-west-2",
4242
"ap-east-1",
4343
"ap-south-1",
44+
"ap-south-2",
4445
"ap-northeast-1",
4546
"ap-northeast-2",
4647
"ap-northeast-3",
@@ -57,6 +58,7 @@ jobs:
5758
"eu-south-2",
5859
"eu-north-1",
5960
"sa-east-1",
61+
"me-central-1",
6062
"me-south-1",
6163
"il-central-1",
6264
]

.github/workflows/run-e2e-tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
packages/parameters,
3333
packages/idempotency,
3434
]
35-
version: [16, 18, 20]
35+
version: [18, 20]
3636
arch: [x86_64, arm64]
3737
fail-fast: false
3838
steps:

.github/workflows/secure-workflows.yml

+1-1
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@74606c30450304eee8660aae751818321754feb1 # v3.0.9
35+
uses: zgosalvez/github-actions-ensure-sha-pinned-actions@b88cd0aad2c36a63e42c71f81cb1958fed95ac87 # v3.0.10
3636
with:
3737
allowlist: slsa-framework/slsa-github-generator

docs/core/logger.md

+20
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,26 @@ We prioritise log level settings in this order:
519519

520520
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.
521521

522+
### Setting timestamp to custom Timezone
523+
524+
By default, Logger emits records with the default Lambda timestamp in **UTC**, i.e. `2016-06-20T12:08:10.000Z`
525+
526+
If you prefer to log in a specific timezone, you can configure it by setting the `TZ` environment variable. You can do this either as an environment variable or directly within your Lambda function settings.
527+
528+
[Click here](https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-runtime){target="_blank"} for a comprehensive list of available Lambda environment variables.
529+
530+
=== "customTimezone.ts"
531+
532+
```typescript hl_lines="8"
533+
--8<-- "examples/snippets/logger/customTimezone.ts"
534+
```
535+
536+
=== "customTimezoneOutput.json"
537+
538+
```json hl_lines="7 15"
539+
--8<-- "examples/snippets/logger/customTimezoneOutput.json"
540+
```
541+
522542
### Using multiple Logger instances across your code
523543

524544
The `createChild` method allows you to create a child instance of the Logger, which inherits all of the attributes from its parent. You have the option to override any of the settings and attributes from the parent logger, including [its settings](#utility-settings), any [extra keys](#appending-additional-keys), and [the log formatter](#custom-log-formatter-bring-your-own-formatter).

docs/index.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ You can use Powertools for AWS Lambda (TypeScript) by installing it with your fa
250250

251251
[Lambda Layer](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html){target="_blank"} is a `.zip` file archive that can contain additional code, pre-packaged dependencies, data, or configuration files. We compile and optimize [all dependencies](#install) to achieve an optimal build.
252252

253-
You can use the Lambda Layer both with CommonJS and ESM (ECMAScript modules) for Node.js 18.x and newer runtimes. **If you are using the managed Node.js 16.x runtime and cannot upgrade, you should use the CommonJS version only**.
253+
You can use the Lambda Layer both with CommonJS and ESM (ECMAScript modules) for Node.js 18.x and newer runtimes.
254254

255255
??? note "Click to expand and copy any regional Lambda Layer ARN"
256256
| Region | Layer ARN |
@@ -260,6 +260,7 @@ You can use the Lambda Layer both with CommonJS and ESM (ECMAScript modules) for
260260
| `us-west-1` | [arn:aws:lambda:us-west-1:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:8](#){: .copyMe}:clipboard: |
261261
| `us-west-2` | [arn:aws:lambda:us-west-2:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:8](#){: .copyMe}:clipboard: |
262262
| `ap-south-1` | [arn:aws:lambda:ap-south-1:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:8](#){: .copyMe}:clipboard: |
263+
| `ap-south-2` | [arn:aws:lambda:ap-south-2:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:8](#){: .copyMe}:clipboard: |
263264
| `ap-east-1` | [arn:aws:lambda:ap-east-1:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:8](#){: .copyMe}:clipboard: |
264265
| `ap-northeast-1` | [arn:aws:lambda:ap-northeast-1:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:8](#){: .copyMe}:clipboard: |
265266
| `ap-northeast-2` | [arn:aws:lambda:ap-northeast-2:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:8](#){: .copyMe}:clipboard: |
@@ -281,6 +282,7 @@ You can use the Lambda Layer both with CommonJS and ESM (ECMAScript modules) for
281282
| `sa-east-1` | [arn:aws:lambda:sa-east-1:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:8](#){: .copyMe}:clipboard: |
282283
| `af-south-1` | [arn:aws:lambda:af-south-1:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:8](#){: .copyMe}:clipboard: |
283284
| `me-south-1` | [arn:aws:lambda:me-south-1:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:8](#){: .copyMe}:clipboard: |
285+
| `me-central-1` | [arn:aws:lambda:me-central-1:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:8](#){: .copyMe}:clipboard: |
284286
| `il-central-1` | [arn:aws:lambda:il-central-1:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:8](#){: .copyMe}:clipboard: |
285287

286288
**Want to inspect the contents of the Layer?**

docs/overrides/main.html

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
{% endblock %}
99

1010
{% block announce %}
11-
Starting from July 1, 2024 we will end support for Node.js 16. Learn more <a
12-
href="https://github.com/aws-powertools/powertools-lambda-typescript/issues/2223" target="_blank">here</a>.
11+
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
13+
End-of-Life</a>. We recommend you to <a href="https://docs.powertools.aws.dev/lambda/typescript/latest/upgrade/"
14+
target="_blank">upgrade to v2</a>.
1315
{% endblock %}

docs/requirements.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
mike==1.1.2
2-
mkdocs-material==9.5.27
2+
mkdocs-material==9.5.28
33
mkdocs-git-revision-date-plugin==0.3.2
44
mkdocs-exclude==1.0.2

docs/requirements.txt

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ babel==2.14.0 \
88
--hash=sha256:6919867db036398ba21eb5c7a0f6b28ab8cbc3ae7a73a44ebe34ae74a4e7d363 \
99
--hash=sha256:efb1a25b7118e67ce3a259bed20545c29cb68be8ad2c784c83689981b7a57287
1010
# via mkdocs-material
11-
certifi==2023.11.17 \
12-
--hash=sha256:9b469f3a900bf28dc19b8cfbf8019bf47f7fdd1a65a1d4ffb98fc14166beb4d1 \
13-
--hash=sha256:e036ab49d5b79556f99cfc2d9320b34cfbe5be05c5871b51de9329f0603b0474
11+
certifi==2024.7.4 \
12+
--hash=sha256:5a1e7645bc0ec61a09e26c36f6106dd4cf40c6db3a1fb6352b0244e7fb057c7b \
13+
--hash=sha256:c198e21b1289c2ab85ee4e67bb4b4ef3ead0892059901a8d5b622f24a1101e90
1414
# via requests
1515
charset-normalizer==3.3.2 \
1616
--hash=sha256:06435b539f889b1f6f4ac1758871aae42dc3a8c0e24ac9e60c2384973ad73027 \
@@ -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.27 \
239-
--hash=sha256:a7d4a35f6d4a62b0c43a0cfe7e987da0980c13587b5bc3c26e690ad494427ec0 \
240-
--hash=sha256:af8cc263fafa98bb79e9e15a8c966204abf15164987569bd1175fd66a7705182
238+
mkdocs-material==9.5.28 \
239+
--hash=sha256:9cba305283ad1600e3d0a67abe72d7a058b54793b47be39930911a588fe0336b \
240+
--hash=sha256:ff48b11b2a9f705dd210409ec3b418ab443dd36d96915bcba45a41f10ea27bfd
241241
# via -r requirements.in
242242
mkdocs-material-extensions==1.3.1 \
243243
--hash=sha256:10c9511cea88f568257f960358a467d12b970e1f7b2c0e5fb2bb48cab1928443 \

docs/upgrade.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ V2 is focused on official support for ESM (ECMAScript modules). We've made other
3131

3232
Before you start, we suggest making a copy of your current working project or create a new git branch.
3333

34-
1. Upgrade Node.js to v16 or higher, Node.js v20 is recommended.
34+
1. Upgrade Node.js to v18 or higher, Node.js v20 is recommended.
3535
2. Ensure that you have the latest Powertools for AWS Lambda (TypeScript) version via [Lambda Layer](./index.md#lambda-layer) or npm.
3636
3. Review the following sections to confirm whether they apply to your codebase.
3737

examples/app/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"jest": "^29.7.0",
4242
"source-map-support": "^0.5.21",
4343
"ts-jest": "^29.1.5",
44-
"tsx": "^4.15.7",
44+
"tsx": "^4.16.2",
4545
"typescript": "^5.4.5"
4646
},
4747
"dependencies": {
@@ -51,14 +51,14 @@
5151
"@aws-lambda-powertools/metrics": "^2.3.0",
5252
"@aws-lambda-powertools/parameters": "^2.3.0",
5353
"@aws-lambda-powertools/tracer": "^2.3.0",
54-
"@aws-sdk/client-ssm": "^3.603.0",
55-
"@aws-sdk/lib-dynamodb": "^3.602.0",
54+
"@aws-sdk/client-ssm": "^3.609.0",
55+
"@aws-sdk/lib-dynamodb": "^3.609.0",
5656
"@middy/core": "^4.7.0",
5757
"@types/aws-lambda": "^8.10.140",
5858
"@types/jest": "^29.5.12",
5959
"@types/node": "20.14.9",
6060
"constructs": "^10.3.0",
61-
"esbuild": "^0.21.5",
61+
"esbuild": "^0.23.0",
6262
"jest": "^29.7.0",
6363
"ts-jest": "^29.1.5",
6464
"ts-node": "^10.9.2",
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Logger } from '@aws-lambda-powertools/logger';
2+
3+
const logger = new Logger({ serviceName: 'serverlessAirline' });
4+
5+
export const handler = async (): Promise<void> => {
6+
logger.info('Hello, World!');
7+
8+
process.env.TZ = 'Europe/Rome';
9+
10+
const childLogger = logger.createChild();
11+
12+
childLogger.info('Ciao, Mondo!');
13+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[
2+
{
3+
"level": "INFO",
4+
"message": "Hello, World!",
5+
"sampling_rate": 0,
6+
"service": "serverlessAirline",
7+
"timestamp": "2024-07-01T11:00:37.886Z",
8+
"xray_trace_id": "1-66828c55-2bb635c65eb609c820ebe7bc"
9+
},
10+
{
11+
"level": "INFO",
12+
"message": "Ciao, Mondo!",
13+
"sampling_rate": 0,
14+
"service": "serverlessAirline",
15+
"timestamp": "2024-07-01T13:00:37.934+02:00",
16+
"xray_trace_id": "1-66828c55-2bb635c65eb609c820ebe7bc"
17+
}
18+
]

examples/snippets/package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@
3737
"@aws-lambda-powertools/parameters": "^2.3.0",
3838
"@aws-lambda-powertools/parser": "^2.3.0",
3939
"@aws-lambda-powertools/tracer": "^2.3.0",
40-
"@aws-sdk/client-appconfigdata": "^3.600.0",
41-
"@aws-sdk/client-dynamodb": "^3.602.0",
42-
"@aws-sdk/client-secrets-manager": "^3.600.0",
43-
"@aws-sdk/client-ssm": "^3.603.0",
44-
"@aws-sdk/util-dynamodb": "^3.602.0",
40+
"@aws-sdk/client-appconfigdata": "^3.609.0",
41+
"@aws-sdk/client-dynamodb": "^3.609.0",
42+
"@aws-sdk/client-secrets-manager": "^3.609.0",
43+
"@aws-sdk/client-ssm": "^3.609.0",
44+
"@aws-sdk/util-dynamodb": "^3.609.0",
4545
"@middy/core": "^4.7.0",
46-
"aws-sdk": "^2.1649.0",
46+
"aws-sdk": "^2.1652.0",
4747
"aws-sdk-client-mock": "^4.0.1",
4848
"aws-sdk-client-mock-jest": "^4.0.1",
4949
"hashi-vault-js": "^0.4.15",

layers/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@
3838
"dependencies": {
3939
"aws-cdk": "^2.145.0",
4040
"aws-cdk-lib": "^2.145.0",
41-
"esbuild": "^0.21.5"
41+
"esbuild": "^0.23.0"
4242
}
4343
}

layers/src/canary-stack.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class CanaryStack extends Stack {
4141
'../tests/e2e/layerPublisher.class.test.functionCode.ts'
4242
),
4343
handler: 'handler',
44-
runtime: Runtime.NODEJS_16_X,
44+
runtime: Runtime.NODEJS_18_X,
4545
functionName: `canary-${suffix}`,
4646
timeout: Duration.seconds(30),
4747
bundling: {

layers/src/layer-publisher-stack.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ export class LayerPublisherStack extends Stack {
3636
this.lambdaLayerVersion = new LayerVersion(this, 'LambdaPowertoolsLayer', {
3737
layerVersionName: props?.layerName,
3838
description: `Powertools for AWS Lambda (TypeScript) version ${powertoolsPackageVersion}`,
39-
compatibleRuntimes: [
40-
Runtime.NODEJS_16_X,
41-
Runtime.NODEJS_18_X,
42-
Runtime.NODEJS_20_X,
43-
],
39+
compatibleRuntimes: [Runtime.NODEJS_18_X, Runtime.NODEJS_20_X],
4440
license: 'MIT-0',
4541
// This is needed because the following regions do not support the compatibleArchitectures property #1400
4642
// ...(![ 'eu-south-2', 'eu-central-2', 'ap-southeast-4' ].includes(Stack.of(this).region) ? { compatibleArchitectures: [Architecture.X86_64] } : {}),
@@ -105,7 +101,7 @@ export class LayerPublisherStack extends Stack {
105101
'node_modules/@aws-sdk/**/README.md ',
106102
];
107103
const buildCommands: string[] = [];
108-
// We need these modules because they are not included in the nodejs16x runtimes
104+
// We install these to get the latest version of the packages
109105
const modulesToInstall: string[] = [
110106
'@aws-sdk/client-dynamodb',
111107
'@aws-sdk/util-dynamodb',

layers/tests/e2e/layerPublisher.test.ts

+1-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
TestInvocationLogs,
1212
invokeFunctionOnce,
1313
generateTestUniqueName,
14-
getRuntimeKey,
1514
} from '@aws-lambda-powertools/testing-utils';
1615
import { TestNodejsFunction } from '@aws-lambda-powertools/testing-utils/resources/lambda';
1716
import {
@@ -48,13 +47,7 @@ describe(`Layers E2E tests`, () => {
4847
},
4948
});
5049

51-
/**
52-
* Node.js 16.x does not support importing ESM modules from Lambda Layers reliably.
53-
*
54-
* The feature is available in Node.js 18.x and later.
55-
* @see https://aws.amazon.com/blogs/compute/node-js-18-x-runtime-now-available-in-aws-lambda/
56-
*/
57-
const cases = getRuntimeKey() === 'nodejs16x' ? ['CJS'] : ['CJS', 'ESM'];
50+
const cases = ['CJS', 'ESM'];
5851
const invocationLogsMap: Map<(typeof cases)[number], TestInvocationLogs> =
5952
new Map();
6053

0 commit comments

Comments
 (0)