question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Updating a BucketDeployment's memoryLimit causes stack update failure

See original GitHub issue

Changing the memoryLimit of an existing BucketDeployment (@aws-cdk/aws-s3-deployment) causes the CloudFormation deploy of the update to fail with the error “Modifying service token is not allowed.”

Reproduction Steps

Create a bucket deployment:

const deployment = new BucketDeployment(this, 'BucketDeployment', {
  destinationBucket: myDestinationBucket,
  sources: [Source.bucket(myBucket, myS3Obj)],
});

Then add memoryLimit: 1792, (for example) to its properties and redeploy. The CFN changeset will fail to deploy and rollback.

Error Log

CloudFormation reports the error “Modifying service token is not allowed.” for the “BucketDeploymentCustomResource.”

Environment

  • CLI Version : 1.30
  • Framework Version: 1.23
  • OS : Mac/Linux
  • Language : Typescript

Workaround

For anyone struggling with this issue, here’s how I worked around the problem:

  1. Remove your bucket deployment construct.
  2. Deploy to all environments. The contents of the S3 bucket might be stale momentarily, but they aren’t deleted or anything.
  3. Add it back with the correct memoryLimit.
  4. Deploy to all environments.

In retrospect, just changing the construct name (add 2 to the end or something) to destroy the old and create the new would probably also have worked. I haven’t tested that.

Other

I noticed this was noted on the original pull request by someone else as well: https://github.com/aws/aws-cdk/pull/4204#issuecomment-584770041

Additional request

I strongly believe the default memoryLimit should be set to 1792, which is the documented number for a full vCPU for a Lambda.

Our experience with even a small 2MB zip file showed we had a 40s deploy at 128 MB and a 3s deploy at 1792 MB. That’s 13X faster at 14X resources, a basically linear speedup, which means it’s nearly free in terms of cost. I strongly believe there’s no reason whatsoever for this lambda to ever have a smaller memory limit, which means this is a very bad default.

Of course, to safely update that default, this bug needs fixing first. Otherwise everyone’s deploy will fail.


This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:16
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
masterchopcommented, Sep 10, 2021

Dudes you have to increase the memoryLimit to fix the problem.

1reaction
iliapolocommented, Jul 9, 2020

@Khalian Apologies for the delayed response. You can change the BucketDeployment construct id. This will replace the underlying custom resource and deploy the new one with the updated config. It doesn’t require blowing up the stack.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Update CloudFormation stacks that are failing because of ...
If you delete a resource that was created by a CloudFormation stack, then your stack fails to update, and you get an error...
Read more >
Memory limit exceeded during Google App Engine deployment
First, I store larger files from local to cloud. Then I successfully deployed the code to Google App Engine without any errors.
Read more >
@aws-cdk/aws-s3-deployment | Yarn - Package Manager
Please note that creating VPC inline may cause stack deletion failures. ... updating memoryLimit or vpc results in stack update failure (#17530 (2ba40d1), ......
Read more >
Using AWS CDK to Deploy EventCatalog - martzcodes
In this post we'll be focusing on creating the "Watcher Stack" that ... deployments and we bumped he memory limit of the BucketDeployment...
Read more >
How do I update an AWS CloudFormation stack that's failing ...
Skip directly to the demo: 0:30For more details see the Knowledge Center article with this video: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found