-
Notifications
You must be signed in to change notification settings - Fork 21
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(cost-explorer): AnomalyMonitor and AnomalySubscription type #39
Open
OlafConijn
wants to merge
3
commits into
master
Choose a base branch
from
feat/cost-explorer
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Distribution / packaging | ||
build/ | ||
dist/ | ||
|
||
# Unit test / coverage reports | ||
.cache | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# RPDK logs | ||
rpdk.log | ||
|
||
# Node.js | ||
node_modules/ | ||
coverage/ | ||
|
||
# contains credentials | ||
sam-tests/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
optional = false | ||
save = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"typeName": "Community::CostExplorer::AnomalyMonitor", | ||
"language": "typescript", | ||
"runtime": "nodejs12.x", | ||
"entrypoint": "dist/handlers.entrypoint", | ||
"testEntrypoint": "dist/handlers.testEntrypoint", | ||
"settings": { | ||
"useDocker": false, | ||
"protocolVersion": "2.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Community::CostExplorer::AnomalyMonitor | ||
|
||
Congratulations on starting development! Next steps: | ||
|
||
1. Write the JSON schema describing your resource, [community-costexplorer-anomalymonitor.json](./community-costexplorer-anomalymonitor.json) | ||
2. Implement your resource handlers in [handlers.ts](./community-costexplorer-anomalymonitor/handlers.ts) | ||
|
||
> Don't modify [models.ts](./community-costexplorer-anomalymonitor/models.ts) by hand, any modifications will be overwritten when the `generate` or `package` commands are run. | ||
|
||
Implement CloudFormation resource here. Each function must always return a ProgressEvent. | ||
|
||
```typescript | ||
const progress: ProgressEvent = ProgressEvent.builder() | ||
|
||
// Required | ||
// Must be one of OperationStatus.InProgress, OperationStatus.Failed, OperationStatus.Success | ||
.status(OperationStatus.InProgress) | ||
// Required on SUCCESS (except for LIST where resourceModels is required) | ||
// The current resource model after the operation; instance of ResourceModel class | ||
.resourceModel(model) | ||
.resourceModels(null) | ||
// Required on FAILED | ||
// Customer-facing message, displayed in e.g. CloudFormation stack events | ||
.message('') | ||
// Required on FAILED a HandlerErrorCode | ||
.errorCode(HandlerErrorCode.InternalFailure) | ||
// Optional | ||
// Use to store any state between re-invocation via IN_PROGRESS | ||
.callbackContext({}) | ||
// Required on IN_PROGRESS | ||
// The number of seconds to delay before re-invocation | ||
.callbackDelaySeconds(0) | ||
|
||
.build() | ||
``` | ||
|
||
While importing the [cfn-rpdk](https://github.com/eduardomourar/cloudformation-cli-typescript-plugin) library, failures can be passed back to CloudFormation by either raising an exception from `exceptions`, or setting the ProgressEvent's `status` to `OperationStatus.Failed` and `errorCode` to one of `HandlerErrorCode`. There is a static helper function, `ProgressEvent.failed`, for this common case. | ||
|
||
Keep in mind, during runtime all logs will be delivered to CloudWatch except those used with `debug` method. |
73 changes: 73 additions & 0 deletions
73
cost-explorer/anomaly-monitor/community-costexplorer-anomalymonitor.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
{ | ||
"typeName": "Community::CostExplorer::AnomalyMonitor", | ||
"description": "An example resource schema demonstrating some basic constructs and validation rules.", | ||
"sourceUrl": "https://github.com/aws-cloudformation/aws-cloudformation-rpdk.git", | ||
"definitions": { | ||
}, | ||
"properties": { | ||
"MonitorName": { | ||
"type": "string" | ||
}, | ||
"MonitorType": { | ||
"type": "string", | ||
"enum": [ | ||
"DIMENSIONAL", | ||
"CUSTOM" | ||
] | ||
}, | ||
"MonitorDimension": { | ||
"type": "string", | ||
"enum": [ | ||
"SERVICE" | ||
] | ||
}, | ||
"MonitorSpecification": { | ||
"type": "object" | ||
}, | ||
"DimensionalValueCount": { | ||
"type": "number" | ||
}, | ||
"Arn": { | ||
"type": "string" | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"required": [ | ||
"MonitorName", | ||
"MonitorType", | ||
"MonitorDimension" | ||
], | ||
"readOnlyProperties": [ | ||
"/properties/Arn" | ||
], | ||
"primaryIdentifier": [ | ||
"/properties/Arn" | ||
], | ||
"handlers": { | ||
"create": { | ||
"permissions": [ | ||
"costExplorer:createAnomalyMonitor" | ||
] | ||
}, | ||
"read": { | ||
"permissions": [ | ||
|
||
] | ||
}, | ||
"update": { | ||
"permissions": [ | ||
"costExplorer:updateAnomalyMonitor" | ||
] | ||
}, | ||
"delete": { | ||
"permissions": [ | ||
"costExplorer:deleteAnomalyMonitor" | ||
] | ||
}, | ||
"list": { | ||
"permissions": [ | ||
|
||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# Community::CostExplorer::AnomalyMonitor | ||
|
||
An example resource schema demonstrating some basic constructs and validation rules. | ||
|
||
## Syntax | ||
|
||
To declare this entity in your AWS CloudFormation template, use the following syntax: | ||
|
||
### JSON | ||
|
||
<pre> | ||
{ | ||
"Type" : "Community::CostExplorer::AnomalyMonitor", | ||
"Properties" : { | ||
"<a href="#monitorname" title="MonitorName">MonitorName</a>" : <i>String</i>, | ||
"<a href="#monitortype" title="MonitorType">MonitorType</a>" : <i>String</i>, | ||
"<a href="#monitordimension" title="MonitorDimension">MonitorDimension</a>" : <i>String</i>, | ||
"<a href="#monitorspecification" title="MonitorSpecification">MonitorSpecification</a>" : <i>Map</i>, | ||
"<a href="#dimensionalvaluecount" title="DimensionalValueCount">DimensionalValueCount</a>" : <i>Double</i>, | ||
} | ||
} | ||
</pre> | ||
|
||
### YAML | ||
|
||
<pre> | ||
Type: Community::CostExplorer::AnomalyMonitor | ||
Properties: | ||
<a href="#monitorname" title="MonitorName">MonitorName</a>: <i>String</i> | ||
<a href="#monitortype" title="MonitorType">MonitorType</a>: <i>String</i> | ||
<a href="#monitordimension" title="MonitorDimension">MonitorDimension</a>: <i>String</i> | ||
<a href="#monitorspecification" title="MonitorSpecification">MonitorSpecification</a>: <i>Map</i> | ||
<a href="#dimensionalvaluecount" title="DimensionalValueCount">DimensionalValueCount</a>: <i>Double</i> | ||
</pre> | ||
|
||
## Properties | ||
|
||
#### MonitorName | ||
|
||
_Required_: Yes | ||
|
||
_Type_: String | ||
|
||
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt) | ||
|
||
#### MonitorType | ||
|
||
_Required_: Yes | ||
|
||
_Type_: String | ||
|
||
_Allowed Values_: <code>DIMENSIONAL</code> | <code>CUSTOM</code> | ||
|
||
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt) | ||
|
||
#### MonitorDimension | ||
|
||
_Required_: Yes | ||
|
||
_Type_: String | ||
|
||
_Allowed Values_: <code>SERVICE</code> | ||
|
||
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt) | ||
|
||
#### MonitorSpecification | ||
|
||
_Required_: No | ||
|
||
_Type_: Map | ||
|
||
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt) | ||
|
||
#### DimensionalValueCount | ||
|
||
_Required_: No | ||
|
||
_Type_: Double | ||
|
||
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt) | ||
|
||
## Return Values | ||
|
||
### Ref | ||
|
||
When you pass the logical ID of this resource to the intrinsic `Ref` function, Ref returns the Arn. | ||
|
||
### Fn::GetAtt | ||
|
||
The `Fn::GetAtt` intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values. | ||
|
||
For more information about using the `Fn::GetAtt` intrinsic function, see [Fn::GetAtt](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.html). | ||
|
||
#### Arn | ||
|
||
Returns the <code>Arn</code> value. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
AWSTemplateFormatVersion: '2010-09-09' | ||
Description: Sample template | ||
|
||
Resources: | ||
AnomalyMonitor: | ||
Type: Community::CostExplorer::AnomalyMonitor | ||
Properties: | ||
MonitorName: 'test-monitor' |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
gitignore can be removed