Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
504 views
in Technique[技术] by (71.8m points)

amazon web services - AWS CDK S3 Deployment Error - Uploaded file must be a non-empty zip

I am trying to upload a static webpage onto s3 utilizing the AWS CDK with the S3 and S3 Deployment modules. The issue is that the deployment goes well until I get an error that states that the uploaded file must be a non-empty zip. the documentation indicates that I should be able to use a directory, but I've tried it with a zip as well and the same error persists. Not sure how to proceed.

enter image description here

import * as CDK from "@aws-cdk/core";
import * as S3 from "@aws-cdk/aws-s3";
import * as S3Deployment from "@aws-cdk/aws-s3-deployment";

const path = "../website.zip";

export class WebsiteStack extends CDK.Stack {
     constructor(app: CDK.App, id: string, props?: CDK.StackProps) {
      super(app, id, props);

const bucket = new S3.Bucket(this, "Files", {
  websiteIndexDocument: "index.html",
  publicReadAccess: true,
});

new S3Deployment.BucketDeployment(this, "Deployment", {
  sources: [S3Deployment.Source.asset(path)],
  destinationBucket: bucket,
  
});

new CDK.CfnOutput(this, "BucketDomain", {
  value: bucket.bucketWebsiteDomainName,
});

} }

question from:https://stackoverflow.com/questions/65945968/aws-cdk-s3-deployment-error-uploaded-file-must-be-a-non-empty-zip

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If you are doing this in early 2021, check what version of NodeJS you are using. If it's 15.6 or newer, a bug was introduced that broke the way .zip files are built which causes this error.

The CDK bug is #12536 and the upstream NodeJS bug is #37027.

As of 2021-02-09, NodeJS 15.8 has been released which does not yet include the fix.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...