AWS Amazon S3 Bucket Inventory

This page shows how to write Terraform and CloudFormation for Amazon S3 Bucket Inventory and write them securely.

aws_s3_bucket_inventory (Terraform)

The Bucket Inventory in Amazon S3 can be configured in Terraform with the resource name aws_s3_bucket_inventory. The following sections describe 5 examples of how to use the resource and its parameters.

Example Usage from GitHub

main.tf#L26
resource "aws_s3_bucket_inventory" "invtry_orc" {
  bucket = aws_s3_bucket.bucket_w_invtry.id
  name   = "EntireBucketDailyORC"

  included_object_versions = "All"

s3_bucket_inventory_test.tf#L20
resource "aws_s3_bucket_inventory" "inventory" {
  bucket                   = aws_s3_bucket.bucket1.bucket
  name                     = "inventory"
  included_object_versions = "All"

  schedule {
inventory.tf#L13
resource "aws_s3_bucket_inventory" "cache-inventory" {
  provider = aws.us
  bucket   = aws_s3_bucket.cache.id
  name     = "WeeklyInventory"

  included_object_versions = "All"
s3_bucket_inventory_test.tf#L20
resource "aws_s3_bucket_inventory" "inventory" {
  bucket                   = aws_s3_bucket.bucket1.bucket
  name                     = "inventory"
  included_object_versions = "All"

  schedule {
main.tf#L15
resource "aws_s3_bucket_inventory" "daily" {
  for_each = toset(var.bucket_list)

  bucket                   = each.key
  name                     = "FullBucketDailyInventory"
  included_object_versions = "All"

Parameters

Explanation in Terraform Registry

Provides a S3 bucket inventory configuration resource.

AWS::S3::Bucket InventoryConfiguration (CloudFormation)

The Bucket InventoryConfiguration in S3 can be configured in CloudFormation with the resource name AWS::S3::Bucket InventoryConfiguration. The following sections describe how to use the resource and its parameters.

Example Usage from GitHub

An example could not be found in GitHub.

Parameters

Destination Contains information about where to publish the inventory results.
Required: Yes
Type: Destination
Update requires: No interruption

Enabled Specifies whether the inventory is enabled or disabled. If set to True, an inventory list is generated. If set to False, no inventory list is generated.
Required: Yes
Type: Boolean
Update requires: No interruption

Id The ID used to identify the inventory configuration.
Required: Yes
Type: String
Update requires: No interruption

IncludedObjectVersions Object versions to include in the inventory list. If set to All, the list includes all 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.
Required: Yes
Type: String
Allowed values: All | Current
Update requires: No interruption

OptionalFields Contains the optional fields that are included in the inventory results.
Valid values: Size | LastModifiedDate | StorageClass | ETag | IsMultipartUploaded | ReplicationStatus | EncryptionStatus | ObjectLockRetainUntilDate | ObjectLockMode | ObjectLockLegalHoldStatus | IntelligentTieringAccessTier | BucketKeyStatus
Required: No
Type: List of String
Update requires: No interruption

Prefix Specifies the inventory filter prefix.
Required: No
Type: String
Update requires: No interruption

ScheduleFrequency Specifies the schedule for generating inventory results.
Allowed values: Daily | Weekly
Required: Yes
Type: String
Update requires: No interruption

Explanation in CloudFormation Registry

Specifies the inventory configuration for an Amazon S3 bucket. For more information, see GET Bucket inventory in the Amazon S3 API Reference.

Frequently asked questions

What is AWS Amazon S3 Bucket Inventory?

AWS Amazon S3 Bucket Inventory is a resource for Amazon S3 of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.

Where can I find the example code for the AWS Amazon S3 Bucket Inventory?

For Terraform, the benjdewantara/benjdewantara-iac, gilyas/infracost and NixOS/nixos-org-configurations source code examples are useful. See the Terraform Example section for further details.