Skip to content

Commit dc47557

Browse files
fix(layer): remove urllib3 from the Lambda layer again (#8556)
Restore the layer cleanup that removes urllib3 together with the other boto3 dependencies, so functions keep using the urllib3 shipped by the Lambda runtime. Relax the auth extras pin to urllib3>=2.7.0, the version the runtime ships today, and document that the layer relies on the runtime copy. Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
1 parent ce161fd commit dc47557

6 files changed

Lines changed: 15 additions & 10 deletions

File tree

‎docs/utilities/auth.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ pip install "aws-lambda-powertools[jwt]"
3838

3939
The `jwt` extra installs PyJWT, cryptography, and urllib3. Build dependencies for the same Python version and architecture as your Lambda function. See [cross-platform builds](../build_recipes/cross-platform.md).
4040

41+
???+ note "Using the Lambda layer"
42+
The Powertools for AWS Lambda layer does not include urllib3. With the layer, this utility uses the urllib3 that comes with the Lambda runtime. To control the urllib3 version yourself, install the `jwt` extra and package it with your function.
43+
4144
#### Compatibility with boto3
4245

4346
If the function also uses boto3, including through Parameters, install and validate the SDK together with JWT verification:

‎docs/utilities/oauth2.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ pip install "aws-lambda-powertools[oauth2]"
4040

4141
The `oauth2` extra installs urllib3; PyJWT and cryptography are not required.
4242

43+
???+ note "Using the Lambda layer"
44+
The Powertools for AWS Lambda layer does not include urllib3. With the layer, this utility uses the urllib3 that comes with the Lambda runtime. To control the urllib3 version yourself, install the `oauth2` extra and package it with your function.
45+
4346
#### Compatibility with boto3
4447

4548
If the function also uses boto3, including through Parameters, install and validate the SDK together with OAuth:

‎layer_v3/docker/Dockerfile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ RUN CFLAGS="-Os -g0 -s" pip install -t /asset/python "aws-lambda-powertools${PAC
3535
RUN cd /asset/python && \
3636
# remove boto3 and botocore (already available in Lambda Runtime)
3737
rm -rf boto* && \
38-
# retain urllib3: Auth requires its declared version, independently of the runtime SDK
39-
rm -rf s3transfer* *dateutil* six* jmespath* && \
38+
# remove boto3 dependencies (already available in Lambda Runtime)
39+
rm -rf s3transfer* *dateutil* urllib3* six* jmespath* && \
4040
# remove debugging symbols
4141
find . -name '*.so' -type f -exec strip "{}" \; && \
4242
# remove tests

‎pyproject.toml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ valkey = [
6262
jwt = [
6363
"pyjwt (>=2.14.0,<3.0.0)",
6464
"cryptography (>=50.0.1,<51.0.0)",
65-
"urllib3 (>=2.8.0,<3.0.0)",
65+
"urllib3 (>=2.7.0,<3.0.0)",
6666
]
6767
oauth2 = [
68-
"urllib3 (>=2.8.0,<3.0.0)",
68+
"urllib3 (>=2.7.0,<3.0.0)",
6969
]
7070
all = [
7171
"pydantic (>=2.4.0,<3.0.0)",
@@ -76,7 +76,7 @@ all = [
7676
"jsonpath-ng (>=1.6.0,<2.0.0)",
7777
"pyjwt (>=2.14.0,<3.0.0)",
7878
"cryptography (>=50.0.1,<51.0.0)",
79-
"urllib3 (>=2.8.0,<3.0.0)",
79+
"urllib3 (>=2.7.0,<3.0.0)",
8080
]
8181
aws-sdk = [
8282
"boto3 (>=1.34.32,<2.0.0)",

‎tests/e2e/utils/lambda_layer/powertools_layer.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ def __init__(self, output_dir: Path = CDK_OUT_PATH, architecture: Architecture =
3030
self.build_command = f"python -m pip install {self.package} {self.build_args} --target {self.target_dir}"
3131
self.cleanup_command = (
3232
f"rm -rf {self.target_dir}/boto* {self.target_dir}/s3transfer* && "
33-
# Auth's declared urllib3 dependency must survive Layer cleanup.
34-
f"rm -rf {self.target_dir}/*dateutil* {self.target_dir}/six* && "
33+
f"rm -rf {self.target_dir}/*dateutil* {self.target_dir}/urllib3* {self.target_dir}/six* && "
3534
f"rm -rf {self.target_dir}/jmespath* && "
3635
f"find {self.target_dir} -name '*.so' -type f -exec strip '{{}}' \\; && "
3736
f"find {self.target_dir} -wholename '*/tests/*' -type f -delete && "

‎uv.lock‎

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)