Configuring Amazon S3 Inventory
Amazon S3 Inventory provides a flat file list of your objects and metadata, on a schedule that
you define. You can use S3 Inventory as a scheduled alternative to the Amazon S3 synchronous
List
API operation. S3 Inventory provides comma-separated values (CSV), Apache optimized row columnar (ORC)
You can configure S3 Inventory to create inventory lists on a daily or weekly basis for an S3 bucket or for objects that share a prefix (objects that have names that begin with the same string). For more information, see Amazon S3 Inventory.
This section describes how to configure an inventory, including details about the inventory source and destination buckets.
Topics
Overview
Amazon S3 Inventory helps you manage your storage by creating lists of the objects in an S3 bucket on a defined schedule. You can configure multiple inventory lists for a bucket. The inventory lists are published to CSV, ORC, or Parquet files in a destination bucket.
The easiest way to set up an inventory is by using the Amazon S3 console, but you can also use the Amazon S3 REST API, AWS Command Line Interface (AWS CLI), or AWS SDKs. The console performs the first step of the following procedure for you: adding a bucket policy to the destination bucket.
To set up Amazon S3 Inventory for an S3 bucket
-
Add a bucket policy for the destination bucket.
You must create a bucket policy on the destination bucket that grants permissions to Amazon S3 to write objects to the bucket in the defined location. For an example policy, see Grant permissions for S3 Inventory and S3 analytics.
-
Configure an inventory to list the objects in a source bucket and publish the list to a destination bucket.
When you configure an inventory list for a source bucket, you specify the destination bucket where you want the list to be stored, and whether you want to generate the list daily or weekly. You can also configure whether to list all object versions or only current versions and what object metadata to include.
Some object metadata fields in S3 Inventory report configurations are optional, meaning that they're available by default but they can be restricted when you grant a user the
s3:PutInventoryConfiguration
permission. You can control whether users can include these optional metadata fields in their reports by using thes3:InventoryAccessibleOptionalFields
condition key.For more information about the optional metadata fields available in S3 Inventory, see OptionalFields in the Amazon Simple Storage Service API Reference. For more information about restricting access to certain optional metadata fields in an inventory configuration, see Control S3 Inventory report configuration creation.
You can specify that the inventory list file be encrypted by using server-side encryption with an Amazon S3 managed key (SSE-S3) or an AWS Key Management Service (AWS KMS) customer managed key (SSE-KMS).
Note
The AWS managed key (
aws/s3
) is not supported for SSE-KMS encryption with S3 Inventory.For more information about SSE-S3 and SSE-KMS, see Protecting data with server-side encryption. If you plan to use SSE-KMS encryption, see Step 3.
-
For information about how to use the console to configure an inventory list, see Configuring inventory by using the S3 console.
-
To use the Amazon S3 API to configure an inventory list, use the PutBucketInventoryConfiguration REST API operation or the equivalent from the AWS CLI or AWS SDKs.
-
-
To encrypt the inventory list file with SSE-KMS, grant Amazon S3 permission to use the AWS KMS key.
You can configure encryption for the inventory list file by using the Amazon S3 console, Amazon S3 REST API, AWS CLI, or AWS SDKs. Whichever way you choose, you must grant Amazon S3 permission to use the customer managed key to encrypt the inventory file. You grant Amazon S3 permission by modifying the key policy for the customer managed key that you want to use to encrypt the inventory file. For more information, see Granting Amazon S3 permission to use your customer managed key for encryption.
The destination bucket that stores the inventory list file can be owned by a different AWS account than the account that owns the source bucket. If you use SSE-KMS encryption for the cross-account operations of Amazon S3 Inventory, we recommend that you use a fully qualified KMS key ARN when you configure S3 inventory. For more information, see Using SSE-KMS encryption for cross-account operations and ServerSideEncryptionByDefault in the Amazon Simple Storage Service API Reference.
Creating a destination bucket policy
If you create your inventory configuration through the Amazon S3 console, Amazon S3 automatically creates a bucket policy on the destination bucket that grants Amazon S3 write permission to the bucket. However, if you create your inventory configuration through the AWS CLI, AWS SDKs, or the Amazon S3 REST API, you must manually add a bucket policy on the destination bucket. For more information, see Grant permissions for S3 Inventory and S3 analytics. The S3 Inventory destination bucket policy allows Amazon S3 to write data for the inventory reports to the bucket.
If an error occurs when you try to create the bucket policy, you are given instructions on how to fix it. For example, if you choose a destination bucket in another AWS account and don't have permissions to read and write to the bucket policy, you see an error message.
In this case, the destination bucket owner must add the bucket policy to the destination bucket. If the policy is not added to the destination bucket, you won't get an inventory report because Amazon S3 doesn't have permission to write to the destination bucket. If the source bucket is owned by a different account than that of the current user, the correct account ID of the source bucket owner must be substituted in the policy.
Granting Amazon S3 permission to use your customer managed key for encryption
To grant Amazon S3 permission to use your AWS Key Management Service (AWS KMS) customer managed key for server-side encryption, you must use a key policy. To update your key policy so that you can use your customer managed key, use the following procedure.
To grant Amazon S3 permissions to encrypt by using your customer managed key
Using the AWS account that owns the customer managed key, sign into the AWS Management Console.
-
Open the AWS KMS console at https://console.aws.amazon.com/kms
. -
To change the AWS Region, use the Region selector in the upper-right corner of the page.
-
In the left navigation pane, choose Customer managed keys.
-
Under Customer managed keys, choose the customer managed key that you want to use to encrypt your inventory files.
-
In the Key policy section, choose Switch to policy view.
-
To update the key policy, choose Edit.
On the Edit key policy page, add the following lines to the existing key policy. For
andsource-account-id
, supply the appropriate values for your use case.amzn-s3-demo-source-bucket
{ "Sid": "Allow Amazon S3 use of the customer managed key", "Effect": "Allow", "Principal": { "Service": "s3.amazonaws.com" }, "Action": [ "kms:GenerateDataKey" ], "Resource": "*", "Condition":{ "StringEquals":{ "aws:SourceAccount":"
source-account-id
" }, "ArnLike":{ "aws:SourceARN": "arn:aws:s3:::
" } } }amzn-s3-demo-source-bucket
-
Choose Save changes.
For more information about creating customer managed keys and using key policies, see the following links in the AWS Key Management Service Developer Guide:
Configuring inventory by using the S3 console
Use these instructions to configure inventory by using the S3 console.
Note
It might take up to 48 hours for Amazon S3 to deliver the first inventory report.
Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/
. -
In the left navigation pane, choose Buckets. In the Buckets list, choose the name of the bucket that you want to configure Amazon S3 Inventory for.
-
Choose the Management tab.
-
Under Inventory configurations, choose Create inventory configuration.
-
For Inventory configuration name, enter a name.
-
For Inventory scope, do the following:
-
Enter an optional prefix.
-
Choose which object versions to include, either Current versions only or Include all versions.
-
-
Under Report details, choose the location of the AWS account that you want to save the reports to: This account or A different account.
-
Under Destination, choose the destination bucket where you want the inventory reports to be saved.
The destination bucket must be in the same AWS Region as the bucket for which you are setting up the inventory. The destination bucket can be in a different AWS account. When specifying the destination bucket, you can also include an optional prefix to group your inventory reports together.
Under the Destination bucket field, you see the Destination bucket permission statement that is added to the destination bucket policy to allow Amazon S3 to place data in that bucket. For more information, see Creating a destination bucket policy.
-
Under Frequency, choose how often the report will be generated, Daily or Weekly.
-
For Output format, choose one of the following formats for the report:
-
CSV – If you plan to use this inventory report with S3 Batch Operations or if you want to analyze this report in another tool, such as Microsoft Excel, choose CSV.
-
Apache ORC
-
Apache Parquet
-
-
Under Status, choose Enable or Disable.
-
To configure server-side encryption, under Inventory report encryption, follow these steps:
-
Under Server-side encryption, choose either Do not specify an encryption key or Specify an encryption key to encrypt data.
-
To keep the bucket settings for default server-side encryption of objects when storing them in Amazon S3, choose Do not specify an encryption key. As long as the bucket destination has S3 Bucket Keys enabled, the copy operation applies an S3 Bucket Key at the destination bucket.
Note
If the bucket policy for the specified destination requires objects to be encrypted before storing them in Amazon S3, you must choose Specify an encryption key. Otherwise, copying objects to the destination will fail.
-
To encrypt objects before storing them in Amazon S3, choose Specify an encryption key.
-
-
If you chose Specify an encryption key, under Encryption type, you must choose either Amazon S3 managed key (SSE-S3) or AWS Key Management Service key (SSE-KMS).
SSE-S3 uses one of the strongest block ciphers—256-bit Advanced Encryption Standard (AES-256) to encrypt each object. SSE-KMS provides you with more control over your key. For more information about SSE-S3, see Using server-side encryption with Amazon S3 managed keys (SSE-S3). For more information about SSE-KMS, see Using server-side encryption with AWS KMS keys (SSE-KMS).
Note
To encrypt the inventory list file with SSE-KMS, you must grant Amazon S3 permission to use the customer managed key. For instructions, see Grant Amazon S3 Permission to Encrypt Using Your KMS Keys.
-
If you chose AWS Key Management Service key (SSE-KMS), under AWS KMS key, you can specify your AWS KMS key through one of the following options.
Note
If the destination bucket that stores the inventory list file is owned by a different AWS account, make sure that you use a fully qualified KMS key ARN to specify your KMS key.
-
To choose from a list of available KMS keys, choose Choose from your AWS KMS keys, and choose a symmetric encryption KMS key from the list of available keys. Make sure the KMS key is in the same Region as your bucket.
Note
Both the AWS managed key (
aws/s3
) and your customer managed keys appear in the list. However, the AWS managed key (aws/s3
) is not supported for SSE-KMS encryption with S3 Inventory. -
To enter the KMS key ARN, choose Enter AWS KMS key ARN, and enter your KMS key ARN in the field that appears.
-
To create a new customer managed key in the AWS KMS console, choose Create a KMS key.
-
-
-
For Additional metadata fields, select one or more of the following to add to the inventory report:
-
Size – The object size in bytes, not including the size of incomplete multipart uploads, object metadata, and delete markers.
-
Last modified date – The object creation date or the last modified date, whichever is the latest.
-
Multipart upload – Specifies that the object was uploaded as a multipart upload. For more information, see Uploading and copying objects using multipart upload.
-
Replication status – The replication status of the object. For more information, see Getting replication status information.
-
Encryption status – The server-side encryption type that's used to encrypt the object. For more information, see Protecting data with server-side encryption.
-
Bucket Key status – Indicates whether a bucket-level key generated by AWS KMS applies to the object. For more information, see Reducing the cost of SSE-KMS with Amazon S3 Bucket Keys.
-
Object access control list – An access control list (ACL) for each object that defines which AWS accounts or groups are granted access to this object and the type of access that is granted. For more information about this field, see Working with the Object ACL field. For more information about ACLs, see Access control list (ACL) overview.
-
Object owner – The owner of the object.
-
Storage class – The storage class that's used for storing the object.
-
Intelligent-Tiering: Access tier – Indicates the access tier (frequent or infrequent) of the object if it was stored in the S3 Intelligent-Tiering storage class. For more information, see Storage class for automatically optimizing data with changing or unknown access patterns.
-
ETag – The entity tag (ETag) is a hash of the object. The ETag reflects changes only to the contents of an object, not to its metadata. The ETag might or might not be an MD5 digest of the object data. Whether it is depends on how the object was created and how it is encrypted. For more information, see Object in the Amazon Simple Storage Service API Reference.
-
Checksum algorithm – Indicates the algorithm that is used to create the checksum for the object.
-
All Object Lock configurations – The Object Lock status of the object, including the following settings:
-
Object Lock: Retention mode – The level of protection applied to the object, either Governance or Compliance.
-
Object Lock: Retain until date – The date until which the locked object cannot be deleted.
-
Object Lock: Legal hold status – The legal hold status of the locked object.
For information about S3 Object Lock, see How S3 Object Lock works.
-
For more information about the contents of an inventory report, see Amazon S3 Inventory list.
For more information about restricting access to certain optional metadata fields in an inventory configuration, see Control S3 Inventory report configuration creation.
-
-
Choose Create.
Using the REST API to work with S3 Inventory
The following are the REST operations that you can use to work with Amazon S3 Inventory.