Resource: aws_s3_bucket_inventory

Provides a S3 bucket inventory configuration resource.

Example Usage

Add inventory configuration

resource "aws_s3_bucket" "test" {
  bucket = "my-tf-test-bucket"
}

resource "aws_s3_bucket" "inventory" {
  bucket = "my-tf-inventory-bucket"
}

resource "aws_s3_bucket_inventory" "test" {
  bucket = aws_s3_bucket.test.id
  name   = "EntireBucketDaily"

  included_object_versions = "All"

  schedule {
    frequency = "Daily"
  }

  destination {
    bucket {
      format     = "ORC"
      bucket_arn = aws_s3_bucket.inventory.arn
    }
  }
}

Add inventory configuration with S3 object prefix

resource "aws_s3_bucket" "test" {
  bucket = "my-tf-test-bucket"
}

resource "aws_s3_bucket" "inventory" {
  bucket = "my-tf-inventory-bucket"
}

resource "aws_s3_bucket_inventory" "test-prefix" {
  bucket = aws_s3_bucket.test.id
  name   = "DocumentsWeekly"

  included_object_versions = "All"

  schedule {
    frequency = "Daily"
  }

  filter {
    prefix = "documents/"
  }

  destination {
    bucket {
      format     = "ORC"
      bucket_arn = aws_s3_bucket.inventory.arn
      prefix     = "inventory"
    }
  }
}

Argument Reference

This resource supports the following arguments:

The filter configuration supports the following:

The schedule configuration supports the following:

The destination configuration supports the following:

The bucket configuration supports the following:

The encryption configuration supports the following:

The sse_kms configuration supports the following:

Attribute Reference

This resource exports no additional attributes.

Import

In Terraform v1.5.0 and later, use an import block to import S3 bucket inventory configurations using bucket:inventory. For example:

import {
  to = aws_s3_bucket_inventory.my-bucket-entire-bucket
  id = "my-bucket:EntireBucket"
}

Using terraform import, import S3 bucket inventory configurations using bucket:inventory. For example:

% terraform import aws_s3_bucket_inventory.my-bucket-entire-bucket my-bucket:EntireBucket