Sets up an S3 bucket and configures metrics with filters based on object prefixes and tags.

Terraform Template

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

resource "aws_s3_bucket_metric" "example-filtered" {
  bucket = aws_s3_bucket.example.id

  filter {
    prefix = "documents/"

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