sbstjn / serverless-dynamodb-autoscaling

Serverless Plugin for Amazon DynamoDB Auto Scaling configuration.
https://sbstjn.com/serverless-dynamodb-auto-scaling-with-cloudformation.html
MIT License
148 stars 27 forks source link

make scaleIn & scaleOut accessible #45

Open paulcruseSG opened 6 years ago

paulcruseSG commented 6 years ago

I am trying to set the scaleIn & scaleOut but notice you have them hardcoded to 60.

Is there anyway you can make these optionally configurable? Something like:

capacities:
        -
            table: ExampleTable
            index:
                - secondary1_id
                - secondary2_id
            read:
                minimum: 100
                maximum: 1000
                usage: 0.5
                scaleIn: 30
                scaleOut: 30
            write:
                minimum: 1
                maximum: 1000
                usage: 0.5

Then in your src/plugin.ts:74 pass in our value

private defaults(config: Capacity): Defaults {
    return {
      read: {
        maximum: config.read && config.read.maximum ? config.read.maximum : 200,
        minimum: config.read && config.read.minimum ? config.read.minimum : 5,
        usage: config.read && config.read.usage ? config.read.usage : 0.75,
        scaleIn: config.read && config.read.scaleIn ? config.read.scaleIn : 60,
        scaleOut: config.read && config.read.scaleOut ? config.read.scaleOut : 60
      },
      write: {
        maximum: config.write && config.write.maximum ? config.write.maximum : 200,
        minimum: config.write && config.write.minimum ? config.write.minimum : 5,
        usage: config.write && config.write.usage ? config.write.usage : 0.75,
        scaleIn: config.write && config.write.scaleIn ? config.write.scaleIn : 60,
        scaleOut: config.write && config.write.scaleOut ? config.write.scaleOut : 60
      }
    }
  }

Or in your src/aws/policy.ts:6 default it to 60

constructor (
    options: Options,
    private read: boolean,
    private value: number,
    private scaleIn=60: number,
    private scaleOut=60: number
  ) { super(options) }

This would really make this more generic and allow for more granular control.