Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable request metrics for S3 bucket using Cloudformation or CDK

I am able to enable (request metrics for S3 bucket, apid option) in the AWS console manually by checking the checkbox(https://ibb.co/bWDLcNT). But I am trying to do that via code. I tried finding solutions that uses CloudFormation / CDK(nodeJs) / AWS CLI. But no luck. I found solutions only about creating metrics with the filters etc and not much about enabling it.. Any suggestions?

like image 299
Hasteq Avatar asked Jan 30 '26 10:01

Hasteq


1 Answers

You can use MetricsConfiguration:

Specifies a metrics configuration for the CloudWatch request metrics (specified by the metrics configuration ID) from an Amazon S3 bucket.

The example would be:

  MyBucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: somey-bucket-3344-name
      MetricsConfigurations: 
        - Id: EntireBucket

Note EntireBucket. This is the required Id to enable the paid metrics.

like image 162
Marcin Avatar answered Feb 01 '26 01:02

Marcin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!