Skip to content

Commit 809e1b0

Browse files
authored
fix(lambda-python): poetry bundling fails on python3.7 (#21950)
For some reason when using the `python3.7` docker image the `useradd` command fails `/bin/sh: /sbin/useradd: No such file or directory`. I'm not sure why it works on 3.8 & 3.9 and not 3.7, but since that is not necessary I'm just removing it. I've added python3.7 to the integration test to confirm that it works for 3.7, 3.8, & 3.9 ---- ### All Submissions: * [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 4b37157 commit 809e1b0

15 files changed

+369
-161
lines changed

packages/@aws-cdk/aws-lambda-python/lib/Dockerfile

-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,4 @@ RUN mkdir /tmp/poetry-cache && \
3535
# set the poetry cache
3636
ENV POETRY_CACHE_DIR=/tmp/poetry-cache
3737

38-
# create non root user and change allow execute command for non root user
39-
RUN /sbin/useradd -u 1000 user && chmod 711 /
40-
4138
CMD [ "python" ]

packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/asset.c163659180107f6d900bb5a9138eb6a904d52ba2521d9252291ba353d5c5850a/.ignorefile

Whitespace-only changes.

packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/asset.c163659180107f6d900bb5a9138eb6a904d52ba2521d9252291ba353d5c5850a/index.py

-8
This file was deleted.

packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/asset.c163659180107f6d900bb5a9138eb6a904d52ba2521d9252291ba353d5c5850a/poetry.lock

-84
This file was deleted.

packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/asset.c163659180107f6d900bb5a9138eb6a904d52ba2521d9252291ba353d5c5850a/pyproject.toml

-15
This file was deleted.

packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/asset.c163659180107f6d900bb5a9138eb6a904d52ba2521d9252291ba353d5c5850a/requirements.txt

-15
This file was deleted.

packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/cdk-integ-lambda-python.assets.json

+22-9
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,54 @@
11
{
2-
"version": "20.0.0",
2+
"version": "21.0.0",
33
"files": {
4-
"c5ecdc350b1c0ecd1962c18d253a073e9284d01d20377458b71dbce88b3fae0d": {
4+
"377b8c7d7d74049daef959af1f7f0f0f2eaeb6ccb4c85fe80f8c00936183b6ff": {
55
"source": {
6-
"path": "asset.c5ecdc350b1c0ecd1962c18d253a073e9284d01d20377458b71dbce88b3fae0d",
6+
"path": "asset.377b8c7d7d74049daef959af1f7f0f0f2eaeb6ccb4c85fe80f8c00936183b6ff",
77
"packaging": "zip"
88
},
99
"destinations": {
1010
"current_account-current_region": {
1111
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12-
"objectKey": "c5ecdc350b1c0ecd1962c18d253a073e9284d01d20377458b71dbce88b3fae0d.zip",
12+
"objectKey": "377b8c7d7d74049daef959af1f7f0f0f2eaeb6ccb4c85fe80f8c00936183b6ff.zip",
1313
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
1414
}
1515
}
1616
},
17-
"5a96395d40e1786ddf393dfb827b961680519f476484b507011d2745c82ffd78": {
17+
"f27e50ce3e964bd188b2fad96e1819a8e68a7a7a17e1f701b6bdcc054e29503a": {
1818
"source": {
19-
"path": "asset.5a96395d40e1786ddf393dfb827b961680519f476484b507011d2745c82ffd78",
19+
"path": "asset.f27e50ce3e964bd188b2fad96e1819a8e68a7a7a17e1f701b6bdcc054e29503a",
2020
"packaging": "zip"
2121
},
2222
"destinations": {
2323
"current_account-current_region": {
2424
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
25-
"objectKey": "5a96395d40e1786ddf393dfb827b961680519f476484b507011d2745c82ffd78.zip",
25+
"objectKey": "f27e50ce3e964bd188b2fad96e1819a8e68a7a7a17e1f701b6bdcc054e29503a.zip",
2626
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
2727
}
2828
}
2929
},
30-
"69a465a4b05894359284e409dc3f2cc2208b03b032aa6d6f67b5a327b4b795e3": {
30+
"d165152de494c90bdd8c4aa643a5b1e99b2a5cbacb7f4594319b3b45d6845fd3": {
31+
"source": {
32+
"path": "asset.d165152de494c90bdd8c4aa643a5b1e99b2a5cbacb7f4594319b3b45d6845fd3",
33+
"packaging": "zip"
34+
},
35+
"destinations": {
36+
"current_account-current_region": {
37+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
38+
"objectKey": "d165152de494c90bdd8c4aa643a5b1e99b2a5cbacb7f4594319b3b45d6845fd3.zip",
39+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
40+
}
41+
}
42+
},
43+
"5187de9a41f36d4b41ca1553d50265326d21791726e2a3dd0a3201910180fc0f": {
3144
"source": {
3245
"path": "cdk-integ-lambda-python.template.json",
3346
"packaging": "file"
3447
},
3548
"destinations": {
3649
"current_account-current_region": {
3750
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
38-
"objectKey": "69a465a4b05894359284e409dc3f2cc2208b03b032aa6d6f67b5a327b4b795e3.json",
51+
"objectKey": "5187de9a41f36d4b41ca1553d50265326d21791726e2a3dd0a3201910180fc0f.json",
3952
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
4053
}
4154
}

packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/cdk-integ-lambda-python.template.json

+55-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"S3Bucket": {
3939
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
4040
},
41-
"S3Key": "c5ecdc350b1c0ecd1962c18d253a073e9284d01d20377458b71dbce88b3fae0d.zip"
41+
"S3Key": "377b8c7d7d74049daef959af1f7f0f0f2eaeb6ccb4c85fe80f8c00936183b6ff.zip"
4242
},
4343
"Role": {
4444
"Fn::GetAtt": [
@@ -91,7 +91,7 @@
9191
"S3Bucket": {
9292
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
9393
},
94-
"S3Key": "5a96395d40e1786ddf393dfb827b961680519f476484b507011d2745c82ffd78.zip"
94+
"S3Key": "f27e50ce3e964bd188b2fad96e1819a8e68a7a7a17e1f701b6bdcc054e29503a.zip"
9595
},
9696
"Role": {
9797
"Fn::GetAtt": [
@@ -105,6 +105,59 @@
105105
"DependsOn": [
106106
"myhandlerpython38ServiceRole2049AFF7"
107107
]
108+
},
109+
"myhandlerpython37ServiceRole45CBD18D": {
110+
"Type": "AWS::IAM::Role",
111+
"Properties": {
112+
"AssumeRolePolicyDocument": {
113+
"Statement": [
114+
{
115+
"Action": "sts:AssumeRole",
116+
"Effect": "Allow",
117+
"Principal": {
118+
"Service": "lambda.amazonaws.com"
119+
}
120+
}
121+
],
122+
"Version": "2012-10-17"
123+
},
124+
"ManagedPolicyArns": [
125+
{
126+
"Fn::Join": [
127+
"",
128+
[
129+
"arn:",
130+
{
131+
"Ref": "AWS::Partition"
132+
},
133+
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
134+
]
135+
]
136+
}
137+
]
138+
}
139+
},
140+
"myhandlerpython37C34039A7": {
141+
"Type": "AWS::Lambda::Function",
142+
"Properties": {
143+
"Code": {
144+
"S3Bucket": {
145+
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
146+
},
147+
"S3Key": "d165152de494c90bdd8c4aa643a5b1e99b2a5cbacb7f4594319b3b45d6845fd3.zip"
148+
},
149+
"Role": {
150+
"Fn::GetAtt": [
151+
"myhandlerpython37ServiceRole45CBD18D",
152+
"Arn"
153+
]
154+
},
155+
"Handler": "index.handler",
156+
"Runtime": "python3.7"
157+
},
158+
"DependsOn": [
159+
"myhandlerpython37ServiceRole45CBD18D"
160+
]
108161
}
109162
},
110163
"Outputs": {
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"20.0.0"}
1+
{"version":"21.0.0"}
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
{
2-
"version": "20.0.0",
2+
"version": "21.0.0",
33
"testCases": {
4-
"integ.function.poetry": {
4+
"poetry/DefaultTest": {
55
"stacks": [
66
"cdk-integ-lambda-python"
77
],
8-
"diffAssets": false,
9-
"stackUpdateWorkflow": false
8+
"stackUpdateWorkflow": false,
9+
"assertionStack": "poetry/DefaultTest/DeployAssert",
10+
"assertionStackName": "poetryDefaultTestDeployAssertE9C9CB8F"
1011
}
11-
},
12-
"synthContext": {},
13-
"enableLookups": false
12+
}
1413
}

packages/@aws-cdk/aws-lambda-python/test/function.poetry.integ.snapshot/manifest.json

+61-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "20.0.0",
2+
"version": "21.0.0",
33
"artifacts": {
44
"Tree": {
55
"type": "cdk:tree",
@@ -23,7 +23,7 @@
2323
"validateOnSynth": false,
2424
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
2525
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
26-
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/69a465a4b05894359284e409dc3f2cc2208b03b032aa6d6f67b5a327b4b795e3.json",
26+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/5187de9a41f36d4b41ca1553d50265326d21791726e2a3dd0a3201910180fc0f.json",
2727
"requiresBootstrapStackVersion": 6,
2828
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
2929
"additionalDependencies": [
@@ -75,6 +75,18 @@
7575
"data": "Python38FunctionName"
7676
}
7777
],
78+
"/cdk-integ-lambda-python/my_handler_python_37/ServiceRole/Resource": [
79+
{
80+
"type": "aws:cdk:logicalId",
81+
"data": "myhandlerpython37ServiceRole45CBD18D"
82+
}
83+
],
84+
"/cdk-integ-lambda-python/my_handler_python_37/Resource": [
85+
{
86+
"type": "aws:cdk:logicalId",
87+
"data": "myhandlerpython37C34039A7"
88+
}
89+
],
7890
"/cdk-integ-lambda-python/BootstrapVersion": [
7991
{
8092
"type": "aws:cdk:logicalId",
@@ -89,6 +101,53 @@
89101
]
90102
},
91103
"displayName": "cdk-integ-lambda-python"
104+
},
105+
"poetryDefaultTestDeployAssertE9C9CB8F.assets": {
106+
"type": "cdk:asset-manifest",
107+
"properties": {
108+
"file": "poetryDefaultTestDeployAssertE9C9CB8F.assets.json",
109+
"requiresBootstrapStackVersion": 6,
110+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
111+
}
112+
},
113+
"poetryDefaultTestDeployAssertE9C9CB8F": {
114+
"type": "aws:cloudformation:stack",
115+
"environment": "aws://unknown-account/unknown-region",
116+
"properties": {
117+
"templateFile": "poetryDefaultTestDeployAssertE9C9CB8F.template.json",
118+
"validateOnSynth": false,
119+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
120+
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
121+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
122+
"requiresBootstrapStackVersion": 6,
123+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
124+
"additionalDependencies": [
125+
"poetryDefaultTestDeployAssertE9C9CB8F.assets"
126+
],
127+
"lookupRole": {
128+
"arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}",
129+
"requiresBootstrapStackVersion": 8,
130+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
131+
}
132+
},
133+
"dependencies": [
134+
"poetryDefaultTestDeployAssertE9C9CB8F.assets"
135+
],
136+
"metadata": {
137+
"/poetry/DefaultTest/DeployAssert/BootstrapVersion": [
138+
{
139+
"type": "aws:cdk:logicalId",
140+
"data": "BootstrapVersion"
141+
}
142+
],
143+
"/poetry/DefaultTest/DeployAssert/CheckBootstrapVersion": [
144+
{
145+
"type": "aws:cdk:logicalId",
146+
"data": "CheckBootstrapVersion"
147+
}
148+
]
149+
},
150+
"displayName": "poetry/DefaultTest/DeployAssert"
92151
}
93152
}
94153
}

0 commit comments

Comments
 (0)