(aws-s3-deployment): Add option to synchronize files based on file size only
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the feature
The BucketDeployment construct in AWS CDK currently synchronizes files based on both size and timestamp. This feature request proposes adding an option to synchronize files based only on size changes, ignoring the timestamp. This can be achieved by adding a SyncWithSizeOnly option that, when set to true, will pass the --size-only flag to the aws s3 sync command.
### Use Case
When using s3 notifications on the destination bucket, we only want to receive a notification only if a file was changed.
With the current behavior, we are receving a PutObject notification for all files, even if we only change one file.
We found that the ``BucketDeployment`` lambda uses ``aws s3 sync`` to synchronize files.
According to the documentation https://docs.aws.amazon.com/cli/latest/reference/s3/sync.html
> A local file will require uploading if the size of the local file is different than the size of the S3 object, the last modified time of the local file is newer than the last modified time of the S3 object, or the local file does not exist under the specified bucket and prefix
Before running ``aws s3 sync``, the content is unzipped, so the last modified time of files will set to the time of extraction.
Timestamp will be different than timestamp in the destination bucket, so all files will be synchronized.
### Proposed Solution
To implement this feature, we can add a new property SyncWithSizeOnly to the BucketDeployment construct. This property will default to false. When set to true, the aws s3 sync command will include the --size-only flag.
### Other Information
_No response_
### Acknowledgements
- [x] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
### CDK version used
v2.184.1
### Environment details (OS name and version, etc.)
Debian 12
Contributor guide
Research direction
Start by locating the BucketDeployment construct and the code that invokes aws s3 sync. Trace how construct properties become sync options, then add the proposed SyncWithSizeOnly behavior with its false default and verify that true includes --size-only while the default does not.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, infrastructure
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100