Trying to deploy a Gatsby site with AWS CDK but the BucketDeployment always fails the error message:
CREATE_FAILED | Custom::CDKBucketDeployment | DeploySiteCustomResourceE47C9748 Received response status [FAILED] from custom resource. Message returned: Command '['/opt/awscli/aws', 's3', 'cp', 's3://cdk-xxxXXXXX-assets-xxx/assets/xxxXXXXXXXX.zip', '/tmp/tmpXXX/XXXXX']' died with <Signals.SIGKILL: 9>
The size of the file is only 163MB so does not exceed the 500MB limit.
Using the gatsby-plugin-s3 I was able to get an error to say that the site had more than 50 routing rules.
How can I get around this with the CDK? I have tried using website-redirect-location but that isn't working either.
bucket deployment
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"}
});
The lambda responsible for unzipping the archive and copying the contents to the destination crashed because it ran out of memory.
Increase its memory with memoryLimit
when creating your BucketDeployment
construct. By default, the lambda gets 128MB of memory, which is insufficient in your case.