This operation is not supported for directory buckets.
Sets an analytics configuration for the bucket (specified by the analytics configuration ID). You can have up to 1,000 analytics configurations per bucket.
You can choose to have storage class analysis export analysis reports sent to a comma-separated values (CSV) flat file. See theDataExport request element. Reports are updated daily and are based on the object filters that you configure. When selecting data export, you specify a destination bucket and an optional destination prefix where the file is written. You can export the data to a destination bucket in a different account. However, the destination bucket must be in the same Region as the bucket that you are making the PUT analytics configuration to. For more information, seeAmazon S3 Analytics – Storage Class Analysis.
You must create a bucket policy on the destination bucket where the exported file is written to grant permissions to Amazon S3 to write objects to the bucket. For an example policy, seeGranting Permissions for Amazon S3 Inventory and Storage Class Analysis.
To use this operation, you must have permissions to perform thes3:PutAnalyticsConfiguration action. The bucket owner has this permission by default. The bucket owner can grant this permission to others. For more information about permissions, seePermissions Related to Bucket Subresource Operations andManaging Access Permissions to Your Amazon S3 Resources.
PutBucketAnalyticsConfiguration has the following special errors:
HTTP Error: HTTP 400 Bad Request
Code: InvalidArgument
Cause: Invalid argument.
HTTP Error: HTTP 400 Bad Request
Code: TooManyConfigurations
Cause: You are attempting to create a new configuration but have already reached the 1,000-configuration limit.
HTTP Error: HTTP 403 Forbidden
Code: AccessDenied
Cause: You are not the owner of the specified bucket, or you do not have the s3:PutAnalyticsConfiguration bucket permission to set the configuration on the bucket.
The following operations are related toPutBucketAnalyticsConfiguration:
You must URL encode any signed header values that contain spaces. For example, if your header value ismy file.txt, containing two spaces aftermy, you must URL encode this value tomy%20%20file.txt.
PUT /?analytics&id=Id HTTP/1.1Host:Bucket.s3.amazonaws.comx-amz-expected-bucket-owner:ExpectedBucketOwner<?xml version="1.0" encoding="UTF-8"?><AnalyticsConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <Id>string</Id> <Filter> <And> <Prefix>string</Prefix> <Tag> <Key>string</Key> <Value>string</Value> </Tag> ... </And> <Prefix>string</Prefix> <Tag> <Key>string</Key> <Value>string</Value> </Tag> </Filter> <StorageClassAnalysis> <DataExport> <Destination> <S3BucketDestination> <Bucket>string</Bucket> <BucketAccountId>string</BucketAccountId> <Format>string</Format> <Prefix>string</Prefix> </S3BucketDestination> </Destination> <OutputSchemaVersion>string</OutputSchemaVersion> </DataExport> </StorageClassAnalysis></AnalyticsConfiguration>The request uses the following URI parameters.
The name of the bucket to which an analytics configuration is stored.
Required: Yes
The ID that identifies the analytics configuration.
Required: Yes
The account ID of the expected bucket owner. If the account ID that you provide does not match the actual owner of the bucket, the request fails with the HTTP status code403 Forbidden (access denied).
The request accepts the following data in XML format.
Root level tag for the AnalyticsConfiguration parameters.
Required: Yes
The filter used to describe a set of objects for analyses. A filter must have exactly one prefix, one tag, or one conjunction (AnalyticsAndOperator). If no filter is provided, all objects will be considered in any analysis.
Type:AnalyticsFilter data type
Required: No
The ID that identifies the analytics configuration.
Type: String
Required: Yes
Contains data related to access patterns to be collected and made available to analyze the tradeoffs between different storage classes.
Type:StorageClassAnalysis data type
Required: Yes
HTTP/1.1 200If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.
The following PUT request for the bucketexamplebucket creates a new or replaces an existing analytics configuration with the IDreport1. The configuration is defined in the request body.
PUT /?analytics&id=report1 HTTP/1.1Host: examplebucket.s3.<Region>.amazonaws.comDate: Mon, 31 Oct 2016 12:00:00 GMTAuthorization: authorization stringContent-Length: length <?xml version="1.0" encoding="UTF-8"?><AnalyticsConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <Id>report1</Id> <Filter> <And> <Prefix>images/</Prefix> <Tag> <Key>dog</Key> <Value>corgi</Value> </Tag> </And> </Filter> <StorageClassAnalysis> <DataExport> <OutputSchemaVersion>V_1</OutputSchemaVersion> <Destination> <S3BucketDestination> <Format>CSV</Format> <BucketAccountId>123456789012</BucketAccountId> <Bucket>arn:aws:s3:::destination-bucket</Bucket> <Prefix>destination-prefix</Prefix> </S3BucketDestination> </Destination> </DataExport> </StorageClassAnalysis></AnalyticsConfiguration>This example illustrates one usage of PutBucketAnalyticsConfiguration.
HTTP/1.1 200 OKx-amz-id-2: YgIPIfBiKa2bj0KMg95r/0zo3emzU4dzsD4rcKCHQUAdQkf3ShJTOOpXUueF6QKox-amz-request-id: 236A8905248E5A01Date: Mon, 31 Oct 2016 12:00:00 GMTContent-Length: 0Server: AmazonS3For more information about using this API in one of the language-specific AWS SDKs, see the following: