(@aws-cdk/aws-s3module) Resource handler returned message: "Uploaded file must be a non-empty zip"
The Question
Hi I had tried few node versions mentioned below still appearing the same issue anyone can help me ?
Environment
- CDK CLI Version: 1.59.0,1.85,1.70,1.105.0
- Node.js Version: node 14.2.0,14.3.0,14.15.0,14.15.1,14.15.2,14.15.3,14.16.1,14.15.4,14.17.0,15.5.1,16.2.0
- OS: Windows 10
- Language (Version): TypeScript (4.2.4)
Other information
new S3Deployment.BucketDeployment(this, 'Deployment', { sources: [S3Deployment.Source.asset('.path')], destinationBucket: bucket });
Hey @max258-new, I see that you're inputting .path as your Source.asset. Do you have a local directory named path in your project? If so, you should input S3Deployment.Source.asset('./path') to the sources property.
What do you have in your path directory? What are you trying to use as the source?
We had a bug that used to cause this, but it's since been fixed. Check out this thread for more info to see if any of the advice might help you after confirming you've set everything up correctly. You say you did use v1.85 which is the version this bug was present on, so this could be the case
Hey @peterwoodworth Thanks for your response. in that line I have
sources: [S3Deployment.Source.asset('./src/script/')]
this path.
I went that thread earlier and I tried out versions mentioned over there but it shows the same error.
Did you also do these two things?
Delete the cached asset in the cdk.out/ directory. You could safely delete the entire directory, and the correct assets and templates will be re-generated during the next run of cdk synth or cdk deploy
Delete the previously uploaded asset from the staging bucket. The S3 key of the asset will be prefixed with asset/ and have the hash of the asset. The hash of the asset can be found in your application's CloudFormation template. The staging bucket can be obtained by running the following command - aws cloudformation describe-stack-resources --stack-name CDKToolkit --logical-resource-id StagingBucket --query 'StackResources[].PhysicalResourceId'
This might be unrelated, but I am seeing this issue as well when using Node 16. Here are the contents of the Node-zipped lambdas:
Node 14.17.0:

Node 16.2.0:

Node 16.3.0:

Only the lambda in the archive created through Node 14.17.0 is accepted when I attempt to deploy via AWS CDK, and it is the only archive content that displays a non-zero size; the other archives are rejected with the same message that @max258-new posted. I suspect that this might be due to the changes that are at the base of the Node issue here; if this is the case, then the Node-based CDK code might need to be updated for use with Node 16 at some point.
Turns out the workaround for my issue is this. The underlying dependency has already been fixed and upgraded; it would be good to incorporate the updated archiver dependency in CDK's package.json once the version bumps make their way up the chain.
Check out this thread for more info
Thanks for your research and input into this @severn-everett, did you check the thread I linked above too? That has a bunch of good info in it, including the solution you found. I know you've already fixed the issue, but I'm linking it in case you're curious and want to see more info :p
@max258-new are you still dealing with this issue?
Please ping me if you're still encountering this issue, thanks!
⚠️COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.