Resource: aws_s3_bucket_analytics_configuration

Provides a S3 bucket analytics configuration resource.

Example Usage

Add analytics configuration for entire S3 bucket and export results to a second S3 bucket

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
        }
      }
    }
  }
}

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

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

Add analytics configuration with S3 object filter

resource "aws_s3_bucket_analytics_configuration" "example-filtered" {
  bucket = aws_s3_bucket.example.id
  name   = "ImportantBlueDocuments"

  filter {
    prefix = "documents/"

    tags = {
      priority = "high"
      class    = "blue"
    }
  }
}

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

Argument Reference

This resource supports the following arguments:

The filter configuration supports the following:

The storage_class_analysis configuration supports the following:

The data_export configuration supports the following:

The destination configuration supports the following:

The s3_bucket_destination 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 analytics configurations using bucket:analytics. For example:

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

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

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