amazon-s3terraformamazon-cloudwatch-metrics

Terraform - Enable Request Metrics on S3 bucket


Is it possible to enable Request Metrics on an S3 bucket via Terraform, either using the aws_s3_bucket resource or other?


Solution

  • You can use aws_s3_bucket_metric resource in Terraform. Passing the name attribute as EntireBucket enables request metrics for the bucket.

    resource "aws_s3_bucket" "example" {
      bucket = "example"
    }
    
    resource "aws_s3_bucket_metric" "example-entire-bucket" {
      bucket = "${aws_s3_bucket.example.bucket}"
      name   = "EntireBucket"
    }