Specifies the lifecycle configuration for objects in an Amazon S3 bucket. For more information, see Object Lifecycle Management in the Amazon S3 User Guide.
Syntax
To declare this entity in your AWS CloudFormation template, use the following syntax:
JSON
{
"Rules" : [ Rule, ... ]
,
"TransitionDefaultMinimumObjectSize" : String
}
YAML
Rules:
- Rule
TransitionDefaultMinimumObjectSize: String
Properties
Rules
-
A lifecycle rule for individual objects in an Amazon S3 bucket.
Required: Yes
Type: Array of Rule
Update requires: No interruption
TransitionDefaultMinimumObjectSize
-
Indicates which default minimum object size behavior is applied to the lifecycle configuration.
Note
This parameter applies to general purpose buckets only. It isn't supported for directory bucket lifecycle configurations.
-
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
orObjectSizeLessThan
in the body of your transition rule. Custom filters always take precedence over the default transition behavior.Required: No
Type: String
Allowed values:
varies_by_storage_class | all_storage_classes_128K
Update requires: No interruption
-
Examples
Manage the lifecycle for S3 objects
The following example template shows an S3 bucket with a lifecycle configuration rule.
The rule applies to all objects with the glacier
key prefix. The objects are
transitioned to Glacier after one day, and deleted after one year.
JSON
{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"S3Bucket": {
"Type": "AWS::S3::Bucket",
"Properties": {
"AccessControl": "Private",
"LifecycleConfiguration": {
"Rules": [
{
"Id": "GlacierRule",
"Prefix": "glacier",
"Status": "Enabled",
"ExpirationInDays": 365,
"Transitions": [
{
"TransitionInDays": 1,
"StorageClass": "GLACIER"
}
]
}
]
}
}
}
},
"Outputs": {
"BucketName": {
"Value": {
"Ref": "S3Bucket"
},
"Description": "Name of the sample Amazon S3 bucket with a lifecycle configuration."
}
}
}
YAML
AWSTemplateFormatVersion: 2010-09-09
Resources:
S3Bucket:
Type: 'AWS::S3::Bucket'
Properties:
AccessControl: Private
LifecycleConfiguration:
Rules:
- Id: GlacierRule
Prefix: glacier
Status: Enabled
ExpirationInDays: 365
Transitions:
- TransitionInDays: 1
StorageClass: GLACIER
Outputs:
BucketName:
Value: !Ref S3Bucket
Description: Name of the sample Amazon S3 bucket with a lifecycle configuration.