diff --git a/packages/@aws-cdk/aws-s3/README.md b/packages/@aws-cdk/aws-s3/README.md index 988b360c01d3c..e34dd8067f0ef 100644 --- a/packages/@aws-cdk/aws-s3/README.md +++ b/packages/@aws-cdk/aws-s3/README.md @@ -578,6 +578,7 @@ const bucket = new s3.Bucket(this, 'MyBucket', { }], objectSizeGreaterThan: 500, prefix: 'prefix', + objectSizeLessThan: 10000, transitions: [{ storageClass: s3.StorageClass.GLACIER, diff --git a/packages/@aws-cdk/aws-s3/lib/bucket.ts b/packages/@aws-cdk/aws-s3/lib/bucket.ts index d51d79165f61c..d2be56356ae7f 100644 --- a/packages/@aws-cdk/aws-s3/lib/bucket.ts +++ b/packages/@aws-cdk/aws-s3/lib/bucket.ts @@ -1923,6 +1923,7 @@ export class Bucket extends BucketBase { })), expiredObjectDeleteMarker: rule.expiredObjectDeleteMarker, tagFilters: self.parseTagFilters(rule.tagFilters), + objectSizeLessThan: rule.objectSizeLessThan, objectSizeGreaterThan: rule.objectSizeGreaterThan, }; diff --git a/packages/@aws-cdk/aws-s3/lib/rule.ts b/packages/@aws-cdk/aws-s3/lib/rule.ts index b79af075ed848..943130c1a20f9 100644 --- a/packages/@aws-cdk/aws-s3/lib/rule.ts +++ b/packages/@aws-cdk/aws-s3/lib/rule.ts @@ -120,7 +120,13 @@ export interface LifecycleRule { readonly expiredObjectDeleteMarker?: boolean; /** - * Specifies the minimum object size in bytes for this rule to apply to. + * Specifies the maximum object size in bytes for this rule to apply to. + * + * @default - No rule + */ + readonly objectSizeLessThan?: number; + + /** Specifies the minimum object size in bytes for this rule to apply to. * * @default - No rule */ diff --git a/packages/@aws-cdk/aws-s3/test/integ.lifecycle.ts b/packages/@aws-cdk/aws-s3/test/integ.lifecycle.ts index 0fe92eda9a7eb..973a0e562232c 100644 --- a/packages/@aws-cdk/aws-s3/test/integ.lifecycle.ts +++ b/packages/@aws-cdk/aws-s3/test/integ.lifecycle.ts @@ -12,6 +12,7 @@ new Bucket(stack, 'MyBucket', { expirationDate: new Date('2019-10-01'), }, { + objectSizeLessThan: 500, objectSizeGreaterThan: 500, }, ], diff --git a/packages/@aws-cdk/aws-s3/test/lifecycle.integ.snapshot/aws-cdk-s3.template.json b/packages/@aws-cdk/aws-s3/test/lifecycle.integ.snapshot/aws-cdk-s3.template.json index df2d4d718d3cf..d811988919f3f 100644 --- a/packages/@aws-cdk/aws-s3/test/lifecycle.integ.snapshot/aws-cdk-s3.template.json +++ b/packages/@aws-cdk/aws-s3/test/lifecycle.integ.snapshot/aws-cdk-s3.template.json @@ -10,6 +10,7 @@ "Status": "Enabled" }, { + "ObjectSizeLessThan": "500", "ObjectSizeGreaterThan": "500", "Status": "Enabled" } diff --git a/packages/@aws-cdk/aws-s3/test/rules.test.ts b/packages/@aws-cdk/aws-s3/test/rules.test.ts index 5be1225ebc4d1..b327494d19267 100644 --- a/packages/@aws-cdk/aws-s3/test/rules.test.ts +++ b/packages/@aws-cdk/aws-s3/test/rules.test.ts @@ -292,13 +292,14 @@ describe('rules', () => { }); }); - test('Bucket with objectSizeGreaterThan', () => { + test('Bucket with object size rules', () => { // GIVEN const stack = new Stack(); // WHEN new Bucket(stack, 'Bucket', { lifecycleRules: [{ + objectSizeLessThan: 0, objectSizeGreaterThan: 0, }], }); @@ -307,6 +308,7 @@ describe('rules', () => { Template.fromStack(stack).hasResourceProperties('AWS::S3::Bucket', { LifecycleConfiguration: { Rules: [{ + ObjectSizeLessThan: 0, ObjectSizeGreaterThan: 0, Status: 'Enabled', }],