Skip to content

Commit

Permalink
fix write setup overwriting read setup. (#22)
Browse files Browse the repository at this point in the history
* fix write setup overwriting read setup.

* Rewrite getPolicyAndTarget()

* Rewrite getPolicyAndTarget()

* Add docs
  • Loading branch information
tmclaugh authored and sbstjn committed Aug 15, 2017
1 parent a253f6c commit 09ac916
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,24 @@ class Plugin {

// Only add Auto Scaling for read capacity if configuration set is available
if (!!config.read) {
resources.push(...this.getPolicyAndTarget(options, data, true))
resources.push(...this.getPolicyAndTarget(options, data.read, true))
}

// Only add Auto Scaling for write capacity if configuration set is available
if (!!config.write) {
resources.push(...this.getPolicyAndTarget(options, data, false))
resources.push(...this.getPolicyAndTarget(options, data.write, false))
}

return resources
}

private getPolicyAndTarget(options: Options, data: Defaults, read: boolean): any[] {
/**
* Create Policy and Target resource
*/
private getPolicyAndTarget(options: Options, data: CapacityConfiguration, read: boolean): any[] {
return [
new Policy(options, false, data.read.usage * 100, 60, 60),
new Target(options, false, data.read.minimum, data.read.maximum)
new Policy(options, read, data.usage * 100, 60, 60),
new Target(options, read, data.minimum, data.maximum)
]
}

Expand Down

0 comments on commit 09ac916

Please sign in to comment.