Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(@aws-cdk/aws-s3module) Resource handler returned message: "Uploaded file must be a non-empty zip" #14843

Closed
max258-new opened this issue May 23, 2021 · 8 comments
Assignees
Labels
guidance Question that needs advice or information.

Comments

@max258-new
Copy link

max258-new commented May 23, 2021

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
});

@max258-new max258-new added guidance Question that needs advice or information. needs-triage This issue or PR still needs to be triaged. labels May 23, 2021
@max258-new max258-new changed the title Resource handler returned message: "Uploaded file must be a non-empty zip" (@aws-cdk/aws-s3module) Resource handler returned message: "Uploaded file must be a non-empty zip" May 24, 2021
@peterwoodworth
Copy link
Contributor

peterwoodworth commented May 24, 2021

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

@peterwoodworth peterwoodworth self-assigned this May 24, 2021
@peterwoodworth peterwoodworth added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels May 24, 2021
@max258-new
Copy link
Author

max258-new commented May 25, 2021

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.

@peterwoodworth
Copy link
Contributor

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'

@severn-everett
Copy link

severn-everett commented Jun 3, 2021

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:
AWS_Lambda_Node_14_17_0

Node 16.2.0:
AWS_Lambda_Node_16_2_0

Node 16.3.0:
AWS_Lambda_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.

@severn-everett
Copy link

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.

@peterwoodworth
Copy link
Contributor

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?

@peterwoodworth
Copy link
Contributor

Please ping me if you're still encountering this issue, thanks!

@peterwoodworth peterwoodworth removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Jun 7, 2021
@github-actions
Copy link

github-actions bot commented Jun 7, 2021

⚠️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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
guidance Question that needs advice or information.
Projects
None yet
Development

No branches or pull requests

3 participants