chore(s3-deployment): increase default memory limit from 128MB to 512MB#35501
Open
chore(s3-deployment): increase default memory limit from 128MB to 512MB#35501
Conversation
aws-cdk-automation
previously requested changes
Sep 16, 2025
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
Contributor
|
Comments on closed issues and PRs are hard for our team to see. |
Contributor
|
As discussed #35487 (comment) changing this default value would be a breaking change, I think we should introduce a feature flag for that. |
pahud
reviewed
Sep 16, 2025
pahud
reviewed
Sep 16, 2025
packages/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.ts
Outdated
Show resolved
Hide resolved
pahud
reviewed
Sep 16, 2025
4a06ffc to
9fdf3b5
Compare
a1c9598 to
53f0324
Compare
kaizencc
reviewed
Sep 24, 2025
| timeout: cdk.Duration.minutes(15), | ||
| role: props.role, | ||
| memorySize: props.memoryLimit, | ||
| memorySize: props.memoryLimit ?? (FeatureFlags.of(this).isEnabled(cxapi.S3_DEPLOYMENT_USE_512MB_MEMORY) ? 512 : undefined), |
Contributor
There was a problem hiding this comment.
I'm confused why this needs to be hidden under a feature flag. Changing the memory limit does not require replacement in the lambda. Yes, the template will see a diff when a user updates but I don't consider that a breaking change. a user would be able to deploy without replacement and without failure in their custom resource right?
f091c7c to
c2897e6
Compare
Contributor
|
CI Error |
Addresses review feedback by removing the feature flag approach and making 512MB the new default memory limit for the BucketDeployment Lambda function. This change improves S3 sync performance from KB/s to MB/s, eliminating timeout issues for typical static website deployments. Users can still explicitly set memoryLimit to 128 if needed for backward compatibility. BREAKING CHANGE: The default memory limit for BucketDeployment Lambda function has changed from 128MB to 512MB. This may increase costs slightly but provides significantly better performance. To restore the old behavior, explicitly set memoryLimit: 128 in BucketDeployment props.
9d9900e to
4c2badc
Compare
…ory default The bedrock agent API schema integration test uses BucketDeployment, which now defaults to 512MB memory. Update the snapshot to reflect this change.
4c2badc to
3651036
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue # (if applicable)
Closes #35487.
Reason for this change
The BucketDeployment construct's Lambda custom resource uses a default memory limit of 128MB, which causes extremely poor S3 sync performance (10s of KB/s) and deployment timeouts. Users reported 15-minute timeouts when deploying typical static website assets, making the construct unreliable for production use without manual memory configuration.
Description of changes
Introduced a feature flag
@aws-cdk/aws-s3-deployment:use512MbMemoryto increase the default memory limit for BucketDeployment Lambda custom resource from 128MB to 512MB, providing dramatically improved S3 sync performance out of the box while maintaining backward compatibility.Key Changes:
@aws-cdk/aws-s3-deployment:use512MbMemory(enabled by default in recommended-feature-flags.json)no explicit memory limit when feature flag is disabled- verifies no MemorySize property is setdefault memory limit is 512MB when feature flag is enabled- verifies MemorySize: 512Describe any new or updated permissions being added
N/A - No IAM permissions or resource access changes. This is purely a Lambda memory configuration adjustment controlled by a feature flag.
Description of how you validated changes
Unit tests:
Integration tests:
Feature flag testing:
Build verification:
Performance validation:
Implementation Details
The implementation follows the feature flag pattern where:
memoryLimitis explicitly provided, use that valueundefined(Lambda default 128MB)This ensures backward compatibility while providing better defaults for new deployments.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license