Menu
Amazon Simple Storage Service
API Reference (API Version 2006-03-01)

PUT Bucket inventory

Description

This implementation of the PUT operation adds an inventory configuration (identified by the inventory ID) to the bucket. You can have up to 1,000 inventory configurations per bucket.

Amazon S3 inventory generates inventories of the objects in the bucket on a daily or weekly basis, and the results are published to a flat file. The bucket that is inventoried is called the source bucket, and the bucket where the inventory flat file is stored is called the destination bucket. The destination bucket must be in the same AWS Region as the source bucket.

When you configure an inventory for a source bucket, you specify the destination bucket where you want the inventory to be stored, and whether to generate the inventory daily or weekly. You can also configure what object metadata to include and whether to inventory all object versions or only current versions. For more information, see Amazon S3 Inventory in the Amazon Simple Storage Service Developer Guide.

Important

You must create a bucket policy on the destination bucket to grant permissions to Amazon S3 to write objects to the bucket in the defined location. For an example policy, see Granting Permissions for Amazon S3 Inventory and Storage Class Analysis.

To use this operation, you must have permissions to perform the s3:PutInventoryConfiguration action. The bucket owner has this permission by default and can grant this permission to others. For more information about permissions, see Permissions Related to Bucket Subresource Operations and Managing Access Permissions to Your Amazon S3 Resources in the Amazon Simple Storage Service Developer Guide.

Requests

Syntax

Copy
PUT /?inventory&id=configuration-ID HTTP/1.1 Host: bucketname.s3.amazonaws.com Content-Length: length Date: date Authorization: authorization string (see Authenticating Requests (AWS Signature Version 4)) Inventory configuration in the request body

Request Parameters

This implementation of PUT uses the parameter in the following table.

Parameter Description Required
id

The ID identifying the inventory configuration. This ID must match the request element id. Limited to 64 characters.

Type: String

Default: None

Valid Characters for id:  a-z A-Z 0-9 - _ .

Yes

Request Headers

This implementation of the operation uses only request headers that are common to all operations. For more information, see Common Request Headers.

Request Elements

In the request, you must specify the inventory configuration in the request body, which is specified as XML. The Examples section shows an example of an inventory configuration.

The following table describes the XML elements in the inventory configuration:

Name Description Required
AccountId

The ID of the account that owns the destination bucket.

Although optional, we recommend that the value be set to prevent problems if the destination bucket ownership changes.

Type: String

Ancestor: S3BucketDestination

No
Bucket

The Amazon Resource Name (ARN) of the bucket where inventory results are published. This destination bucket must be in the same AWS Region as the source bucket.

Type: String

Ancestor: S3BucketDestination

Yes
Destination

Contains information about where to publish the inventory results.

Type: Container

Children: S3BucketDestination

Ancestor: InventoryConfiguration

Yes
Encryption

Contains the type of server-side encryption to use to encrypt the inventory.

Type: Container

Children: SSE-KMS, SSE-S3

Ancestor: S3BucketDestination

No
Field

Contains the optional fields that are included in the inventory results. Multiple Field elements can be contained in OptionalFields.

Type: String

Ancestor: OptionalFields

Valid values: Size, LastModifiedDate, StorageClass, ETag, IsMultipartUploaded, ReplicationStatus, EncryptionStatus

No
Filter

Specifies an inventory filter. The inventory only includes objects that meet the filter's criteria. If no filter is specified, all of the contents of the bucket are inventoried.

Type: Container

Children: Prefix

Ancestor: InventoryConfiguration

No
Format

Specifies the output format of the inventory results. Currently, Amazon S3 supports the comma-separated values (CSV) format and the Apache optimized row columnar (ORC) format.

Type: String

Ancestor: S3BucketDestination

Valid values: CSV, ORC

Yes
Frequency

Specifies how frequently inventory results are produced.

Type: String

Ancestor: Schedule

Valid values: Daily, or Weekly

Yes
Id

The ID identifying the inventory configuration. This ID must match the request parameter id.

Type: String

Ancestor:InventoryConfiguration

Yes
IncludedObjectVersions

Specifies which object versions to include in the inventory results. If set to All, the list includes all of the object versions, which adds the version-related fields VersionId, IsLatest, and DeleteMarker to the list. If set to Current, the list does not contain these version-related fields.

Type: String

Ancestor: InventoryConfiguration

Valid values: Current or All

