Skip to content

How can I include ResourceType in CDK when creating an alarm based on an existing metric?

0

I am in the process of trying to create an alarm via CDK. My Alarm references AWS Config; but specified resourceType is AWS::S3::AccountPublicAccessBlock When I go through the console I am able to easily reference the resourceType as it's included automatically; however, when I go through CDK I can do not see a parameter value where I can pass this in as an argument to CDK.

It's important I include the resourceeType because I have 4 metrics with the same name and different resourceTypes for Config.

Is this something I would need to include in dimension? If so how would this look?

Documents I referenced: https://github.com/aws/aws-cdk/issues/1739

1 Answer
0
Accepted Answer

To create an alarm in CDK that references a specific resourceType in AWS Config, you should include the resourceType as part of the dimensionsMap in the Metric object. This allows you to distinguish between metrics that have the same name but apply to different resource types.

AWS
EXPERT
answered a year ago
EXPERT
reviewed a year ago
  • Thanks,

    So in this scenario I should use dimensionsMap: { ResourceType: 'MyResourceType'} in this format?

    If any examples on this, it would be good but I think I understand right.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.