Description
Describe the bug
AwsCustomResource in custom_resources generates an incorrect IAM action prefix monitoring:<action>
for CloudWatch actions. The correct prefix should be cloudwatch:<action>
.
Regression Issue
- Select this option if this issue appears to be a regression.
Last Known Working CDK Version
No response
Expected Behavior
The generated IAM action prefix should be cloudwatch:<action>
.
https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoncloudwatch.html
Amazon CloudWatch (service prefix: cloudwatch) provides the following service-specific resources, actions, and condition context keys for use in IAM permission policies.
Current Behavior
The generated IAM action prefix is monitoring:<action>
.
Reproduction Steps
- Use AwsCustomResource to create a resource for a CloudWatch action (e.g., tagResource).
- Run cdk synth.
- Observe the generated IAM policy in the synthesized template.
new custom_resources.AwsCustomResource(this, "CustomResource", {
onCreate: {
service: "CloudWatch",
action: "tagResource",
parameters: {
ResourceARN: "dummy",
Tags: [{ Key: "Name", Value: "prod" }],
},
physicalResourceId: custom_resources.PhysicalResourceId.of("add_tag"),
},
policy: custom_resources.AwsCustomResourcePolicy.fromSdkCalls({
resources: custom_resources.AwsCustomResourcePolicy.ANY_RESOURCE,
}),
});
cdk synth
(snip)
CustomResourceCustomResourcePolicy887CD354:
Type: AWS::IAM::Policy
Properties:
PolicyDocument:
Statement:
- Action: monitoring:TagResource
Effect: Allow
Resource: "*"
Version: "2012-10-17"
PolicyName: CustomResourceCustomResourcePolicy887CD354
Roles:
- Ref: AWS679f53fac002430cb0da5b7982bd2287ServiceRoleC1EA0FF2
(snip)
Possible Solution
The issue seems to originate in the sdk-v3-metadata.json file, which maps CloudWatch actions to the incorrect prefix monitoring.
Additional Information/Context
No response
CDK CLI Version
2.176.0
Framework Version
No response
Node.js Version
v22.8.0
OS
macOS Monterey
Language
TypeScript
Language Version
No response
Other information
No response