Skip to content

Commit

Permalink
feat(s3): support transitionDefaultMinimumObjectSize for life cycle (
Browse files Browse the repository at this point in the history
…#31778)

### Issue # (if applicable)

Closes #31777.

### Reason for this change



TransitionDefaultMinimumObjectSize for lifecycles has been supported. It can be possible to indicate which default minimum object size behavior is applied to the lifecycle configuration.

what's new: https://aws.amazon.com/about-aws/whats-new/2024/09/amazon-s3-default-minimum-object-size-lifecycle-transition-rules

UserGuide: https://docs.aws.amazon.com/AmazonS3/latest/userguide/lifecycle-transition-general-considerations.html#lifecycle-configuration-constraints

Cfn doc: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-lifecycleconfiguration.html#cfn-s3-bucket-lifecycleconfiguration-transitiondefaultminimumobjectsize

API: https://docs.aws.amazon.com/cli/latest/reference/s3api/put-bucket-lifecycle-configuration.html

Still CFn documentation says “Property description not available”, so it is good to look at the API documentation for the description.

```
--transition-default-minimum-object-size (string)

Indicates which default minimum object size behavior is applied to the lifecycle configuration.

all_storage_classes_128K - Objects smaller than 128 KB will not transition to any storage class by default.
varies_by_storage_class - Objects smaller than 128 KB will transition to Glacier Flexible Retrieval or Glacier Deep Archive storage classes. By default, all other storage classes will prevent transitions smaller than 128 KB.
To customize the minimum object size for any transition you can add a filter that specifies a custom ObjectSizeGreaterThan or ObjectSizeLessThan in the body of your transition rule. Custom filters always take precedence over the default transition behavior.

Possible values:

varies_by_storage_class
all_storage_classes_128K
```

### Description of changes



Add `TransitionDefaultMinimumObjectSize` to BucketProps.

### Description of how you validated changes



Both unit and integ tests.

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https:/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https:/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
go-to-k authored Oct 18, 2024
1 parent 5dbe8f7 commit 4aa117b
Show file tree
Hide file tree
Showing 12 changed files with 654 additions and 1 deletion.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"Resources": {
"AllStorageClasses128KB8241761": {
"Type": "AWS::S3::Bucket",
"Properties": {
"LifecycleConfiguration": {
"Rules": [
{
"Status": "Enabled",
"Transitions": [
{
"StorageClass": "DEEP_ARCHIVE",
"TransitionInDays": 30
}
]
},
{
"ObjectSizeGreaterThan": 200000,
"ObjectSizeLessThan": 300000,
"Status": "Enabled",
"Transitions": [
{
"StorageClass": "ONEZONE_IA",
"TransitionInDays": 30
}
]
}
],
"TransitionDefaultMinimumObjectSize": "all_storage_classes_128K"
}
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
},
"VariesByStorageClassCD3C88D5": {
"Type": "AWS::S3::Bucket",
"Properties": {
"LifecycleConfiguration": {
"Rules": [
{
"Status": "Enabled",
"Transitions": [
{
"StorageClass": "DEEP_ARCHIVE",
"TransitionInDays": 30
}
]
},
{
"ObjectSizeGreaterThan": 200000,
"ObjectSizeLessThan": 300000,
"Status": "Enabled",
"Transitions": [
{
"StorageClass": "ONEZONE_IA",
"TransitionInDays": 30
}
]
}
],
"TransitionDefaultMinimumObjectSize": "varies_by_storage_class"
}
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
}
},
"Parameters": {
"BootstrapVersion": {
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "/cdk-bootstrap/hnb659fds/version",
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
}
},
"Rules": {
"CheckBootstrapVersion": {
"Assertions": [
{
"Assert": {
"Fn::Not": [
{
"Fn::Contains": [
[
"1",
"2",
"3",
"4",
"5"
],
{
"Ref": "BootstrapVersion"
}
]
}
]
},
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
}
]
}
}
}
Loading

0 comments on commit 4aa117b

Please sign in to comment.