New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

serverless-dynamodb-autoscaling

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

serverless-dynamodb-autoscaling - npm Package Compare versions

Comparing version

to
0.5.1

2

coverage/coverage-final.json

@@ -1,2 +0,2 @@

{"/home/ubuntu/serverless-dynamodb-autoscaling/src/plugin.ts": {"path":"/home/ubuntu/serverless-dynamodb-autoscaling/src/plugin.ts","statementMap":{"0":{"start":{"line":2,"column":0},"end":{"line":2,"column":62}},"1":{"start":{"line":3,"column":15},"end":{"line":3,"column":32}},"2":{"start":{"line":4,"column":10},"end":{"line":4,"column":27}},"3":{"start":{"line":5,"column":13},"end":{"line":5,"column":28}},"4":{"start":{"line":6,"column":17},"end":{"line":6,"column":40}},"5":{"start":{"line":7,"column":15},"end":{"line":7,"column":36}},"6":{"start":{"line":8,"column":17},"end":{"line":8,"column":40}},"7":{"start":{"line":9,"column":13},"end":{"line":13,"column":1}},"8":{"start":{"line":19,"column":8},"end":{"line":19,"column":37}},"9":{"start":{"line":20,"column":8},"end":{"line":22,"column":10}},"10":{"start":{"line":28,"column":8},"end":{"line":28,"column":61}},"11":{"start":{"line":34,"column":8},"end":{"line":34,"column":56}},"12":{"start":{"line":40,"column":8},"end":{"line":40,"column":60}},"13":{"start":{"line":41,"column":8},"end":{"line":41,"column":68}},"14":{"start":{"line":42,"column":8},"end":{"line":42,"column":77}},"15":{"start":{"line":43,"column":8},"end":{"line":43,"column":82}},"16":{"start":{"line":44,"column":8},"end":{"line":44,"column":87}},"17":{"start":{"line":45,"column":8},"end":{"line":45,"column":75}},"18":{"start":{"line":46,"column":8},"end":{"line":46,"column":86}},"19":{"start":{"line":52,"column":8},"end":{"line":63,"column":10}},"20":{"start":{"line":69,"column":26},"end":{"line":69,"column":28}},"21":{"start":{"line":70,"column":24},"end":{"line":70,"column":45}},"22":{"start":{"line":71,"column":22},"end":{"line":71,"column":37}},"23":{"start":{"line":72,"column":21},"end":{"line":72,"column":42}},"24":{"start":{"line":74,"column":8},"end":{"line":74,"column":143}},"25":{"start":{"line":76,"column":8},"end":{"line":76,"column":73}},"26":{"start":{"line":78,"column":8},"end":{"line":82,"column":9}},"27":{"start":{"line":79,"column":12},"end":{"line":81,"column":191}},"28":{"start":{"line":84,"column":8},"end":{"line":88,"column":9}},"29":{"start":{"line":85,"column":12},"end":{"line":87,"column":196}},"30":{"start":{"line":89,"column":8},"end":{"line":89,"column":25}},"31":{"start":{"line":95,"column":24},"end":{"line":95,"column":26}},"32":{"start":{"line":96,"column":29},"end":{"line":96,"column":31}},"33":{"start":{"line":97,"column":24},"end":{"line":97,"column":52}},"34":{"start":{"line":98,"column":8},"end":{"line":100,"column":9}},"35":{"start":{"line":99,"column":12},"end":{"line":99,"column":32}},"36":{"start":{"line":101,"column":8},"end":{"line":105,"column":11}},"37":{"start":{"line":102,"column":28},"end":{"line":102,"column":133}},"38":{"start":{"line":102,"column":83},"end":{"line":102,"column":132}},"39":{"start":{"line":103,"column":12},"end":{"line":103,"column":50}},"40":{"start":{"line":104,"column":12},"end":{"line":104,"column":76}},"41":{"start":{"line":104,"column":51},"end":{"line":104,"column":74}},"42":{"start":{"line":106,"column":8},"end":{"line":106,"column":25}},"43":{"start":{"line":112,"column":8},"end":{"line":114,"column":9}},"44":{"start":{"line":113,"column":12},"end":{"line":113,"column":26}},"45":{"start":{"line":115,"column":8},"end":{"line":115,"column":37}},"46":{"start":{"line":121,"column":8},"end":{"line":121,"column":317}},"47":{"start":{"line":121,"column":69},"end":{"line":121,"column":100}},"48":{"start":{"line":121,"column":122},"end":{"line":121,"column":315}},"49":{"start":{"line":121,"column":170},"end":{"line":121,"column":314}},"50":{"start":{"line":121,"column":221},"end":{"line":121,"column":313}},"51":{"start":{"line":124,"column":8},"end":{"line":124,"column":378}},"52":{"start":{"line":124,"column":44},"end":{"line":124,"column":59}},"53":{"start":{"line":124,"column":72},"end":{"line":124,"column":145}},"54":{"start":{"line":124,"column":158},"end":{"line":124,"column":172}},"55":{"start":{"line":124,"column":185},"end":{"line":124,"column":271}},"56":{"start":{"line":124,"column":288},"end":{"line":124,"column":376}},"57":{"start":{"line":127,"column":0},"end":{"line":127,"column":24}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":18,"column":4},"end":{"line":18,"column":5}},"loc":{"start":{"line":18,"column":28},"end":{"line":23,"column":5}},"line":18},"1":{"name":"(anonymous_1)","decl":{"start":{"line":27,"column":4},"end":{"line":27,"column":5}},"loc":{"start":{"line":27,"column":15},"end":{"line":29,"column":5}},"line":27},"2":{"name":"(anonymous_2)","decl":{"start":{"line":33,"column":4},"end":{"line":33,"column":5}},"loc":{"start":{"line":33,"column":21},"end":{"line":35,"column":5}},"line":33},"3":{"name":"(anonymous_3)","decl":{"start":{"line":39,"column":4},"end":{"line":39,"column":5}},"loc":{"start":{"line":39,"column":15},"end":{"line":47,"column":5}},"line":39},"4":{"name":"(anonymous_4)","decl":{"start":{"line":51,"column":4},"end":{"line":51,"column":5}},"loc":{"start":{"line":51,"column":21},"end":{"line":64,"column":5}},"line":51},"5":{"name":"(anonymous_5)","decl":{"start":{"line":68,"column":4},"end":{"line":68,"column":5}},"loc":{"start":{"line":68,"column":36},"end":{"line":90,"column":5}},"line":68},"6":{"name":"(anonymous_6)","decl":{"start":{"line":94,"column":4},"end":{"line":94,"column":5}},"loc":{"start":{"line":94,"column":28},"end":{"line":107,"column":5}},"line":94},"7":{"name":"(anonymous_7)","decl":{"start":{"line":101,"column":24},"end":{"line":101,"column":25}},"loc":{"start":{"line":101,"column":35},"end":{"line":105,"column":9}},"line":101},"8":{"name":"(anonymous_8)","decl":{"start":{"line":102,"column":69},"end":{"line":102,"column":70}},"loc":{"start":{"line":102,"column":83},"end":{"line":102,"column":132}},"line":102},"9":{"name":"(anonymous_9)","decl":{"start":{"line":104,"column":41},"end":{"line":104,"column":42}},"loc":{"start":{"line":104,"column":51},"end":{"line":104,"column":74}},"line":104},"10":{"name":"(anonymous_10)","decl":{"start":{"line":111,"column":4},"end":{"line":111,"column":5}},"loc":{"start":{"line":111,"column":20},"end":{"line":116,"column":5}},"line":111},"11":{"name":"(anonymous_11)","decl":{"start":{"line":120,"column":4},"end":{"line":120,"column":5}},"loc":{"start":{"line":120,"column":14},"end":{"line":122,"column":5}},"line":120},"12":{"name":"(anonymous_12)","decl":{"start":{"line":121,"column":57},"end":{"line":121,"column":58}},"loc":{"start":{"line":121,"column":69},"end":{"line":121,"column":100}},"line":121},"13":{"name":"(anonymous_13)","decl":{"start":{"line":121,"column":110},"end":{"line":121,"column":111}},"loc":{"start":{"line":121,"column":122},"end":{"line":121,"column":315}},"line":121},"14":{"name":"(anonymous_14)","decl":{"start":{"line":121,"column":159},"end":{"line":121,"column":160}},"loc":{"start":{"line":121,"column":170},"end":{"line":121,"column":314}},"line":121},"15":{"name":"(anonymous_15)","decl":{"start":{"line":121,"column":207},"end":{"line":121,"column":208}},"loc":{"start":{"line":121,"column":221},"end":{"line":121,"column":313}},"line":121},"16":{"name":"(anonymous_16)","decl":{"start":{"line":123,"column":4},"end":{"line":123,"column":5}},"loc":{"start":{"line":123,"column":28},"end":{"line":125,"column":5}},"line":123},"17":{"name":"(anonymous_17)","decl":{"start":{"line":124,"column":38},"end":{"line":124,"column":39}},"loc":{"start":{"line":124,"column":44},"end":{"line":124,"column":59}},"line":124},"18":{"name":"(anonymous_18)","decl":{"start":{"line":124,"column":66},"end":{"line":124,"column":67}},"loc":{"start":{"line":124,"column":72},"end":{"line":124,"column":145}},"line":124},"19":{"name":"(anonymous_19)","decl":{"start":{"line":124,"column":152},"end":{"line":124,"column":153}},"loc":{"start":{"line":124,"column":158},"end":{"line":124,"column":172}},"line":124},"20":{"name":"(anonymous_20)","decl":{"start":{"line":124,"column":179},"end":{"line":124,"column":180}},"loc":{"start":{"line":124,"column":185},"end":{"line":124,"column":271}},"line":124},"21":{"name":"(anonymous_21)","decl":{"start":{"line":124,"column":279},"end":{"line":124,"column":280}},"loc":{"start":{"line":124,"column":288},"end":{"line":124,"column":376}},"line":124}},"branchMap":{"0":{"loc":{"start":{"line":54,"column":25},"end":{"line":54,"column":87}},"type":"cond-expr","locations":[{"start":{"line":54,"column":62},"end":{"line":54,"column":81}},{"start":{"line":54,"column":84},"end":{"line":54,"column":87}}],"line":54},"1":{"loc":{"start":{"line":54,"column":25},"end":{"line":54,"column":59}},"type":"binary-expr","locations":[{"start":{"line":54,"column":25},"end":{"line":54,"column":36}},{"start":{"line":54,"column":40},"end":{"line":54,"column":59}}],"line":54},"2":{"loc":{"start":{"line":55,"column":25},"end":{"line":55,"column":85}},"type":"cond-expr","locations":[{"start":{"line":55,"column":62},"end":{"line":55,"column":81}},{"start":{"line":55,"column":84},"end":{"line":55,"column":85}}],"line":55},"3":{"loc":{"start":{"line":55,"column":25},"end":{"line":55,"column":59}},"type":"binary-expr","locations":[{"start":{"line":55,"column":25},"end":{"line":55,"column":36}},{"start":{"line":55,"column":40},"end":{"line":55,"column":59}}],"line":55},"4":{"loc":{"start":{"line":56,"column":23},"end":{"line":56,"column":82}},"type":"cond-expr","locations":[{"start":{"line":56,"column":58},"end":{"line":56,"column":75}},{"start":{"line":56,"column":78},"end":{"line":56,"column":82}}],"line":56},"5":{"loc":{"start":{"line":56,"column":23},"end":{"line":56,"column":55}},"type":"binary-expr","locations":[{"start":{"line":56,"column":23},"end":{"line":56,"column":34}},{"start":{"line":56,"column":38},"end":{"line":56,"column":55}}],"line":56},"6":{"loc":{"start":{"line":59,"column":25},"end":{"line":59,"column":90}},"type":"cond-expr","locations":[{"start":{"line":59,"column":64},"end":{"line":59,"column":84}},{"start":{"line":59,"column":87},"end":{"line":59,"column":90}}],"line":59},"7":{"loc":{"start":{"line":59,"column":25},"end":{"line":59,"column":61}},"type":"binary-expr","locations":[{"start":{"line":59,"column":25},"end":{"line":59,"column":37}},{"start":{"line":59,"column":41},"end":{"line":59,"column":61}}],"line":59},"8":{"loc":{"start":{"line":60,"column":25},"end":{"line":60,"column":88}},"type":"cond-expr","locations":[{"start":{"line":60,"column":64},"end":{"line":60,"column":84}},{"start":{"line":60,"column":87},"end":{"line":60,"column":88}}],"line":60},"9":{"loc":{"start":{"line":60,"column":25},"end":{"line":60,"column":61}},"type":"binary-expr","locations":[{"start":{"line":60,"column":25},"end":{"line":60,"column":37}},{"start":{"line":60,"column":41},"end":{"line":60,"column":61}}],"line":60},"10":{"loc":{"start":{"line":61,"column":23},"end":{"line":61,"column":85}},"type":"cond-expr","locations":[{"start":{"line":61,"column":60},"end":{"line":61,"column":78}},{"start":{"line":61,"column":81},"end":{"line":61,"column":85}}],"line":61},"11":{"loc":{"start":{"line":61,"column":23},"end":{"line":61,"column":57}},"type":"binary-expr","locations":[{"start":{"line":61,"column":23},"end":{"line":61,"column":35}},{"start":{"line":61,"column":39},"end":{"line":61,"column":57}}],"line":61},"12":{"loc":{"start":{"line":74,"column":107},"end":{"line":74,"column":139}},"type":"cond-expr","locations":[{"start":{"line":74,"column":116},"end":{"line":74,"column":133}},{"start":{"line":74,"column":137},"end":{"line":74,"column":139}}],"line":74},"13":{"loc":{"start":{"line":78,"column":8},"end":{"line":82,"column":9}},"type":"if","locations":[{"start":{"line":78,"column":8},"end":{"line":82,"column":9}},{"start":{"line":78,"column":8},"end":{"line":82,"column":9}}],"line":78},"14":{"loc":{"start":{"line":84,"column":8},"end":{"line":88,"column":9}},"type":"if","locations":[{"start":{"line":84,"column":8},"end":{"line":88,"column":9}},{"start":{"line":84,"column":8},"end":{"line":88,"column":9}}],"line":84},"15":{"loc":{"start":{"line":98,"column":8},"end":{"line":100,"column":9}},"type":"if","locations":[{"start":{"line":98,"column":8},"end":{"line":100,"column":9}},{"start":{"line":98,"column":8},"end":{"line":100,"column":9}}],"line":98},"16":{"loc":{"start":{"line":112,"column":8},"end":{"line":114,"column":9}},"type":"if","locations":[{"start":{"line":112,"column":8},"end":{"line":114,"column":9}},{"start":{"line":112,"column":8},"end":{"line":114,"column":9}}],"line":112},"17":{"loc":{"start":{"line":112,"column":12},"end":{"line":112,"column":46}},"type":"binary-expr","locations":[{"start":{"line":112,"column":12},"end":{"line":112,"column":16}},{"start":{"line":112,"column":20},"end":{"line":112,"column":46}}],"line":112},"18":{"loc":{"start":{"line":115,"column":16},"end":{"line":115,"column":26}},"type":"binary-expr","locations":[{"start":{"line":115,"column":16},"end":{"line":115,"column":20}},{"start":{"line":115,"column":24},"end":{"line":115,"column":26}}],"line":115},"19":{"loc":{"start":{"line":121,"column":69},"end":{"line":121,"column":100}},"type":"binary-expr","locations":[{"start":{"line":121,"column":69},"end":{"line":121,"column":82}},{"start":{"line":121,"column":86},"end":{"line":121,"column":100}}],"line":121}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":2,"9":2,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":1,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":5,"44":1,"45":4,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":1},"f":{"0":2,"1":0,"2":0,"3":0,"4":1,"5":0,"6":0,"7":0,"8":0,"9":0,"10":5,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0},"b":{"0":[1,0],"1":[1,1],"2":[0,1],"3":[1,1],"4":[1,0],"5":[1,1],"6":[0,1],"7":[1,1],"8":[1,0],"9":[1,1],"10":[0,1],"11":[1,1],"12":[0,0],"13":[0,0],"14":[0,0],"15":[0,0],"16":[1,4],"17":[5,4],"18":[4,1],"19":[0,0]},"inputSourceMap":{"version":3,"file":"plugin.js","sourceRoot":"","sources":["plugin.ts"],"names":[],"mappings":";;AAAA,i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UAAU,CAAC,MAAM,CAC9C,CAAC,MAAgB,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CACtD,CAAC,OAAO,CACP,CAAC,MAAgB,KAAK,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CACxD,CAAC,KAAa,KAAK,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CACrD,CAAC,QAAgB,KAAK,CAAC,CAAC,KAAK,CAC3B,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,8BAA8B,CAAC,SAAS,EACzE,QAAQ,CACT,CACF,CACF,CACF,CAAA;IACH,CAAC;IAEO,qBAAqB;QAC3B,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAC3B,MAAM,IAAI,CAAC,QAAQ,EAAE,CACtB,CAAC,IAAI,CACJ,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,mCAAmC,CAAC,CAAC,CAChF,CAAC,IAAI,CACJ,MAAM,IAAI,CAAC,OAAO,EAAE,CACrB,CAAC,IAAI,CACJ,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,gDAAgD,CAAC,CAAC,CAC7F,CAAC,KAAK,CACL,CAAC,GAAU,KAAK,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,qCAAqC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CACzG,CAAA;IACH,CAAC;CACF;AAED,MAAM,CAAC,OAAO,GAAG,MAAM,CAAA","sourcesContent":["import * as assert from 'assert'\nimport * as _ from 'lodash'\nimport * as util from 'util'\n\nimport Policy from './aws/policy'\nimport Role from './aws/role'\nimport Target from './aws/target'\n\nconst text = {\n INVALID_CONFIGURATION: 'Invalid serverless configuration',\n NO_AUTOSCALING_CONFIG: 'Not Auto Scaling configuration found',\n ONLY_AWS_SUPPORT: 'Only supported for AWS provicer'\n}\n\nclass Plugin {\n public hooks: {}\n\n /**\n * Constructur\n */\n constructor (private serverless: Serverless) {\n this.hooks = {\n 'deploy:compileEvents': this.beforeDeployResources.bind(this)\n }\n }\n\n /**\n * Get the current stage name\n */\n private getStage(): string {\n return this.serverless.getProvider('aws').getStage()\n }\n\n /**\n * Get the current service name\n */\n private getServiceName(): string {\n return this.serverless.service.getServiceName()\n }\n\n /**\n * Validate the request and check if configuration is available\n */\n private validate(): void {\n assert(this.serverless, text.INVALID_CONFIGURATION)\n assert(this.serverless.service, text.INVALID_CONFIGURATION)\n assert(this.serverless.service.provider, text.INVALID_CONFIGURATION)\n assert(this.serverless.service.provider.name, text.INVALID_CONFIGURATION)\n assert(this.serverless.service.provider.name === 'aws', text.ONLY_AWS_SUPPORT)\n\n assert(this.serverless.service.custom, text.NO_AUTOSCALING_CONFIG)\n assert(this.serverless.service.custom.capacities, text.NO_AUTOSCALING_CONFIG)\n }\n\n /**\n * Parse configuration and fill up with default values when needed\n */\n private defaults(config: Capacity): { read: CapacityConfiguration, write: CapacityConfiguration } {\n return {\n read: {\n maximum: config.read && config.read.maximum ? config.read.maximum : 200,\n minimum: config.read && config.read.minimum ? config.read.minimum : 5,\n usage: config.read && config.read.usage ? config.read.usage : 0.75\n },\n write: {\n maximum: config.write && config.write.maximum ? config.write.maximum : 200,\n minimum: config.write && config.write.minimum ? config.write.minimum : 5,\n usage: config.write && config.write.usage ? config.write.usage : 0.75\n }\n }\n }\n\n /**\n * Create CloudFormation resources for table (and optional index)\n */\n private resources(table: string, index: string, config: Capacity): any[] {\n const resources = []\n const service = this.getServiceName()\n const stage = this.getStage()\n const data = this.defaults(config)\n\n // Start processing configuration\n this.serverless.cli.log(\n util.format(' - Building configuration for resource \"table/%s%s\"', table, (index ? ('/index/' + index) : ''))\n )\n\n // Add role to manage Auto Scaling policies\n resources.push(new Role(service, table, index, stage))\n\n // Only add Auto Scaling for read capacity if configuration set is available\n if (config.read) {\n resources.push(\n // ScaleIn/ScaleOut values are fix to 60% usage\n new Policy(service, table, data.read.usage, true, 60, 60, index, stage),\n new Target(service, table, data.read.minimum, data.read.maximum, true, index, stage)\n )\n }\n\n // Only add Auto Scaling for write capacity if configuration set is available\n if (config.write) {\n resources.push(\n // ScaleIn/ScaleOut values are fix to 60% usage\n new Policy(service, table, data.write.usage, false, 60, 60, index, stage),\n new Target(service, table, data.write.minimum, data.write.maximum, false, index, stage)\n )\n }\n\n return resources\n }\n\n /**\n * Generate CloudFormation resources for DynamoDB table and indexes\n */\n private generate(table: string, config: Capacity) {\n let resources: any[] = []\n let lastRessources: any[] = []\n\n const indexes = this.normalize(config.index)\n if (!config.indexOnly) {\n indexes.unshift('') // Horrible solution\n }\n\n indexes.forEach(\n (index: string) => {\n const current = this.resources(table, index, config).map(\n (resource: any) => resource.setDependencies(lastRessources).toJSON()\n )\n\n resources = resources.concat(current)\n lastRessources = current.map((item: any) => Object.keys(item).pop())\n }\n )\n\n return resources\n }\n\n /**\n * Check if parameter is defined and return as array if only a string is provided\n */\n private normalize(data: string|string[]): string[] {\n if (data && data.constructor !== Array) {\n return [ data as string ]\n }\n\n return (data as string[] || []).slice(0)\n }\n\n /**\n * Process the provided configuration\n */\n private process() {\n this.serverless.service.custom.capacities.filter(\n (config: Capacity) => !!config.read || !!config.write\n ).forEach(\n (config: Capacity) => this.normalize(config.table).forEach(\n (table: string) => this.generate(table, config).forEach(\n (resource: string) => _.merge(\n this.serverless.service.provider.compiledCloudFormationTemplate.Resources,\n resource\n )\n )\n )\n )\n }\n\n private beforeDeployResources(): Promise<any> {\n return Promise.resolve().then(\n () => this.validate()\n ).then(\n () => this.serverless.cli.log(util.format('Configure DynamoDB Auto Scaling …'))\n ).then(\n () => this.process()\n ).then(\n () => this.serverless.cli.log(util.format('Added DynamoDB Auto Scaling to CloudFormation!'))\n ).catch(\n (err: Error) => this.serverless.cli.log(util.format('Skipping DynamoDB Auto Scaling: %s!', err.message))\n )\n }\n}\n\nmodule.exports = Plugin\n"]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"a73fab9825f1d3f3782708a752d3f6dd27c9d9d7"}
{"/home/ubuntu/serverless-dynamodb-autoscaling/src/plugin.ts": {"path":"/home/ubuntu/serverless-dynamodb-autoscaling/src/plugin.ts","statementMap":{"0":{"start":{"line":2,"column":0},"end":{"line":2,"column":62}},"1":{"start":{"line":3,"column":15},"end":{"line":3,"column":32}},"2":{"start":{"line":4,"column":10},"end":{"line":4,"column":27}},"3":{"start":{"line":5,"column":13},"end":{"line":5,"column":28}},"4":{"start":{"line":6,"column":17},"end":{"line":6,"column":40}},"5":{"start":{"line":7,"column":15},"end":{"line":7,"column":36}},"6":{"start":{"line":8,"column":17},"end":{"line":8,"column":40}},"7":{"start":{"line":9,"column":13},"end":{"line":13,"column":1}},"8":{"start":{"line":19,"column":8},"end":{"line":19,"column":37}},"9":{"start":{"line":20,"column":8},"end":{"line":22,"column":10}},"10":{"start":{"line":28,"column":8},"end":{"line":28,"column":61}},"11":{"start":{"line":34,"column":8},"end":{"line":34,"column":56}},"12":{"start":{"line":40,"column":8},"end":{"line":40,"column":60}},"13":{"start":{"line":41,"column":8},"end":{"line":41,"column":68}},"14":{"start":{"line":42,"column":8},"end":{"line":42,"column":77}},"15":{"start":{"line":43,"column":8},"end":{"line":43,"column":82}},"16":{"start":{"line":44,"column":8},"end":{"line":44,"column":87}},"17":{"start":{"line":45,"column":8},"end":{"line":45,"column":75}},"18":{"start":{"line":46,"column":8},"end":{"line":46,"column":86}},"19":{"start":{"line":52,"column":8},"end":{"line":63,"column":10}},"20":{"start":{"line":69,"column":26},"end":{"line":69,"column":28}},"21":{"start":{"line":70,"column":24},"end":{"line":70,"column":45}},"22":{"start":{"line":71,"column":22},"end":{"line":71,"column":37}},"23":{"start":{"line":72,"column":21},"end":{"line":72,"column":42}},"24":{"start":{"line":74,"column":8},"end":{"line":74,"column":143}},"25":{"start":{"line":76,"column":8},"end":{"line":76,"column":73}},"26":{"start":{"line":78,"column":8},"end":{"line":82,"column":9}},"27":{"start":{"line":79,"column":12},"end":{"line":81,"column":197}},"28":{"start":{"line":84,"column":8},"end":{"line":88,"column":9}},"29":{"start":{"line":85,"column":12},"end":{"line":87,"column":202}},"30":{"start":{"line":89,"column":8},"end":{"line":89,"column":25}},"31":{"start":{"line":95,"column":24},"end":{"line":95,"column":26}},"32":{"start":{"line":96,"column":29},"end":{"line":96,"column":31}},"33":{"start":{"line":97,"column":24},"end":{"line":97,"column":52}},"34":{"start":{"line":98,"column":8},"end":{"line":100,"column":9}},"35":{"start":{"line":99,"column":12},"end":{"line":99,"column":32}},"36":{"start":{"line":101,"column":8},"end":{"line":105,"column":11}},"37":{"start":{"line":102,"column":28},"end":{"line":102,"column":133}},"38":{"start":{"line":102,"column":83},"end":{"line":102,"column":132}},"39":{"start":{"line":103,"column":12},"end":{"line":103,"column":50}},"40":{"start":{"line":104,"column":12},"end":{"line":104,"column":76}},"41":{"start":{"line":104,"column":51},"end":{"line":104,"column":74}},"42":{"start":{"line":106,"column":8},"end":{"line":106,"column":25}},"43":{"start":{"line":112,"column":8},"end":{"line":114,"column":9}},"44":{"start":{"line":113,"column":12},"end":{"line":113,"column":26}},"45":{"start":{"line":115,"column":8},"end":{"line":115,"column":37}},"46":{"start":{"line":121,"column":8},"end":{"line":121,"column":317}},"47":{"start":{"line":121,"column":69},"end":{"line":121,"column":100}},"48":{"start":{"line":121,"column":122},"end":{"line":121,"column":315}},"49":{"start":{"line":121,"column":170},"end":{"line":121,"column":314}},"50":{"start":{"line":121,"column":221},"end":{"line":121,"column":313}},"51":{"start":{"line":124,"column":8},"end":{"line":124,"column":378}},"52":{"start":{"line":124,"column":44},"end":{"line":124,"column":59}},"53":{"start":{"line":124,"column":72},"end":{"line":124,"column":145}},"54":{"start":{"line":124,"column":158},"end":{"line":124,"column":172}},"55":{"start":{"line":124,"column":185},"end":{"line":124,"column":271}},"56":{"start":{"line":124,"column":288},"end":{"line":124,"column":376}},"57":{"start":{"line":127,"column":0},"end":{"line":127,"column":24}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":18,"column":4},"end":{"line":18,"column":5}},"loc":{"start":{"line":18,"column":28},"end":{"line":23,"column":5}},"line":18},"1":{"name":"(anonymous_1)","decl":{"start":{"line":27,"column":4},"end":{"line":27,"column":5}},"loc":{"start":{"line":27,"column":15},"end":{"line":29,"column":5}},"line":27},"2":{"name":"(anonymous_2)","decl":{"start":{"line":33,"column":4},"end":{"line":33,"column":5}},"loc":{"start":{"line":33,"column":21},"end":{"line":35,"column":5}},"line":33},"3":{"name":"(anonymous_3)","decl":{"start":{"line":39,"column":4},"end":{"line":39,"column":5}},"loc":{"start":{"line":39,"column":15},"end":{"line":47,"column":5}},"line":39},"4":{"name":"(anonymous_4)","decl":{"start":{"line":51,"column":4},"end":{"line":51,"column":5}},"loc":{"start":{"line":51,"column":21},"end":{"line":64,"column":5}},"line":51},"5":{"name":"(anonymous_5)","decl":{"start":{"line":68,"column":4},"end":{"line":68,"column":5}},"loc":{"start":{"line":68,"column":36},"end":{"line":90,"column":5}},"line":68},"6":{"name":"(anonymous_6)","decl":{"start":{"line":94,"column":4},"end":{"line":94,"column":5}},"loc":{"start":{"line":94,"column":28},"end":{"line":107,"column":5}},"line":94},"7":{"name":"(anonymous_7)","decl":{"start":{"line":101,"column":24},"end":{"line":101,"column":25}},"loc":{"start":{"line":101,"column":35},"end":{"line":105,"column":9}},"line":101},"8":{"name":"(anonymous_8)","decl":{"start":{"line":102,"column":69},"end":{"line":102,"column":70}},"loc":{"start":{"line":102,"column":83},"end":{"line":102,"column":132}},"line":102},"9":{"name":"(anonymous_9)","decl":{"start":{"line":104,"column":41},"end":{"line":104,"column":42}},"loc":{"start":{"line":104,"column":51},"end":{"line":104,"column":74}},"line":104},"10":{"name":"(anonymous_10)","decl":{"start":{"line":111,"column":4},"end":{"line":111,"column":5}},"loc":{"start":{"line":111,"column":20},"end":{"line":116,"column":5}},"line":111},"11":{"name":"(anonymous_11)","decl":{"start":{"line":120,"column":4},"end":{"line":120,"column":5}},"loc":{"start":{"line":120,"column":14},"end":{"line":122,"column":5}},"line":120},"12":{"name":"(anonymous_12)","decl":{"start":{"line":121,"column":57},"end":{"line":121,"column":58}},"loc":{"start":{"line":121,"column":69},"end":{"line":121,"column":100}},"line":121},"13":{"name":"(anonymous_13)","decl":{"start":{"line":121,"column":110},"end":{"line":121,"column":111}},"loc":{"start":{"line":121,"column":122},"end":{"line":121,"column":315}},"line":121},"14":{"name":"(anonymous_14)","decl":{"start":{"line":121,"column":159},"end":{"line":121,"column":160}},"loc":{"start":{"line":121,"column":170},"end":{"line":121,"column":314}},"line":121},"15":{"name":"(anonymous_15)","decl":{"start":{"line":121,"column":207},"end":{"line":121,"column":208}},"loc":{"start":{"line":121,"column":221},"end":{"line":121,"column":313}},"line":121},"16":{"name":"(anonymous_16)","decl":{"start":{"line":123,"column":4},"end":{"line":123,"column":5}},"loc":{"start":{"line":123,"column":28},"end":{"line":125,"column":5}},"line":123},"17":{"name":"(anonymous_17)","decl":{"start":{"line":124,"column":38},"end":{"line":124,"column":39}},"loc":{"start":{"line":124,"column":44},"end":{"line":124,"column":59}},"line":124},"18":{"name":"(anonymous_18)","decl":{"start":{"line":124,"column":66},"end":{"line":124,"column":67}},"loc":{"start":{"line":124,"column":72},"end":{"line":124,"column":145}},"line":124},"19":{"name":"(anonymous_19)","decl":{"start":{"line":124,"column":152},"end":{"line":124,"column":153}},"loc":{"start":{"line":124,"column":158},"end":{"line":124,"column":172}},"line":124},"20":{"name":"(anonymous_20)","decl":{"start":{"line":124,"column":179},"end":{"line":124,"column":180}},"loc":{"start":{"line":124,"column":185},"end":{"line":124,"column":271}},"line":124},"21":{"name":"(anonymous_21)","decl":{"start":{"line":124,"column":279},"end":{"line":124,"column":280}},"loc":{"start":{"line":124,"column":288},"end":{"line":124,"column":376}},"line":124}},"branchMap":{"0":{"loc":{"start":{"line":54,"column":25},"end":{"line":54,"column":87}},"type":"cond-expr","locations":[{"start":{"line":54,"column":62},"end":{"line":54,"column":81}},{"start":{"line":54,"column":84},"end":{"line":54,"column":87}}],"line":54},"1":{"loc":{"start":{"line":54,"column":25},"end":{"line":54,"column":59}},"type":"binary-expr","locations":[{"start":{"line":54,"column":25},"end":{"line":54,"column":36}},{"start":{"line":54,"column":40},"end":{"line":54,"column":59}}],"line":54},"2":{"loc":{"start":{"line":55,"column":25},"end":{"line":55,"column":85}},"type":"cond-expr","locations":[{"start":{"line":55,"column":62},"end":{"line":55,"column":81}},{"start":{"line":55,"column":84},"end":{"line":55,"column":85}}],"line":55},"3":{"loc":{"start":{"line":55,"column":25},"end":{"line":55,"column":59}},"type":"binary-expr","locations":[{"start":{"line":55,"column":25},"end":{"line":55,"column":36}},{"start":{"line":55,"column":40},"end":{"line":55,"column":59}}],"line":55},"4":{"loc":{"start":{"line":56,"column":23},"end":{"line":56,"column":82}},"type":"cond-expr","locations":[{"start":{"line":56,"column":58},"end":{"line":56,"column":75}},{"start":{"line":56,"column":78},"end":{"line":56,"column":82}}],"line":56},"5":{"loc":{"start":{"line":56,"column":23},"end":{"line":56,"column":55}},"type":"binary-expr","locations":[{"start":{"line":56,"column":23},"end":{"line":56,"column":34}},{"start":{"line":56,"column":38},"end":{"line":56,"column":55}}],"line":56},"6":{"loc":{"start":{"line":59,"column":25},"end":{"line":59,"column":90}},"type":"cond-expr","locations":[{"start":{"line":59,"column":64},"end":{"line":59,"column":84}},{"start":{"line":59,"column":87},"end":{"line":59,"column":90}}],"line":59},"7":{"loc":{"start":{"line":59,"column":25},"end":{"line":59,"column":61}},"type":"binary-expr","locations":[{"start":{"line":59,"column":25},"end":{"line":59,"column":37}},{"start":{"line":59,"column":41},"end":{"line":59,"column":61}}],"line":59},"8":{"loc":{"start":{"line":60,"column":25},"end":{"line":60,"column":88}},"type":"cond-expr","locations":[{"start":{"line":60,"column":64},"end":{"line":60,"column":84}},{"start":{"line":60,"column":87},"end":{"line":60,"column":88}}],"line":60},"9":{"loc":{"start":{"line":60,"column":25},"end":{"line":60,"column":61}},"type":"binary-expr","locations":[{"start":{"line":60,"column":25},"end":{"line":60,"column":37}},{"start":{"line":60,"column":41},"end":{"line":60,"column":61}}],"line":60},"10":{"loc":{"start":{"line":61,"column":23},"end":{"line":61,"column":85}},"type":"cond-expr","locations":[{"start":{"line":61,"column":60},"end":{"line":61,"column":78}},{"start":{"line":61,"column":81},"end":{"line":61,"column":85}}],"line":61},"11":{"loc":{"start":{"line":61,"column":23},"end":{"line":61,"column":57}},"type":"binary-expr","locations":[{"start":{"line":61,"column":23},"end":{"line":61,"column":35}},{"start":{"line":61,"column":39},"end":{"line":61,"column":57}}],"line":61},"12":{"loc":{"start":{"line":74,"column":107},"end":{"line":74,"column":139}},"type":"cond-expr","locations":[{"start":{"line":74,"column":116},"end":{"line":74,"column":133}},{"start":{"line":74,"column":137},"end":{"line":74,"column":139}}],"line":74},"13":{"loc":{"start":{"line":78,"column":8},"end":{"line":82,"column":9}},"type":"if","locations":[{"start":{"line":78,"column":8},"end":{"line":82,"column":9}},{"start":{"line":78,"column":8},"end":{"line":82,"column":9}}],"line":78},"14":{"loc":{"start":{"line":84,"column":8},"end":{"line":88,"column":9}},"type":"if","locations":[{"start":{"line":84,"column":8},"end":{"line":88,"column":9}},{"start":{"line":84,"column":8},"end":{"line":88,"column":9}}],"line":84},"15":{"loc":{"start":{"line":98,"column":8},"end":{"line":100,"column":9}},"type":"if","locations":[{"start":{"line":98,"column":8},"end":{"line":100,"column":9}},{"start":{"line":98,"column":8},"end":{"line":100,"column":9}}],"line":98},"16":{"loc":{"start":{"line":112,"column":8},"end":{"line":114,"column":9}},"type":"if","locations":[{"start":{"line":112,"column":8},"end":{"line":114,"column":9}},{"start":{"line":112,"column":8},"end":{"line":114,"column":9}}],"line":112},"17":{"loc":{"start":{"line":112,"column":12},"end":{"line":112,"column":46}},"type":"binary-expr","locations":[{"start":{"line":112,"column":12},"end":{"line":112,"column":16}},{"start":{"line":112,"column":20},"end":{"line":112,"column":46}}],"line":112},"18":{"loc":{"start":{"line":115,"column":16},"end":{"line":115,"column":26}},"type":"binary-expr","locations":[{"start":{"line":115,"column":16},"end":{"line":115,"column":20}},{"start":{"line":115,"column":24},"end":{"line":115,"column":26}}],"line":115},"19":{"loc":{"start":{"line":121,"column":69},"end":{"line":121,"column":100}},"type":"binary-expr","locations":[{"start":{"line":121,"column":69},"end":{"line":121,"column":82}},{"start":{"line":121,"column":86},"end":{"line":121,"column":100}}],"line":121}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":2,"9":2,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":1,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":5,"44":1,"45":4,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":1},"f":{"0":2,"1":0,"2":0,"3":0,"4":1,"5":0,"6":0,"7":0,"8":0,"9":0,"10":5,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0},"b":{"0":[1,0],"1":[1,1],"2":[0,1],"3":[1,1],"4":[1,0],"5":[1,1],"6":[0,1],"7":[1,1],"8":[1,0],"9":[1,1],"10":[0,1],"11":[1,1],"12":[0,0],"13":[0,0],"14":[0,0],"15":[0,0],"16":[1,4],"17":[5,4],"18":[4,1],"19":[0,0]},"inputSourceMap":{"version":3,"file":"plugin.js","sourceRoot":"","sources":["plugin.ts"],"names":[],"mappings":";;AAAA,iCAAgC;AAChC,4BAA2B;AAC3B,6BAA4B;AAE5B,yCAAiC;AACjC,qCAA6B;AA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,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CACtD,CAAC,OAAO,CACP,CAAC,MAAgB,KAAK,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CACxD,CAAC,KAAa,KAAK,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CACrD,CAAC,QAAgB,KAAK,CAAC,CAAC,KAAK,CAC3B,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,8BAA8B,CAAC,SAAS,EACzE,QAAQ,CACT,CACF,CACF,CACF,CAAA;IACH,CAAC;IAEO,qBAAqB;QAC3B,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAC3B,MAAM,IAAI,CAAC,QAAQ,EAAE,CACtB,CAAC,IAAI,CACJ,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,mCAAmC,CAAC,CAAC,CAChF,CAAC,IAAI,CACJ,MAAM,IAAI,CAAC,OAAO,EAAE,CACrB,CAAC,IAAI,CACJ,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,gDAAgD,CAAC,CAAC,CAC7F,CAAC,KAAK,CACL,CAAC,GAAU,KAAK,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,qCAAqC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CACzG,CAAA;IACH,CAAC;CACF;AAED,MAAM,CAAC,OAAO,GAAG,MAAM,CAAA","sourcesContent":["import * as assert from 'assert'\nimport * as _ from 'lodash'\nimport * as util from 'util'\n\nimport Policy from './aws/policy'\nimport Role from './aws/role'\nimport Target from './aws/target'\n\nconst text = {\n INVALID_CONFIGURATION: 'Invalid serverless configuration',\n NO_AUTOSCALING_CONFIG: 'Not Auto Scaling configuration found',\n ONLY_AWS_SUPPORT: 'Only supported for AWS provicer'\n}\n\nclass Plugin {\n public hooks: {}\n\n /**\n * Constructur\n */\n constructor (private serverless: Serverless) {\n this.hooks = {\n 'deploy:compileEvents': this.beforeDeployResources.bind(this)\n }\n }\n\n /**\n * Get the current stage name\n */\n private getStage(): string {\n return this.serverless.getProvider('aws').getStage()\n }\n\n /**\n * Get the current service name\n */\n private getServiceName(): string {\n return this.serverless.service.getServiceName()\n }\n\n /**\n * Validate the request and check if configuration is available\n */\n private validate(): void {\n assert(this.serverless, text.INVALID_CONFIGURATION)\n assert(this.serverless.service, text.INVALID_CONFIGURATION)\n assert(this.serverless.service.provider, text.INVALID_CONFIGURATION)\n assert(this.serverless.service.provider.name, text.INVALID_CONFIGURATION)\n assert(this.serverless.service.provider.name === 'aws', text.ONLY_AWS_SUPPORT)\n\n assert(this.serverless.service.custom, text.NO_AUTOSCALING_CONFIG)\n assert(this.serverless.service.custom.capacities, text.NO_AUTOSCALING_CONFIG)\n }\n\n /**\n * Parse configuration and fill up with default values when needed\n */\n private defaults(config: Capacity): { read: CapacityConfiguration, write: CapacityConfiguration } {\n return {\n read: {\n maximum: config.read && config.read.maximum ? config.read.maximum : 200,\n minimum: config.read && config.read.minimum ? config.read.minimum : 5,\n usage: config.read && config.read.usage ? config.read.usage : 0.75\n },\n write: {\n maximum: config.write && config.write.maximum ? config.write.maximum : 200,\n minimum: config.write && config.write.minimum ? config.write.minimum : 5,\n usage: config.write && config.write.usage ? config.write.usage : 0.75\n }\n }\n }\n\n /**\n * Create CloudFormation resources for table (and optional index)\n */\n private resources(table: string, index: string, config: Capacity): any[] {\n const resources = []\n const service = this.getServiceName()\n const stage = this.getStage()\n const data = this.defaults(config)\n\n // Start processing configuration\n this.serverless.cli.log(\n util.format(' - Building configuration for resource \"table/%s%s\"', table, (index ? ('/index/' + index) : ''))\n )\n\n // Add role to manage Auto Scaling policies\n resources.push(new Role(service, table, index, stage))\n\n // Only add Auto Scaling for read capacity if configuration set is available\n if (config.read) {\n resources.push(\n // ScaleIn/ScaleOut values are fix to 60% usage\n new Policy(service, table, data.read.usage * 100, true, 60, 60, index, stage),\n new Target(service, table, data.read.minimum, data.read.maximum, true, index, stage)\n )\n }\n\n // Only add Auto Scaling for write capacity if configuration set is available\n if (config.write) {\n resources.push(\n // ScaleIn/ScaleOut values are fix to 60% usage\n new Policy(service, table, data.write.usage * 100, false, 60, 60, index, stage),\n new Target(service, table, data.write.minimum, data.write.maximum, false, index, stage)\n )\n }\n\n return resources\n }\n\n /**\n * Generate CloudFormation resources for DynamoDB table and indexes\n */\n private generate(table: string, config: Capacity) {\n let resources: any[] = []\n let lastRessources: any[] = []\n\n const indexes = this.normalize(config.index)\n if (!config.indexOnly) {\n indexes.unshift('') // Horrible solution\n }\n\n indexes.forEach(\n (index: string) => {\n const current = this.resources(table, index, config).map(\n (resource: any) => resource.setDependencies(lastRessources).toJSON()\n )\n\n resources = resources.concat(current)\n lastRessources = current.map((item: any) => Object.keys(item).pop())\n }\n )\n\n return resources\n }\n\n /**\n * Check if parameter is defined and return as array if only a string is provided\n */\n private normalize(data: string|string[]): string[] {\n if (data && data.constructor !== Array) {\n return [ data as string ]\n }\n\n return (data as string[] || []).slice(0)\n }\n\n /**\n * Process the provided configuration\n */\n private process() {\n this.serverless.service.custom.capacities.filter(\n (config: Capacity) => !!config.read || !!config.write\n ).forEach(\n (config: Capacity) => this.normalize(config.table).forEach(\n (table: string) => this.generate(table, config).forEach(\n (resource: string) => _.merge(\n this.serverless.service.provider.compiledCloudFormationTemplate.Resources,\n resource\n )\n )\n )\n )\n }\n\n private beforeDeployResources(): Promise<any> {\n return Promise.resolve().then(\n () => this.validate()\n ).then(\n () => this.serverless.cli.log(util.format('Configure DynamoDB Auto Scaling …'))\n ).then(\n () => this.process()\n ).then(\n () => this.serverless.cli.log(util.format('Added DynamoDB Auto Scaling to CloudFormation!'))\n ).catch(\n (err: Error) => this.serverless.cli.log(util.format('Skipping DynamoDB Auto Scaling: %s!', err.message))\n )\n }\n}\n\nmodule.exports = Plugin\n"]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"7170c1b9e29b6f8fd8be8ce3e31aa9193fa98b6d"}
,"/home/ubuntu/serverless-dynamodb-autoscaling/src/aws/names.ts": {"path":"/home/ubuntu/serverless-dynamodb-autoscaling/src/aws/names.ts","statementMap":{"0":{"start":{"line":2,"column":0},"end":{"line":2,"column":62}},"1":{"start":{"line":3,"column":12},"end":{"line":3,"column":26}},"2":{"start":{"line":4,"column":13},"end":{"line":4,"column":28}},"3":{"start":{"line":6,"column":4},"end":{"line":6,"column":56}},"4":{"start":{"line":8,"column":0},"end":{"line":8,"column":22}},"5":{"start":{"line":10,"column":4},"end":{"line":10,"column":73}},"6":{"start":{"line":12,"column":0},"end":{"line":12,"column":28}},"7":{"start":{"line":14,"column":4},"end":{"line":14,"column":130}},"8":{"start":{"line":16,"column":0},"end":{"line":16,"column":34}},"9":{"start":{"line":18,"column":4},"end":{"line":18,"column":108}},"10":{"start":{"line":20,"column":0},"end":{"line":20,"column":32}},"11":{"start":{"line":22,"column":4},"end":{"line":22,"column":106}},"12":{"start":{"line":24,"column":0},"end":{"line":24,"column":30}},"13":{"start":{"line":26,"column":4},"end":{"line":26,"column":129}},"14":{"start":{"line":28,"column":0},"end":{"line":28,"column":24}},"15":{"start":{"line":30,"column":4},"end":{"line":30,"column":88}},"16":{"start":{"line":32,"column":0},"end":{"line":32,"column":24}},"17":{"start":{"line":34,"column":4},"end":{"line":34,"column":106}},"18":{"start":{"line":36,"column":0},"end":{"line":36,"column":20}}},"fnMap":{"0":{"name":"clean","decl":{"start":{"line":5,"column":9},"end":{"line":5,"column":14}},"loc":{"start":{"line":5,"column":22},"end":{"line":7,"column":1}},"line":5},"1":{"name":"truncate","decl":{"start":{"line":9,"column":9},"end":{"line":9,"column":17}},"loc":{"start":{"line":9,"column":25},"end":{"line":11,"column":1}},"line":9},"2":{"name":"policyScale","decl":{"start":{"line":13,"column":9},"end":{"line":13,"column":20}},"loc":{"start":{"line":13,"column":57},"end":{"line":15,"column":1}},"line":13},"3":{"name":"policyRole","decl":{"start":{"line":17,"column":9},"end":{"line":17,"column":19}},"loc":{"start":{"line":17,"column":50},"end":{"line":19,"column":1}},"line":17},"4":{"name":"dimension","decl":{"start":{"line":21,"column":9},"end":{"line":21,"column":18}},"loc":{"start":{"line":21,"column":32},"end":{"line":23,"column":1}},"line":21},"5":{"name":"target","decl":{"start":{"line":25,"column":9},"end":{"line":25,"column":15}},"loc":{"start":{"line":25,"column":52},"end":{"line":27,"column":1}},"line":25},"6":{"name":"metric","decl":{"start":{"line":29,"column":9},"end":{"line":29,"column":15}},"loc":{"start":{"line":29,"column":22},"end":{"line":31,"column":1}},"line":29},"7":{"name":"role","decl":{"start":{"line":33,"column":9},"end":{"line":33,"column":13}},"loc":{"start":{"line":33,"column":44},"end":{"line":35,"column":1}},"line":33}},"branchMap":{"0":{"loc":{"start":{"line":10,"column":11},"end":{"line":10,"column":72}},"type":"cond-expr","locations":[{"start":{"line":10,"column":32},"end":{"line":10,"column":37}},{"start":{"line":10,"column":40},"end":{"line":10,"column":72}}],"line":10},"1":{"loc":{"start":{"line":14,"column":71},"end":{"line":14,"column":94}},"type":"cond-expr","locations":[{"start":{"line":14,"column":78},"end":{"line":14,"column":84}},{"start":{"line":14,"column":87},"end":{"line":14,"column":94}}],"line":14},"2":{"loc":{"start":{"line":14,"column":103},"end":{"line":14,"column":114}},"type":"binary-expr","locations":[{"start":{"line":14,"column":103},"end":{"line":14,"column":108}},{"start":{"line":14,"column":112},"end":{"line":14,"column":114}}],"line":14},"3":{"loc":{"start":{"line":14,"column":116},"end":{"line":14,"column":127}},"type":"binary-expr","locations":[{"start":{"line":14,"column":116},"end":{"line":14,"column":121}},{"start":{"line":14,"column":125},"end":{"line":14,"column":127}}],"line":14},"4":{"loc":{"start":{"line":18,"column":81},"end":{"line":18,"column":92}},"type":"binary-expr","locations":[{"start":{"line":18,"column":81},"end":{"line":18,"column":86}},{"start":{"line":18,"column":90},"end":{"line":18,"column":92}}],"line":18},"5":{"loc":{"start":{"line":18,"column":94},"end":{"line":18,"column":105}},"type":"binary-expr","locations":[{"start":{"line":18,"column":94},"end":{"line":18,"column":99}},{"start":{"line":18,"column":103},"end":{"line":18,"column":105}}],"line":18},"6":{"loc":{"start":{"line":22,"column":54},"end":{"line":22,"column":79}},"type":"cond-expr","locations":[{"start":{"line":22,"column":62},"end":{"line":22,"column":69}},{"start":{"line":22,"column":72},"end":{"line":22,"column":79}}],"line":22},"7":{"loc":{"start":{"line":22,"column":81},"end":{"line":22,"column":104}},"type":"cond-expr","locations":[{"start":{"line":22,"column":88},"end":{"line":22,"column":94}},{"start":{"line":22,"column":97},"end":{"line":22,"column":104}}],"line":22},"8":{"loc":{"start":{"line":26,"column":70},"end":{"line":26,"column":93}},"type":"cond-expr","locations":[{"start":{"line":26,"column":77},"end":{"line":26,"column":83}},{"start":{"line":26,"column":86},"end":{"line":26,"column":93}}],"line":26},"9":{"loc":{"start":{"line":26,"column":102},"end":{"line":26,"column":113}},"type":"binary-expr","locations":[{"start":{"line":26,"column":102},"end":{"line":26,"column":107}},{"start":{"line":26,"column":111},"end":{"line":26,"column":113}}],"line":26},"10":{"loc":{"start":{"line":26,"column":115},"end":{"line":26,"column":126}},"type":"binary-expr","locations":[{"start":{"line":26,"column":115},"end":{"line":26,"column":120}},{"start":{"line":26,"column":124},"end":{"line":26,"column":126}}],"line":26},"11":{"loc":{"start":{"line":30,"column":62},"end":{"line":30,"column":85}},"type":"cond-expr","locations":[{"start":{"line":30,"column":69},"end":{"line":30,"column":75}},{"start":{"line":30,"column":78},"end":{"line":30,"column":85}}],"line":30},"12":{"loc":{"start":{"line":34,"column":79},"end":{"line":34,"column":90}},"type":"binary-expr","locations":[{"start":{"line":34,"column":79},"end":{"line":34,"column":84}},{"start":{"line":34,"column":88},"end":{"line":34,"column":90}}],"line":34},"13":{"loc":{"start":{"line":34,"column":92},"end":{"line":34,"column":103}},"type":"binary-expr","locations":[{"start":{"line":34,"column":92},"end":{"line":34,"column":97}},{"start":{"line":34,"column":101},"end":{"line":34,"column":103}}],"line":34}},"s":{"0":5,"1":5,"2":5,"3":46,"4":5,"5":46,"6":5,"7":10,"8":5,"9":3,"10":5,"11":6,"12":5,"13":12,"14":5,"15":6,"16":5,"17":10,"18":5},"f":{"0":46,"1":46,"2":10,"3":3,"4":6,"5":12,"6":6,"7":10},"b":{"0":[44,2],"1":[5,5],"2":[10,10],"3":[10,10],"4":[3,3],"5":[3,3],"6":[0,6],"7":[3,3],"8":[6,6],"9":[12,12],"10":[12,12],"11":[3,3],"12":[10,9],"13":[10,9]},"inputSourceMap":{"version":3,"file":"names.js","sourceRoot":"","sources":["names.ts"],"names":[],"mappings":";;AAAA,2BAA0B;AAC1B,6BAA4B;AAE5B,eAAsB,KAAa;IACjC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,CAAA;AACrD,CAAC;AAFD,sBAEC;AAED,kBAAyB,KAAa;IACpC,MAAM,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,GAAG,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAA;AACtE,CAAC;AAFD,4BAEC;AAED,qBAA4B,OAAe,EAAE,KAAa,EAAE,IAAa,EAAE,KAAc,EAAE,KAAc;IACvG,MAAM,CAAC,KAAK,CACV,IAAI,CAAC,MAAM,CACT,+BAA+B,EAC/B,OAAO,EACP,IAAI,GAAG,MAAM,GAAG,OAAO,EACvB,KAAK,EACL,KAAK,IAAI,EAAE,EACX,KAAK,IAAI,EAAE,CACZ,CACF,CAAA;AACH,CAAC;AAXD,kCAWC;AAED,oBAA2B,OAAe,EAAE,KAAa,EAAE,KAAc,EAAE,KAAc;IACvF,MAAM,CAAC,KAAK,CACV,IAAI,CAAC,MAAM,CACT,kCAAkC,EAClC,OAAO,EACP,KAAK,EACL,KAAK,IAAI,EAAE,EACX,KAAK,IAAI,EAAE,CACZ,CACF,CAAA;AACH,CAAC;AAVD,gCAUC;AAED,mBAA0B,IAAa,EAAE,KAAc;IACrD,MAAM,CAAC,IAAI,CAAC,MAAM,CAChB,6BAA6B,EAC7B,KAAK,GAAG,OAAO,GAAG,OAAO,EACzB,IAAI,GAAG,MAAM,GAAG,OAAO,CACxB,CAAA;AACH,CAAC;AAND,8BAMC;AAED,gBAAuB,OAAe,EAAE,KAAa,EAAE,IAAa,EAAE,KAAc,EAAE,KAAc;IAClG,MAAM,CAAC,KAAK,CACV,IAAI,CAAC,MAAM,CACT,8BAA8B,EAC9B,OAAO,EACP,IAAI,GAAG,MAAM,GAAG,OAAO,EACvB,KAAK,EACL,KAAK,IAAI,EAAE,EACX,KAAK,IAAI,EAAE,CACZ,CACF,CAAA;AACH,CAAC;AAXD,wBAWC;AAED,gBAAuB,IAAa;IAClC,MAAM,CAAC,KAAK,CACV,IAAI,CAAC,MAAM,CACT,+BAA+B,EAC/B,IAAI,GAAG,MAAM,GAAG,OAAO,CACxB,CACF,CAAA;AACH,CAAC;AAPD,wBAOC;AAED,cAAqB,OAAe,EAAE,KAAa,EAAE,KAAc,EAAE,KAAc;IACjF,MAAM,CAAC,KAAK,CACV,IAAI,CAAC,MAAM,CACT,gCAAgC,EAChC,OAAO,EACP,KAAK,EACL,KAAK,IAAI,EAAE,EACX,KAAK,IAAI,EAAE,CACZ,CACF,CAAA;AACH,CAAC;AAVD,oBAUC","sourcesContent":["import * as md5 from 'md5'\nimport * as util from 'util'\n\nexport function clean(input: string): string {\n return truncate(input.replace(/[^a-z0-9+]+/gi, ''))\n}\n\nexport function truncate(input: string): string {\n return input.length <= 64 ? input : input.substr(0, 32) + md5(input)\n}\n\nexport function policyScale(service: string, table: string, read: boolean, index?: string, stage?: string): string {\n return clean(\n util.format(\n '%sTable%sScalingPolicy-%s%s%s',\n service,\n read ? 'Read' : 'Write',\n table,\n index || '',\n stage || ''\n )\n )\n}\n\nexport function policyRole(service: string, table: string, index?: string, stage?: string): string {\n return clean(\n util.format(\n '%sDynamoDBAutoscalePolicy-%s%s%s',\n service,\n table,\n index || '',\n stage || ''\n )\n )\n}\n\nexport function dimension(read: boolean, index: boolean): string {\n return util.format(\n 'dynamodb:%s:%sCapacityUnits',\n index ? 'index' : 'table',\n read ? 'Read' : 'Write'\n )\n}\n\nexport function target(service: string, table: string, read: boolean, index?: string, stage?: string): string {\n return clean(\n util.format(\n '%sAutoScalingTarget%s-%s%s%s',\n service,\n read ? 'Read' : 'Write',\n table,\n index || '',\n stage || ''\n )\n )\n}\n\nexport function metric(read: boolean): string {\n return clean(\n util.format(\n 'DynamoDB%sCapacityUtilization',\n read ? 'Read' : 'Write'\n )\n )\n}\n\nexport function role(service: string, table: string, index?: string, stage?: string): string {\n return clean(\n util.format(\n '%sDynamoDBAutoscaleRole-%s%s%s',\n service,\n table,\n index || '',\n stage || ''\n )\n )\n}\n"]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"0d93213574d24db41d9121240e66c091e4f986ca"}

@@ -3,0 +3,0 @@ ,"/home/ubuntu/serverless-dynamodb-autoscaling/src/aws/policy.ts": {"path":"/home/ubuntu/serverless-dynamodb-autoscaling/src/aws/policy.ts","statementMap":{"0":{"start":{"line":2,"column":0},"end":{"line":2,"column":62}},"1":{"start":{"line":3,"column":14},"end":{"line":3,"column":32}},"2":{"start":{"line":6,"column":8},"end":{"line":6,"column":31}},"3":{"start":{"line":7,"column":8},"end":{"line":7,"column":27}},"4":{"start":{"line":8,"column":8},"end":{"line":8,"column":27}},"5":{"start":{"line":9,"column":8},"end":{"line":9,"column":25}},"6":{"start":{"line":10,"column":8},"end":{"line":10,"column":31}},"7":{"start":{"line":11,"column":8},"end":{"line":11,"column":33}},"8":{"start":{"line":12,"column":8},"end":{"line":12,"column":27}},"9":{"start":{"line":13,"column":8},"end":{"line":13,"column":27}},"10":{"start":{"line":14,"column":8},"end":{"line":14,"column":31}},"11":{"start":{"line":15,"column":8},"end":{"line":15,"column":65}},"12":{"start":{"line":18,"column":8},"end":{"line":18,"column":33}},"13":{"start":{"line":19,"column":8},"end":{"line":19,"column":20}},"14":{"start":{"line":22,"column":27},"end":{"line":22,"column":50}},"15":{"start":{"line":23,"column":32},"end":{"line":23,"column":110}},"16":{"start":{"line":24,"column":27},"end":{"line":24,"column":100}},"17":{"start":{"line":25,"column":29},"end":{"line":25,"column":79}},"18":{"start":{"line":26,"column":8},"end":{"line":44,"column":10}},"19":{"start":{"line":47,"column":0},"end":{"line":47,"column":25}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":5,"column":4},"end":{"line":5,"column":5}},"loc":{"start":{"line":5,"column":78},"end":{"line":16,"column":5}},"line":5},"1":{"name":"(anonymous_1)","decl":{"start":{"line":17,"column":4},"end":{"line":17,"column":5}},"loc":{"start":{"line":17,"column":26},"end":{"line":20,"column":5}},"line":17},"2":{"name":"(anonymous_2)","decl":{"start":{"line":21,"column":4},"end":{"line":21,"column":5}},"loc":{"start":{"line":21,"column":13},"end":{"line":45,"column":5}},"line":21}},"branchMap":{},"s":{"0":2,"1":2,"2":2,"3":2,"4":2,"5":2,"6":2,"7":2,"8":2,"9":2,"10":2,"11":2,"12":0,"13":0,"14":2,"15":2,"16":2,"17":2,"18":2,"19":2},"f":{"0":2,"1":0,"2":2},"b":{},"inputSourceMap":{"version":3,"file":"policy.js","sourceRoot":"","sources":["policy.ts"],"names":[],"mappings":";;AAAA,iCAAgC;AAEhC;IAIE,YACU,OAAe,EACf,KAAa,EACb,KAAa,EACb,IAAa,EACb,OAAe,EACf,QAAgB,EAChB,KAAa,EACb,KAAa;QAPb,YAAO,GAAP,OAAO,CAAQ;QACf,UAAK,GAAL,KAAK,CAAQ;QACb,UAAK,GAAL,KAAK,CAAQ;QACb,SAAI,GAAJ,IAAI,CAAS;QACb,YAAO,GAA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,KAAK;qBACxB;iBACF;gBACD,IAAI,EAAE,IAAI,CAAC,IAAI;aAChB;SACF,CAAA;IACH,CAAC;CACF;AAhDD,yBAgDC","sourcesContent":["import * as names from './names'\n\nexport default class Policy {\n private dependencies: string[] = []\n private type: string = 'AWS::ApplicationAutoScaling::ScalingPolicy'\n\n constructor (\n private service: string,\n private table: string,\n private value: number,\n private read: boolean,\n private scaleIn: number,\n private scaleOut: number,\n private index: string,\n private stage: string\n ) { }\n\n public setDependencies(list: string[]): Policy {\n this.dependencies = list\n\n return this\n }\n\n public toJSON(): any {\n const nameMetric = names.metric(this.read)\n const nameScalePolicy = names.policyScale(this.service, this.table, this.read, this.index, this.stage)\n const nameTarget = names.target(this.service, this.table, this.read, this.index, this.stage)\n\n const dependencies = [this.table, nameTarget ].concat(this.dependencies)\n\n return {\n [nameScalePolicy]: {\n DependsOn: dependencies,\n Properties: {\n PolicyName: nameScalePolicy,\n PolicyType: 'TargetTrackingScaling',\n ScalingTargetId: { Ref: nameTarget },\n TargetTrackingScalingPolicyConfiguration: {\n PredefinedMetricSpecification: {\n PredefinedMetricType: nameMetric\n },\n ScaleInCooldown: this.scaleIn,\n ScaleOutCooldown: this.scaleOut,\n TargetValue: this.value\n }\n },\n Type: this.type\n }\n }\n }\n}\n"]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"334829cadced5fc00817e52fc02bf8cb14aa93aa"}

@@ -81,3 +81,3 @@ "use strict";

// ScaleIn/ScaleOut values are fix to 60% usage
new policy_1.default(service, table, data.read.usage, true, 60, 60, index, stage), new target_1.default(service, table, data.read.minimum, data.read.maximum, true, index, stage));
new policy_1.default(service, table, data.read.usage * 100, true, 60, 60, index, stage), new target_1.default(service, table, data.read.minimum, data.read.maximum, true, index, stage));
}

@@ -88,3 +88,3 @@ // Only add Auto Scaling for write capacity if configuration set is available

// ScaleIn/ScaleOut values are fix to 60% usage
new policy_1.default(service, table, data.write.usage, false, 60, 60, index, stage), new target_1.default(service, table, data.write.minimum, data.write.maximum, false, index, stage));
new policy_1.default(service, table, data.write.usage * 100, false, 60, 60, index, stage), new target_1.default(service, table, data.write.minimum, data.write.maximum, false, index, stage));
}

@@ -91,0 +91,0 @@ return resources;

{
"name": "serverless-dynamodb-autoscaling",
"description": "Serverless Plugin for Amazon DynamoDB Auto Scaling.",
"version": "0.5.0",
"version": "0.5.1",
"main": "dist/plugin.js",

@@ -6,0 +6,0 @@ "scripts": {

@@ -94,3 +94,3 @@ import * as assert from 'assert'

// ScaleIn/ScaleOut values are fix to 60% usage
new Policy(service, table, data.read.usage, true, 60, 60, index, stage),
new Policy(service, table, data.read.usage * 100, true, 60, 60, index, stage),
new Target(service, table, data.read.minimum, data.read.maximum, true, index, stage)

@@ -104,3 +104,3 @@ )

// ScaleIn/ScaleOut values are fix to 60% usage
new Policy(service, table, data.write.usage, false, 60, 60, index, stage),
new Policy(service, table, data.write.usage * 100, false, 60, 60, index, stage),
new Target(service, table, data.write.minimum, data.write.maximum, false, index, stage)

@@ -107,0 +107,0 @@ )

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet