Luke Wyman
09/04/2021, 2:58 AMnpx sst deploy --stage test
of my monorepo app. CDK is in Typescript, Lambdas are in Python. Things had been pretty smooth with deploying/removing through this morning, and I haven't changed the CDK code in a couple days. Here's the error:
test-karaoke-auth | CREATE_FAILED | AWS::Lambda::Function | AuthpostConfirmation9638BE34 Resource handler returned message: "Could not unzip uploaded file. Please check your file, then try to upload again. (Service: Lambda, Status Code: 400, Request ID: 62093ef6-5fc4-4c34-9fc9-41f040129049, Extended Request ID: null)" (RequestToken: 7ff6ef6c-3053-e0bd-a668-dd1d985361bc, HandlerErrorCode: InvalidRequest)
Putting other failed Lambda here to preserve:
test-karaoke-singers | CREATE_FAILED | AWS::Lambda::Function | LambdaPUTkaraokesingerssingerId0B097659 Resource handler returned message: "Could not unzip uploaded file. Please check your file, then try to upload again. (Service: Lambda, Status Code: 400, Request ID: 78b004a4-77ed-4336-bc7e-4ce5c5eac1c4, Extended Request ID: null)" (RequestToken: 4529ae3a-b7be-a06a-e162-7a16afd056ee, HandlerErrorCode: InvalidRequest)
I did a complete deploy before my last git push and deploy and integration tests worked great. The only changes I've made this go around, are to add a non-infrastructure-related domain object with isolated unit tests.
It might be not related to sst, since I seem to also have a Python issue where modules in the same folder are not being recognized on imports, but that is happening throughout the project, and only a couple of Lambdas are being rejected on deploy.Frank
Luke Wyman
09/04/2021, 3:58 AMLuke Wyman
09/04/2021, 3:58 AMpip install -e .
was working great last night and this morning, and all of a sudden, my .py files can't find modules in that python environment.Luke Wyman
09/04/2021, 4:00 AMFrank
sst deploy
and gets this error, try this:
1. go into .build/cdk.out
2. open up the CF template for test-karaoke-auth
3. look up the asset file for the Post Confirmation lambda
4. find that asset zip
5. try manually unzipFrank
Luke Wyman
09/04/2021, 4:04 AMLuke Wyman
09/04/2021, 4:10 AM"AuthpostConfirmation9638BE34": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"ZipFile": "placeholder"
},
Frank
Frank
sst remove
so your Lambdas are not getting built on remove. And this is happening from running sst deploy
?Luke Wyman
09/04/2021, 4:15 AMFrank
Luke Wyman
09/04/2021, 4:22 AMtest-karaoke-auth.template.json
for the term "ZipFile" finds nothing.Luke Wyman
09/04/2021, 4:26 AM"AuthpostConfirmation9638BE34": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"S3Bucket": {
"Ref": "AssetParametersac4e6005b437cb3ac058af34adb98d4147d60091b897ce896f12457b6a7cc91eS3Bucket0FBA01FB"
},
"S3Key": {
"Fn::Join": [
"",
[
{
"Fn::Select": [
0,
{
"Fn::Split": [
"||",
{
"Ref": "AssetParametersac4e6005b437cb3ac058af34adb98d4147d60091b897ce896f12457b6a7cc91eS3VersionKey771BDE70"
}
]
}
]
},
{
"Fn::Select": [
1,
{
"Fn::Split": [
"||",
{
"Ref": "AssetParametersac4e6005b437cb3ac058af34adb98d4147d60091b897ce896f12457b6a7cc91eS3VersionKey771BDE70"
}
]
}
]
}
]
]
}
},
Luke Wyman
09/04/2021, 4:26 AMFrank
AssetParametersac4e6005b437cb3ac058af34adb98d4147d60091b897ce896f12457b6a7cc91eS3Bucket0FBA01FB
in ur CFN template?Luke Wyman
09/04/2021, 4:39 AM"AssetParametersac4e6005b437cb3ac058af34adb98d4147d60091b897ce896f12457b6a7cc91eS3Bucket0FBA01FB": {
"Type": "String",
"Description": "S3 bucket for asset \"ac4e6005b437cb3ac058af34adb98d4147d60091b897ce896f12457b6a7cc91e\""
}
Frank
ac4e6005b437cb3ac058af34adb98d4147d60091b897ce896f12457b6a7cc91e
in ur .build/cdk.out
?Luke Wyman
09/04/2021, 4:49 AM.template.json
files in cdk.out, and then 3 sub folders prefixed with asset.[some long string]
which contain copies of my .py
files.Frank
Luke Wyman
09/04/2021, 4:57 AMLuke Wyman
09/04/2021, 4:58 AMUserAttributes
from Cognito.Luke Wyman
09/04/2021, 4:59 AMLuke Wyman
09/04/2021, 5:02 AMLuke Wyman
09/04/2021, 5:25 AMFrank
AssetParametersac4e6005b437cb3ac058af34adb98d4147d60091b897ce896f12457b6a7cc91eS3Bucket0FBA01FB
S3 asset?Frank
Luke Wyman
09/04/2021, 10:32 PMAuthStack
and SingersStack
are the two stacks that fail to deploy due to the zip error complaint. They both point to the same folder for their Lambdas. I found the S3 asset, AssetParametersac4e6005b437cb3ac058af34adb98d4147d60091b897ce896f12457b6a7cc91eS3Bucket0FBA01FB
, in both stacks - once in Auth for the function it takes, and five times in Singers for the five functions it uses. I checked the other stacks to be sure, and those don't use that S3 asset.
Second, I did a little experiment, where I commented out the API routes in the Singers stack one by one:
singersApi.addRoutes(this, {
'POST /karaoke/singers': 'KAR_SNG_test_create_singer.handler',
'GET /karaoke/singers/{singerId}': 'KAR_SNG_get_singer_by_id.handler',
'GET /karaoke/singers': 'KAR_SNG_get_singers.handler',
'PUT /karaoke/singers/{singerId}': 'KAR_SNG_update_singer.handler',
'DELETE /karaoke/singers/{singerId}': 'KAR_SNG_delete_singer.handler',
});
...and then tried the deploy again after each comment-out. Each Lambda failed, one after the other:
AuthpostConfirmation9638BE34
LambdaPOSTkaraokesingers87AC2C24
LambdaGETkaraokesingerssingerId784287B5
LambdaGETkaraokesingersFED899AE
LambdaPUTkaraokesingerssingerId0B097659
LambdaDELETEkaraokesingerssingerIdF1924E8A
To summarize - that S3 asset only appears in the Auth and Singers stacks. They all point to the same folder, src/karaoke/singers
in my application code. So, every Lambda in that folder is failing.Frank
Frank
cdk-
, that’s the name of the S3 bucket;
• also note the parameter value for AssetParametersac4e6005b437cb3ac058af34adb98d4147d60091b897ce896f12457b6a7cc91eS3Bucket0FBA01FB
, that’s the S3 path to the Lambda zip
• now go to the S3 console and locate the file
• download it
• try unzip it
Let’s see if u can unzip the zip file; and what’s in it.Luke Wyman
09/05/2021, 9:54 PMAssetParametersac4e6005b437cb3ac058af34adb98d4147d60091b897ce896f12457b6a7cc91eS3Bucket0FBA01FB
is the Key to the S3 bucket, and AssetParametersac4e6005b437cb3ac058af34adb98d4147d60091b897ce896f12457b6a7cc91eS3VersionKey771BDE70
is the Key to the zip file, which is named assets/||ac4e6005b437cb3ac058af34adb98d4147d60091b897ce896f12457b6a7cc91e.zip
.
I downloaded the zip file and tried to unzip it locally with unzip ac4e6005b437cb3ac058af34adb98d4147d60091b897ce896f12457b6a7cc91e.zip
and got the following error message:
$ unzip ac4e6005b437cb3ac058af34adb98d4147d60091b897ce896f12457b6a7cc91e.zip
Archive: ac4e6005b437cb3ac058af34adb98d4147d60091b897ce896f12457b6a7cc91e.zip
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
unzip: cannot find zipfile directory in one of ac4e6005b437cb3ac058af34adb98d4147d60091b897ce896f12457b6a7cc91e.zip or
ac4e6005b437cb3ac058af34adb98d4147d60091b897ce896f12457b6a7cc91e.zip.zip, and cannot find ac4e6005b437cb3ac058af34adb98d4147d60091b897ce896f12457b6a7cc91e.zip.ZIP, period.
Luke Wyman
09/05/2021, 11:12 PMsite
folder outside of src
. Did a full deploy as a lark, and now everything works just fine.
Thanks for your help on this all the same. If there's still any information I can throw your way because this bug is important to sst, let me know.Frank
Frank
Luke Wyman
09/07/2021, 12:06 AMrotations_impl
branch, and I believe it was commit 67a7de9
"Pythonized app folder names with underscores" that unintentionally resolved the issue, maaaaaybe commit 1da2ce2
right before it.
A word of caution: there are issues around my Python packaging that may make it a bit of hit and miss to isolate the problem. I've been trying to create a package with a setup.py
, ___init___.py
etc so that my unit tests can "see" my domain objects they're testing. This has resulted in problems where Lambda can't see a package called karaoke.song_library.songs_db
, for example. So I'm deep in the weeds figuring out how to get unit tests, packaging and deployment to all play nicely together.
And here's the repo: https://github.com/lukewyman/karaoke-backend-sstSeth Geoghegan
02/03/2022, 4:57 PMstage-kas-KafkaIngest failed: Resource handler returned message: "Could not unzip uploaded file. Please check your file, then try to upload again. (Service: Lambda, Status Code: 400, Request ID: ac5a9bd2-16f3-4af3-ae44-381b1096f583, Extended Request ID: null)" (RequestToken: dbf205dc-7fe2-2ad4-ae90-21e999d258fe, HandlerErrorCode: InvalidRequest)
Seth Geoghegan
02/03/2022, 5:02 PMSeth Geoghegan
02/03/2022, 5:10 PM