Skip to content

Resource: awsS3BucketMetric

Provides a S3 bucket metrics configuration resource.

Example Usage

Add metrics configuration for entire 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 awsS3BucketExample = new aws.s3Bucket.S3Bucket(this, "example", {
  bucket: "example",
});
new aws.s3BucketMetric.S3BucketMetric(this, "example-entire-bucket", {
  bucket: awsS3BucketExample.id,
  name: "EntireBucket",
});

Add metrics 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.s3BucketMetric.S3BucketMetric(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 to put metric configuration.
  • name - (Required) Unique identifier of the metrics configuration for the bucket. Must be less than or equal to 64 characters in length.
  • filter - (Optional) Object filtering that accepts a prefix, tags, or a logical AND of prefix and tags (documented below).

The filter metric configuration supports the following:

\~> NOTE: At least one of prefix or tags is required when specifying a filter

  • prefix - (Optional) Object prefix for filtering (singular).
  • tags - (Optional) Object tags for filtering (up to 10).

Attributes Reference

No additional attributes are exported.

Import

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

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