-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cloudwatch): add static helper function to grant metric writing … #258
Conversation
…permissions This fixes #214.
} | ||
|
||
// Percentile statistics | ||
const re = /^p([\d.]+)$/; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not as robust as it could be (allows p.
, amounts other things that it shouldn't).
That's particularly relevant if parseFloat
behaves as nicely as parseInt
does (that is, trying to guess what you meant).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a good point, but not the issue at hand here. I just moved the code around to get around jsii build errors (which I'm surprised they didn't trigger beforehand).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Schrödingbug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jsii build errors
What were the errors?
* @param identity The IAM identity to give permissions to. | ||
*/ | ||
public static grantPutMetricData(identity?: IIdentityResource) { | ||
if (identity) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I always prefer early bail-out:
if (!identity) { return; }
// happy
@@ -80,6 +82,19 @@ export interface MetricProps { | |||
* alarms and graphs. | |||
*/ | |||
export class Metric { | |||
/** | |||
* Grant permissions to the given identity to write metrics. | |||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe indicate that this is going to be a star ("*") resource permission
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no alternative though. ARNs don't seem to have meaning for PutMetricData
. Don't know that it makes sense to put that here, or if people would even expect anything else.
} | ||
|
||
// Percentile statistics | ||
const re = /^p([\d.]+)$/; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jsii build errors
What were the errors?
Exported function returns unexported types. Which it did. Don't know why I didn't get that error before. Probably because it was a free-floating function and wasn't exported by JSII at all? |
…permissions
This fixes #214.
By submitting this pull request, I confirm that my contribution is made under
the terms of the beta license.