Skip to content
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

Merged
merged 4 commits into from
Jul 9, 2018

Conversation

rix0rrr
Copy link
Contributor

@rix0rrr rix0rrr commented Jul 9, 2018

…permissions

This fixes #214.

By submitting this pull request, I confirm that my contribution is made under
the terms of the beta license.

}

// Percentile statistics
const re = /^p([\d.]+)$/;
Copy link
Contributor

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).

Copy link
Contributor Author

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).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Schrödingbug?

Copy link
Contributor

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) {
Copy link
Contributor

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.
*
Copy link
Contributor

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

Copy link
Contributor Author

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.]+)$/;
Copy link
Contributor

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?

@rix0rrr
Copy link
Contributor Author

rix0rrr commented Jul 9, 2018

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?

@rix0rrr rix0rrr merged commit ce967d9 into master Jul 9, 2018
@rix0rrr rix0rrr deleted the huijbers/metric-grant-helper branch July 9, 2018 15:22
@NGL321 NGL321 added the contribution/core This is a PR that came from AWS. label Sep 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add static method which grants PutMetricData() to Metric
4 participants