Skip to content

Resource: awsS3BucketAnalyticsConfiguration

Provides a S3 bucket analytics configuration resource.

Example Usage

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

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsS3BucketAnalytics = new aws.s3Bucket.S3Bucket(this, "analytics", {
  bucket: "analytics destination",
});
const awsS3BucketExample = new aws.s3Bucket.S3Bucket(this, "example", {
  bucket: "example",
});
new aws.s3BucketAnalyticsConfiguration.S3BucketAnalyticsConfiguration(
  this,
  "example-entire-bucket",
  {
    bucket: awsS3BucketExample.id,
    name: "EntireBucket",
    storageClassAnalysis: {
      dataExport: {
        destination: {
          s3BucketDestination: {
            bucketArn: awsS3BucketAnalytics.arn,
          },
        },
      },
    },
  }
);

Add analytics configuration with S3 object filter

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsS3BucketExample = new aws.s3Bucket.S3Bucket(this, "example", {
  bucket: "example",
});
new aws.s3BucketAnalyticsConfiguration.S3BucketAnalyticsConfiguration(
  this,
  "example-filtered",
  {
    bucket: awsS3BucketExample.id,
    filter: {
      prefix: "documents/",
      tags: {
        class: "blue",
        priority: "high",
      },
    },
    name: "ImportantBlueDocuments",
  }
);

Argument Reference

The following arguments are supported:

  • bucket - (Required) Name of the bucket this analytics configuration is associated with.
  • name - (Required) Unique identifier of the analytics configuration for the bucket.
  • filter - (Optional) Object filtering that accepts a prefix, tags, or a logical AND of prefix and tags (documented below).
  • storageClassAnalysis - (Optional) Configuration for the analytics data export (documented below).

The filter configuration supports the following:

  • prefix - (Optional) Object prefix for filtering.
  • tags - (Optional) Set of object tags for filtering.

The storageClassAnalysis configuration supports the following:

  • dataExport - (Required) Data export configuration (documented below).

The dataExport configuration supports the following:

  • outputSchemaVersion - (Optional) Schema version of exported analytics data. Allowed values: V_1. Default value: V_1.
  • destination - (Required) Specifies the destination for the exported analytics data (documented below).

The destination configuration supports the following:

  • s3BucketDestination - (Required) Analytics data export currently only supports an S3 bucket destination (documented below).

The s3BucketDestination configuration supports the following:

  • bucketArn - (Required) ARN of the destination bucket.
  • bucketAccountId - (Optional) Account ID that owns the destination bucket.
  • format - (Optional) Output format of exported analytics data. Allowed values: csv. Default value: csv.
  • prefix - (Optional) Prefix to append to exported analytics data.

Attributes Reference

No additional attributes are exported.

Import

S3 bucket analytics configurations can be imported using bucket:analytics, e.g.,

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