Yes
InventoryConfiguration

Contains the inventory configuration.

Type: Container

Children: Id, IsEnabled, Filter, Destination, Schedule, IncludedObjectVersions, and OptionalFields elements.

Ancestor: None

Yes
IsEnabled

Specifies whether the inventory is enabled or disabled.

If set to True, inventory results are generated. If set to False, no inventory is generated.

Type: String

Ancestor: InventoryConfiguration

Valid values: True or False

Yes
KeyId

The AWS KMS customer master key (CMK) used to encrypt the inventory file.

Type: String

Ancestor: SSE-KMS

Valid values: ARN of the CMK

No
OptionalFields

Contains the optional fields that are included in the inventory results.

Type: Container

Children: Field

Ancestor: InventoryConfiguration

No
Prefix

The prefix that an object must have to be included in the inventory results.

Type: String

Ancestor: Filter

No
Prefix

The prefix that is prepended to all inventory results.

Type: String

Ancestor: S3BucketDestination

No
Schedule

Contains the frequency for generating inventory results.

Type: Container

Children: Frequency

Ancestor: Destination

Yes
SSE-KMS

Specifies to use server-side encryption with AWS KMS-managed keys (SSE-KMS) and contains the key that is used to encrypt the inventory file.

Type: Container

Children: KeyId

Ancestor: Encryption

No
SSE-S3

Specifies to use server-side encryption with Amazon S3-managed keys (SSE-S3) to encrypt the inventory file.

Type: Container

Ancestor: Encryption

Valid values: empty

No
S3BucketDestination

Contains the bucket ARN, file format, bucket owner (optional), prefix where inventory results are published (optional), and the type of server-side encryption that is used to encrypt the file (optional).

Type: Container

Children: Format, AccountId, Bucket, Prefix, Encryption

Ancestor: Destination

Yes

Responses

Response Headers

This implementation of the operation uses only response headers that are common to most responses. For more information, see Common Response Headers.

Response Elements

This implementation of the operation does not return response elements.

Special Errors

Amazon S3 checks the validity of the proposed InventoryConfiguration element and verifies whether the proposed configuration is valid when you call the PUT operation. The following table lists the errors and possible causes.

HTTP Error Code Cause
HTTP 400 Bad Request InvalidArgument

Invalid argument.

HTTP 403 Forbidden AccessDenied

You are not the owner of the specified bucket, or you do not have the s3:PutInventoryConfiguration bucket permission to set the configuration on the bucket.

For general information about Amazon S3 errors and a list of error codes, see Error Responses.

Examples

Example 1: Creating an Inventory Configuration

The following PUT request for the bucket examplebucket creates a new or replaces an existing inventory configuration with the ID report1. The configuration is defined in the request body.

Copy
PUT /?inventory&id=report1 HTTP/1.1 Host: examplebucket.s3.amazonaws.com Date: Mon, 31 Oct 2016 12:00:00 GMT Authorization: authorization string Content-Length: length <?xml version="1.0" encoding="UTF-8"?> <InventoryConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <Id>report1</Id> <IsEnabled>true</IsEnabled> <Filter> <Prefix>filterPrefix/</Prefix> </Filter> <Destination> <S3BucketDestination> <Format>CSV</Format> <AccountId>123456789012</AccountId> <Bucket>arn:aws:s3:::destination-bucket</Bucket> <Prefix>prefix1</Prefix> <Encryption> <SSE-KMS> <KeyId>arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</KeyId> </SSE-KMS> </Encryption> </S3BucketDestination> </Destination> <Schedule> <Frequency>Daily</Frequency> </Schedule> <IncludedObjectVersions>All</IncludedObjectVersions> <OptionalFields> <Field>Size</Field> <Field>LastModifiedDate</Field> <Field>ETag</Field> <Field>StorageClass</Field> <Field>IsMultipartUploaded</Field> <Field>ReplicationStatus</Field> <Field>EncryptionStatus</Field> </OptionalFields> </InventoryConfiguration>

The following is a sample response.

Copy
HTTP/1.1 200 OK x-amz-id-2: YgIPIfBiKa2bj0KMg95r/0zo3emzU4dzsD4rcKCHQUAdQkf3ShJTOOpXUueF6QKo x-amz-request-id: 236A8905248E5A01 Date: Mon, 31 Oct 2016 12:00:00 GMT Content-Length: 0 Server: AmazonS3