Skip to content

aws_cloudwatch: Metric class dimensions property limited to 10 items #29322

@ruvimrd

Description

@ruvimrd

Describe the bug

Property: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudwatch.Metric.html#dimensions

CloudFormation allows up to 30 items for the 'dimensions' property as seen here.

Currently CDK limits the items to a maximum amount of 10.
Code with the hard limit: https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-cloudwatch/lib/metric.ts#L512-L514

If you need to deploy an Alarm with more than 30 dimensions, the L1 CfnAlarm has to be used.

Expected Behavior

Up to 30 items should be allowed for the dimensions property

Current Behavior

Error thrown: The maximum number of dimensions is 10, received 11

Reproduction Steps

Simple reproduction:

const metric = new cloudwatch.Metric({
  metricName: 'Test',
  namespace: 'namespace',
  dimensionsMap: {
    d1: 'value1',
    d2: 'value2',
    d3: 'value3',
    d4: 'value4',
    d5: 'value5',
    d6: 'value6',
    d7: 'value7',
    d8: 'value8',
    d9: 'value9',
    d10: 'value10',
    // d11: 'value11'
  }
})

const alarm = new cloudwatch.Alarm(this, 'TestAlarm', {
  comparisonOperator: cloudwatch.ComparisonOperator.GREATER_THAN_THRESHOLD,
  threshold: 1,
  evaluationPeriods: 1,
  metric: metric
});

//Uncomment d11 dimension above to get the error

Possible Solution

Change hard limits from 10 to 30 here: https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-cloudwatch/lib/metric.ts#L512-L514

Additional Information/Context

No response

CDK CLI Version

2.130.0

Framework Version

No response

Node.js Version

18.19.1

OS

macOS

Language

TypeScript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-cloudwatchRelated to Amazon CloudWatchbugThis issue is a bug.effort/smallSmall work item – less than a day of effortp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions