CDK部署Gatsby站点超过50条路由规则

CDK deploy Gatsby site exceeds 50 routing rules

正在尝试使用 AWS CDK 部署 Gatsby 站点,但 BucketDeployment 始终失败并显示错误消息:

CREATE_FAILED | Custom::CDKBucketDeployment | DeploySiteCustomResourceE47C9748 Received response status [FAILED] from custom resource. Message returned: Command '['/opt/awscli/aws', 's3', 'cp', 's3://cdk-XXXXX-assets-XXXXXX-eu-west-2/assets/XXXXXXXX.zip', '/tmp/tmpXXX/XXXXX']' died with <Signals.SIGKILL: 9>

文件大小只有 163MB,所以没有超过 500MB 的限制。

使用 gatsby-plugin-s3 我能够得到一个错误,说该站点有超过 50 个路由规则。

如何使用 CDK 解决这个问题?我试过使用 website-redirect-location 但这也不起作用。

桶部署

const bucket = new s3.Bucket(this, "Testbucket", {
  bucketName: "my-test-bucket",
  publicReadAccess: true,
  removalPolicy: cdk.RemovalPolicy.DESTROY,
  websiteIndexDocument: "index.html"
});

new s3Deploy.BucketDeployment(this, "DeploySite", {
  sources: [s3Deploy.Source.asset("../gatsby-site/public")],
  destinationBucket: bucket,
  metadata: { "website-redirect-location": "index.html"}
});

负责解压缩存档并将内容复制到目标的 lambda 崩溃,因为它 运行 内存不足。

在创建 BucketDeployment 构造时,使用 memoryLimit 增加其内存。默认情况下,lambda 获得 128MB 内存,这在您的情况下是不够的。