AWS::S3::Bucket LifecycleConfiguration - AWS CloudFormation

AWS::S3::Bucket LifecycleConfiguration

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 }

Properties

Rules

A lifecycle rule for individual objects in an Amazon S3 bucket.

Required: Yes

Type: Array of Rule

Update requires: No interruption

TransitionDefaultMinimumObjectSize

Property description not available.

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.