Skip to content

Commit 2bf30df

Browse files
authored
feat(s3): adds objectSizeLessThan property for s3 lifecycle rule (#20429)
Fixes (other half - see #20425) of #20372. This implements the `objectSizeLessThan` property for a S3 lifecycle rule. ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)? * [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 27fdaf1 commit 2bf30df

File tree

6 files changed

+14
-2
lines changed

6 files changed

+14
-2
lines changed

packages/@aws-cdk/aws-s3/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ const bucket = new s3.Bucket(this, 'MyBucket', {
578578
}],
579579
objectSizeGreaterThan: 500,
580580
prefix: 'prefix',
581+
objectSizeLessThan: 10000,
581582
transitions: [{
582583
storageClass: s3.StorageClass.GLACIER,
583584

packages/@aws-cdk/aws-s3/lib/bucket.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,6 +1923,7 @@ export class Bucket extends BucketBase {
19231923
})),
19241924
expiredObjectDeleteMarker: rule.expiredObjectDeleteMarker,
19251925
tagFilters: self.parseTagFilters(rule.tagFilters),
1926+
objectSizeLessThan: rule.objectSizeLessThan,
19261927
objectSizeGreaterThan: rule.objectSizeGreaterThan,
19271928
};
19281929

packages/@aws-cdk/aws-s3/lib/rule.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,13 @@ export interface LifecycleRule {
120120
readonly expiredObjectDeleteMarker?: boolean;
121121

122122
/**
123-
* Specifies the minimum object size in bytes for this rule to apply to.
123+
* Specifies the maximum object size in bytes for this rule to apply to.
124+
*
125+
* @default - No rule
126+
*/
127+
readonly objectSizeLessThan?: number;
128+
129+
/** Specifies the minimum object size in bytes for this rule to apply to.
124130
*
125131
* @default - No rule
126132
*/

packages/@aws-cdk/aws-s3/test/integ.lifecycle.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ new Bucket(stack, 'MyBucket', {
1212
expirationDate: new Date('2019-10-01'),
1313
},
1414
{
15+
objectSizeLessThan: 500,
1516
objectSizeGreaterThan: 500,
1617
},
1718
],

packages/@aws-cdk/aws-s3/test/lifecycle.integ.snapshot/aws-cdk-s3.template.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"Status": "Enabled"
1111
},
1212
{
13+
"ObjectSizeLessThan": "500",
1314
"ObjectSizeGreaterThan": "500",
1415
"Status": "Enabled"
1516
}

packages/@aws-cdk/aws-s3/test/rules.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,13 +292,14 @@ describe('rules', () => {
292292
});
293293
});
294294

295-
test('Bucket with objectSizeGreaterThan', () => {
295+
test('Bucket with object size rules', () => {
296296
// GIVEN
297297
const stack = new Stack();
298298

299299
// WHEN
300300
new Bucket(stack, 'Bucket', {
301301
lifecycleRules: [{
302+
objectSizeLessThan: 0,
302303
objectSizeGreaterThan: 0,
303304
}],
304305
});
@@ -307,6 +308,7 @@ describe('rules', () => {
307308
Template.fromStack(stack).hasResourceProperties('AWS::S3::Bucket', {
308309
LifecycleConfiguration: {
309310
Rules: [{
311+
ObjectSizeLessThan: 0,
310312
ObjectSizeGreaterThan: 0,
311313
Status: 'Enabled',
312314
}],

0 commit comments

Comments
 (0)