Configures analytics for an entire S3 bucket and exports the results to another S3 bucket.

Terraform Template

resource "aws_s3_bucket" "analytics" {
  bucket = "analytics destination"
}

resource "aws_s3_bucket" "example" {
  bucket = "example"
}

resource "aws_s3_bucket_analytics_configuration" "example-entire-bucket" {
  bucket = aws_s3_bucket.example.id
  name = "EntireBucket"

  storage_class_analysis {

    data_export {

      destination {

        s3_bucket_destination {
          bucket_arn = aws_s3_bucket.analytics.arn
        }
      }
    }
  }
}