aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.68k stars 3.93k forks source link

aws-s3-deployment: Bucket deployment keeps failing #21035

Closed lorefnon closed 2 years ago

lorefnon commented 2 years ago

Describe the bug

I am using aws-cdk v2 typescript to deploy a static site (s3 bucket fronted by cloudfront CDN)

When using CDK, my deployment randomly fails with an error like this:

FrontendStackDevelopment | 0/3 | 7:37:17 PM | UPDATE_FAILED        | Custom::CDKBucketDeployment          | DeployXXXGuiArtifacts/CustomResource/Default (DeployXXXGuiArtifactsCustomResourceE2848FD1) Received response status [FAILED] from custom resource. Message returned: Command '['/opt/awscli/aws', 's3', 'cp', 's3://cdk-hnb659fds-assets-039695708555-us-east-1/50f9943a577af662f6a08c723d8d2a45cfab94a5924e815dd394ad08a0880979.zip', '/tmp/tmpkwhkm871/e6e8d5d0-68bd-432f-bb99-ae7204c10423']' died with <Signals.SIGKILL: 9>. (RequestId: 6c90be26-e089-40e4-bba0-4f78ab68801a)

I assume that this has something to do with the size of the zip because as the artifact size has grown (currently ~110MB) this has become increasingly frequently. My last workflow run failed about 10 times before succeeding.

Expected Behavior

S3 deployment through CDK works reliably

Current Behavior

Frequent SIGKILL failures

Reproduction Steps

My (stripped-down) configuration looks like this:

export class FrontendStack extends cdk.Stack {
    s3Bucket = new s3.Bucket(this, "s3-bucket", {
        removalPolicy: cdk.RemovalPolicy.RETAIN,
        publicReadAccess: true,
        websiteIndexDocument: "index.html",
        versioned: false
    });

    cfDistribution = new cf.Distribution(this, 'cf-dist', { ... });

    s3BucketDeployment = new s3Dep.BucketDeployment(this, 'DeployXXXGuiArtifacts', {
        sources: [
          s3Dep.Source.asset("build-output.zip")
        ],
        destinationBucket: this.s3Bucket,
        distribution: this.cfDistribution
    });
}

Possible Solution

No response

Additional Information/Context

For now I have replaced my deployment workflow to use aws cli directly instead of cdk:

aws s3 sync ./build0output s3://$S3_BUCKET_ID

aws cloudfront create-invalidation --distribution-id $CF_DIST_ID --paths "/*"

and I have yet to encounter any failure - it works reliably everytime.

I'd ideally want to use CDK which prevents me from having to pass around the resource ids. Any help is much appreciated - thanks in advance.

CDK CLI Version

2.12.0

Framework Version

2.12.0

Node.js Version

18

OS

Ubuntu

Language

Typescript

Language Version

4.5.5

Other information

No response

peterwoodworth commented 2 years ago

Thanks for reporting this @lorefnon,

Limitation of deployment due to size is something we're aware of and tracking here. Please take further concerns and discussions to that issue, thanks!

github-actions[bot] commented 2 years ago

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