AWS::S3::StorageLens
The AWS::S3::StorageLens resource creates an Amazon S3 Storage Lens configuration.
Syntax
To declare this entity in your AWS CloudFormation template, use the following syntax:
JSON
{ "Type" : "AWS::S3::StorageLens", "Properties" : { "StorageLensConfiguration" :
StorageLensConfiguration
, "Tags" :[ Tag, ... ]
} }
YAML
Type: AWS::S3::StorageLens Properties: StorageLensConfiguration:
StorageLensConfiguration
Tags:- Tag
Properties
StorageLensConfiguration
-
This resource contains the details Amazon S3 Storage Lens configuration.
Required: Yes
Type: StorageLensConfiguration
Update requires: No interruption
Tags
-
A set of tags (key–value pairs) to associate with the Storage Lens configuration.
Required: No
Type: List of Tag
Update requires: No interruption
Return values
Ref
When the logical ID of this resource is provided to the Ref intrinsic function, Ref
returns the S3 Storage Lens configuration Id, such as
your-storage-lens-configuration-id
. For more information about using the Ref
function, see Ref.
Fn::GetAtt
Fn::GetAtt returns a value for a specified attribute of this type. For more information, see Fn::GetAtt. The following are the available attributes and sample return values.
Examples
The following examples create an advanced S3 Storage Lens configuration that enables advanced metrics, Amazon CloudWatch publishing, and prefix aggregation. This example also configures a metrics export and adds tags.
Creating an advanced S3 Storage Lens configuration
JSON
{ "AWSTemplateFormatVersion": "2010-09-09", "Description": "StorageLens Advanced Configuration Example", "Resources": { "StorageLensConfigurationExample": { "Type": "AWS::S3::StorageLens", "Properties": { "StorageLensConfiguration": { "Id": "StorageLensAdvancedConfiguration", "AccountLevel": { "ActivityMetrics": { "IsEnabled": true }, "AdvancedCostOptimizationMetrics": { "IsEnabled": true }, "AdvancedDataProtectionMetrics": { "IsEnabled": true }, "DetailedStatusCodesMetrics": { "IsEnabled": true }, "BucketLevel": { "ActivityMetrics": { "IsEnabled": true }, "AdvancedCostOptimizationMetrics": { "IsEnabled": true }, "AdvancedDataProtectionMetrics": { "IsEnabled": true }, "DetailedStatusCodesMetrics": { "IsEnabled": true }, "PrefixLevel": { "StorageMetrics": { "IsEnabled": true, "SelectionCriteria": { "MaxDepth": 5, "MinStorageBytesPercentage": 1.23, "Delimiter": "/" } } } } }, "Exclude": { "Buckets": [ { "Fn::Sub": "arn:aws:s3:::source_bucket_1" }, { "Fn::Sub": "arn:aws:s3:::source_bucket_2" } ] }, "IsEnabled": true, "DataExport": { "S3BucketDestination": { "OutputSchemaVersion": "V_1", "Format": "CSV", "AccountId": "111122223333", "Arn": { "Fn::Sub": "arn:aws:s3:::destination_bucket" }, "Prefix": "output-path-prefix", "Encryption": { "SSES3": {} } }, "CloudWatchMetrics": { "IsEnabled": true } } }, "Tags": [ { "Key": "tag-key-1", "Value": "tag-value-1" }, { "Key": "tag-key-2", "Value": "tag-value-2" } ] } } } }
YAML
AWSTemplateFormatVersion: 2010-09-09 Description: StorageLens Advanced Configuration Example Resources: StorageLensConfigurationExample: Type: AWS::S3::StorageLens Properties: StorageLensConfiguration: Id: "StorageLensAdvancedConfiguration" AccountLevel: ActivityMetrics: IsEnabled: true AdvancedCostOptimizationMetrics: IsEnabled: true AdvancedDataProtectionMetrics: IsEnabled: true DetailedStatusCodesMetrics: IsEnabled: true BucketLevel: ActivityMetrics: IsEnabled: true AdvancedCostOptimizationMetrics: IsEnabled: true AdvancedDataProtectionMetrics: IsEnabled: true DetailedStatusCodesMetrics: IsEnabled: true PrefixLevel: StorageMetrics: IsEnabled: true SelectionCriteria: MaxDepth: 5 MinStorageBytesPercentage: 1.23 Delimiter: "/" Exclude: Buckets: - !Sub 'arn:aws:s3:::source_bucket_1' - !Sub 'arn:aws:s3:::source_bucket_2' IsEnabled: true DataExport: S3BucketDestination: OutputSchemaVersion: "V_1" Format: "CSV" AccountId: "111122223333" Arn: !Sub 'arn:aws:s3:::destination_bucket' Prefix: "output-path-prefix" Encryption: SSES3: {} CloudWatchMetrics: IsEnabled: true Tags: - Key: "tag-key-1" Value: "tag-value-1" - Key: "tag-key-2" Value: "tag-value-2"