diff --git a/packages/aws-cdk-lib/aws-cloudwatch/lib/metric.ts b/packages/aws-cdk-lib/aws-cloudwatch/lib/metric.ts index 99f7a27bc138c..8b6c05bc45122 100644 --- a/packages/aws-cdk-lib/aws-cloudwatch/lib/metric.ts +++ b/packages/aws-cdk-lib/aws-cloudwatch/lib/metric.ts @@ -509,8 +509,8 @@ export class Metric implements IMetric { } var dimsArray = Object.keys(dims); - if (dimsArray?.length > 10) { - throw new Error(`The maximum number of dimensions is 10, received ${dimsArray.length}`); + if (dimsArray?.length > 30) { + throw new Error(`The maximum number of dimensions is 30, received ${dimsArray.length}`); } dimsArray.map(key => { diff --git a/packages/aws-cdk-lib/aws-cloudwatch/test/metrics.test.ts b/packages/aws-cdk-lib/aws-cloudwatch/test/metrics.test.ts index ac0d0186ea014..42f3bd14a1fbb 100644 --- a/packages/aws-cdk-lib/aws-cloudwatch/test/metrics.test.ts +++ b/packages/aws-cdk-lib/aws-cloudwatch/test/metrics.test.ts @@ -112,7 +112,7 @@ describe('Metrics', () => { }); - testDeprecated('throws error when there are more than 10 dimensions', () => { + testDeprecated('throws error when there are more than 30 dimensions', () => { expect(() => { new Metric({ namespace: 'Test', @@ -130,13 +130,33 @@ describe('Metrics', () => { dimensionI: 'value9', dimensionJ: 'value10', dimensionK: 'value11', + dimensionL: 'value12', + dimensionM: 'value13', + dimensionN: 'value14', + dimensionO: 'value15', + dimensionP: 'value16', + dimensionQ: 'value17', + dimensionR: 'value18', + dimensionS: 'value19', + dimensionT: 'value20', + dimensionU: 'value21', + dimensionV: 'value22', + dimensionW: 'value23', + dimensionX: 'value24', + dimensionY: 'value25', + dimensionZ: 'value26', + dimensionAA: 'value27', + dimensionAB: 'value28', + dimensionAC: 'value29', + dimensionAD: 'value30', + dimensionAE: 'value31', }, } ); - }).toThrow(/The maximum number of dimensions is 10, received 11/); + }).toThrow(/The maximum number of dimensions is 30, received 31/); }); - test('throws error when there are more than 10 dimensions in dimensionsMap', () => { + test('throws error when there are more than 30 dimensions in dimensionsMap', () => { expect(() => { new Metric({ namespace: 'Test', @@ -154,9 +174,29 @@ describe('Metrics', () => { dimensionI: 'value9', dimensionJ: 'value10', dimensionK: 'value11', + dimensionL: 'value12', + dimensionM: 'value13', + dimensionN: 'value14', + dimensionO: 'value15', + dimensionP: 'value16', + dimensionQ: 'value17', + dimensionR: 'value18', + dimensionS: 'value19', + dimensionT: 'value20', + dimensionU: 'value21', + dimensionV: 'value22', + dimensionW: 'value23', + dimensionX: 'value24', + dimensionY: 'value25', + dimensionZ: 'value26', + dimensionAA: 'value27', + dimensionAB: 'value28', + dimensionAC: 'value29', + dimensionAD: 'value30', + dimensionAE: 'value31', }, } ); - }).toThrow(/The maximum number of dimensions is 10, received 11/); + }).toThrow(/The maximum number of dimensions is 30, received 31/); });