AWS::S3::Bucket LoggingConfiguration
Describes where logs are stored and the prefix that Amazon S3 assigns to all log object keys for a bucket. For examples and more information, see PUT Bucket logging in the Amazon S3 API Reference.
Syntax
To declare this entity in your AWS CloudFormation template, use the following syntax:
JSON
{ "DestinationBucketName" :
String
, "LogFilePrefix" :String
}
YAML
DestinationBucketName:
String
LogFilePrefix:String
Properties
DestinationBucketName
-
The name of the bucket where Amazon S3 should store server access log files. You can store log files in any bucket that you own. By default, logs are stored in the bucket where the
LoggingConfiguration
property is defined.Required: No
Type: String
Update requires: No interruption
LogFilePrefix
-
A prefix for all log object keys. If you store log files from multiple Amazon S3 buckets in a single bucket, you can use a prefix to distinguish which log files came from which bucket.
Required: No
Type: String
Update requires: No interruption
Examples
Log access requests for a specific S3 bucket
The following example template creates two S3 buckets. The LoggingBucket
bucket store the logs from the S3Bucket
bucket. To receive logs from the
S3Bucket
bucket, the logging bucket requires log delivery write
permissions.
JSON
{ "AWSTemplateFormatVersion": "2010-09-09", "Resources": { "S3Bucket": { "Type": "AWS::S3::Bucket", "Properties": { "AccessControl": "Private", "LoggingConfiguration": { "DestinationBucketName": { "Ref": "LoggingBucket" }, "LogFilePrefix": "testing-logs" } } }, "LoggingBucket": { "Type": "AWS::S3::Bucket", "Properties": { "AccessControl": "LogDeliveryWrite" } } }, "Outputs": { "BucketName": { "Value": { "Ref": "S3Bucket" }, "Description": "Name of the sample Amazon S3 bucket with a logging configuration." } } }
YAML
AWSTemplateFormatVersion: 2010-09-09 Resources: S3Bucket: Type: 'AWS::S3::Bucket' Properties: AccessControl: Private LoggingConfiguration: DestinationBucketName: !Ref LoggingBucket LogFilePrefix: testing-logs LoggingBucket: Type: 'AWS::S3::Bucket' Properties: AccessControl: LogDeliveryWrite Outputs: BucketName: Value: !Ref S3Bucket Description: Name of the sample Amazon S3 bucket with a logging configuration.