serverless-dynamodb-autoscaling
Advanced tools
Comparing version
@@ -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":17,"column":1}},"8":{"start":{"line":23,"column":8},"end":{"line":23,"column":37}},"9":{"start":{"line":24,"column":8},"end":{"line":26,"column":10}},"10":{"start":{"line":32,"column":8},"end":{"line":32,"column":61}},"11":{"start":{"line":38,"column":8},"end":{"line":38,"column":56}},"12":{"start":{"line":44,"column":8},"end":{"line":44,"column":62}},"13":{"start":{"line":50,"column":8},"end":{"line":50,"column":60}},"14":{"start":{"line":51,"column":8},"end":{"line":51,"column":68}},"15":{"start":{"line":52,"column":8},"end":{"line":52,"column":77}},"16":{"start":{"line":53,"column":8},"end":{"line":53,"column":82}},"17":{"start":{"line":54,"column":8},"end":{"line":54,"column":87}},"18":{"start":{"line":55,"column":8},"end":{"line":55,"column":75}},"19":{"start":{"line":56,"column":8},"end":{"line":56,"column":86}},"20":{"start":{"line":62,"column":8},"end":{"line":73,"column":10}},"21":{"start":{"line":79,"column":21},"end":{"line":79,"column":42}},"22":{"start":{"line":80,"column":24},"end":{"line":86,"column":9}},"23":{"start":{"line":88,"column":8},"end":{"line":88,"column":107}},"24":{"start":{"line":90,"column":26},"end":{"line":92,"column":9}},"25":{"start":{"line":94,"column":8},"end":{"line":96,"column":9}},"26":{"start":{"line":95,"column":12},"end":{"line":95,"column":76}},"27":{"start":{"line":98,"column":8},"end":{"line":100,"column":9}},"28":{"start":{"line":99,"column":12},"end":{"line":99,"column":77}},"29":{"start":{"line":101,"column":8},"end":{"line":101,"column":25}},"30":{"start":{"line":104,"column":8},"end":{"line":107,"column":10}},"31":{"start":{"line":113,"column":24},"end":{"line":113,"column":26}},"32":{"start":{"line":114,"column":29},"end":{"line":114,"column":31}},"33":{"start":{"line":115,"column":24},"end":{"line":115,"column":52}},"34":{"start":{"line":116,"column":8},"end":{"line":118,"column":9}},"35":{"start":{"line":117,"column":12},"end":{"line":117,"column":32}},"36":{"start":{"line":119,"column":8},"end":{"line":123,"column":11}},"37":{"start":{"line":120,"column":28},"end":{"line":120,"column":133}},"38":{"start":{"line":120,"column":83},"end":{"line":120,"column":132}},"39":{"start":{"line":121,"column":12},"end":{"line":121,"column":50}},"40":{"start":{"line":122,"column":12},"end":{"line":122,"column":76}},"41":{"start":{"line":122,"column":51},"end":{"line":122,"column":74}},"42":{"start":{"line":124,"column":8},"end":{"line":124,"column":25}},"43":{"start":{"line":130,"column":8},"end":{"line":132,"column":9}},"44":{"start":{"line":131,"column":12},"end":{"line":131,"column":26}},"45":{"start":{"line":133,"column":8},"end":{"line":133,"column":37}},"46":{"start":{"line":139,"column":8},"end":{"line":139,"column":317}},"47":{"start":{"line":139,"column":69},"end":{"line":139,"column":100}},"48":{"start":{"line":139,"column":122},"end":{"line":139,"column":315}},"49":{"start":{"line":139,"column":170},"end":{"line":139,"column":314}},"50":{"start":{"line":139,"column":221},"end":{"line":139,"column":313}},"51":{"start":{"line":142,"column":8},"end":{"line":142,"column":298}},"52":{"start":{"line":142,"column":44},"end":{"line":142,"column":59}},"53":{"start":{"line":142,"column":72},"end":{"line":142,"column":124}},"54":{"start":{"line":142,"column":137},"end":{"line":142,"column":151}},"55":{"start":{"line":142,"column":164},"end":{"line":142,"column":215}},"56":{"start":{"line":142,"column":232},"end":{"line":142,"column":296}},"57":{"start":{"line":145,"column":0},"end":{"line":145,"column":24}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":22,"column":4},"end":{"line":22,"column":5}},"loc":{"start":{"line":22,"column":28},"end":{"line":27,"column":5}},"line":22},"1":{"name":"(anonymous_1)","decl":{"start":{"line":31,"column":4},"end":{"line":31,"column":5}},"loc":{"start":{"line":31,"column":15},"end":{"line":33,"column":5}},"line":31},"2":{"name":"(anonymous_2)","decl":{"start":{"line":37,"column":4},"end":{"line":37,"column":5}},"loc":{"start":{"line":37,"column":21},"end":{"line":39,"column":5}},"line":37},"3":{"name":"(anonymous_3)","decl":{"start":{"line":43,"column":4},"end":{"line":43,"column":5}},"loc":{"start":{"line":43,"column":16},"end":{"line":45,"column":5}},"line":43},"4":{"name":"(anonymous_4)","decl":{"start":{"line":49,"column":4},"end":{"line":49,"column":5}},"loc":{"start":{"line":49,"column":15},"end":{"line":57,"column":5}},"line":49},"5":{"name":"(anonymous_5)","decl":{"start":{"line":61,"column":4},"end":{"line":61,"column":5}},"loc":{"start":{"line":61,"column":21},"end":{"line":74,"column":5}},"line":61},"6":{"name":"(anonymous_6)","decl":{"start":{"line":78,"column":4},"end":{"line":78,"column":5}},"loc":{"start":{"line":78,"column":36},"end":{"line":102,"column":5}},"line":78},"7":{"name":"(anonymous_7)","decl":{"start":{"line":103,"column":4},"end":{"line":103,"column":5}},"loc":{"start":{"line":103,"column":44},"end":{"line":108,"column":5}},"line":103},"8":{"name":"(anonymous_8)","decl":{"start":{"line":112,"column":4},"end":{"line":112,"column":5}},"loc":{"start":{"line":112,"column":28},"end":{"line":125,"column":5}},"line":112},"9":{"name":"(anonymous_9)","decl":{"start":{"line":119,"column":24},"end":{"line":119,"column":25}},"loc":{"start":{"line":119,"column":35},"end":{"line":123,"column":9}},"line":119},"10":{"name":"(anonymous_10)","decl":{"start":{"line":120,"column":69},"end":{"line":120,"column":70}},"loc":{"start":{"line":120,"column":83},"end":{"line":120,"column":132}},"line":120},"11":{"name":"(anonymous_11)","decl":{"start":{"line":122,"column":41},"end":{"line":122,"column":42}},"loc":{"start":{"line":122,"column":51},"end":{"line":122,"column":74}},"line":122},"12":{"name":"(anonymous_12)","decl":{"start":{"line":129,"column":4},"end":{"line":129,"column":5}},"loc":{"start":{"line":129,"column":20},"end":{"line":134,"column":5}},"line":129},"13":{"name":"(anonymous_13)","decl":{"start":{"line":138,"column":4},"end":{"line":138,"column":5}},"loc":{"start":{"line":138,"column":14},"end":{"line":140,"column":5}},"line":138},"14":{"name":"(anonymous_14)","decl":{"start":{"line":139,"column":57},"end":{"line":139,"column":58}},"loc":{"start":{"line":139,"column":69},"end":{"line":139,"column":100}},"line":139},"15":{"name":"(anonymous_15)","decl":{"start":{"line":139,"column":110},"end":{"line":139,"column":111}},"loc":{"start":{"line":139,"column":122},"end":{"line":139,"column":315}},"line":139},"16":{"name":"(anonymous_16)","decl":{"start":{"line":139,"column":159},"end":{"line":139,"column":160}},"loc":{"start":{"line":139,"column":170},"end":{"line":139,"column":314}},"line":139},"17":{"name":"(anonymous_17)","decl":{"start":{"line":139,"column":207},"end":{"line":139,"column":208}},"loc":{"start":{"line":139,"column":221},"end":{"line":139,"column":313}},"line":139},"18":{"name":"(anonymous_18)","decl":{"start":{"line":141,"column":4},"end":{"line":141,"column":5}},"loc":{"start":{"line":141,"column":28},"end":{"line":143,"column":5}},"line":141},"19":{"name":"(anonymous_19)","decl":{"start":{"line":142,"column":38},"end":{"line":142,"column":39}},"loc":{"start":{"line":142,"column":44},"end":{"line":142,"column":59}},"line":142},"20":{"name":"(anonymous_20)","decl":{"start":{"line":142,"column":66},"end":{"line":142,"column":67}},"loc":{"start":{"line":142,"column":72},"end":{"line":142,"column":124}},"line":142},"21":{"name":"(anonymous_21)","decl":{"start":{"line":142,"column":131},"end":{"line":142,"column":132}},"loc":{"start":{"line":142,"column":137},"end":{"line":142,"column":151}},"line":142},"22":{"name":"(anonymous_22)","decl":{"start":{"line":142,"column":158},"end":{"line":142,"column":159}},"loc":{"start":{"line":142,"column":164},"end":{"line":142,"column":215}},"line":142},"23":{"name":"(anonymous_23)","decl":{"start":{"line":142,"column":223},"end":{"line":142,"column":224}},"loc":{"start":{"line":142,"column":232},"end":{"line":142,"column":296}},"line":142}},"branchMap":{"0":{"loc":{"start":{"line":64,"column":25},"end":{"line":64,"column":87}},"type":"cond-expr","locations":[{"start":{"line":64,"column":62},"end":{"line":64,"column":81}},{"start":{"line":64,"column":84},"end":{"line":64,"column":87}}],"line":64},"1":{"loc":{"start":{"line":64,"column":25},"end":{"line":64,"column":59}},"type":"binary-expr","locations":[{"start":{"line":64,"column":25},"end":{"line":64,"column":36}},{"start":{"line":64,"column":40},"end":{"line":64,"column":59}}],"line":64},"2":{"loc":{"start":{"line":65,"column":25},"end":{"line":65,"column":85}},"type":"cond-expr","locations":[{"start":{"line":65,"column":62},"end":{"line":65,"column":81}},{"start":{"line":65,"column":84},"end":{"line":65,"column":85}}],"line":65},"3":{"loc":{"start":{"line":65,"column":25},"end":{"line":65,"column":59}},"type":"binary-expr","locations":[{"start":{"line":65,"column":25},"end":{"line":65,"column":36}},{"start":{"line":65,"column":40},"end":{"line":65,"column":59}}],"line":65},"4":{"loc":{"start":{"line":66,"column":23},"end":{"line":66,"column":82}},"type":"cond-expr","locations":[{"start":{"line":66,"column":58},"end":{"line":66,"column":75}},{"start":{"line":66,"column":78},"end":{"line":66,"column":82}}],"line":66},"5":{"loc":{"start":{"line":66,"column":23},"end":{"line":66,"column":55}},"type":"binary-expr","locations":[{"start":{"line":66,"column":23},"end":{"line":66,"column":34}},{"start":{"line":66,"column":38},"end":{"line":66,"column":55}}],"line":66},"6":{"loc":{"start":{"line":69,"column":25},"end":{"line":69,"column":90}},"type":"cond-expr","locations":[{"start":{"line":69,"column":64},"end":{"line":69,"column":84}},{"start":{"line":69,"column":87},"end":{"line":69,"column":90}}],"line":69},"7":{"loc":{"start":{"line":69,"column":25},"end":{"line":69,"column":61}},"type":"binary-expr","locations":[{"start":{"line":69,"column":25},"end":{"line":69,"column":37}},{"start":{"line":69,"column":41},"end":{"line":69,"column":61}}],"line":69},"8":{"loc":{"start":{"line":70,"column":25},"end":{"line":70,"column":88}},"type":"cond-expr","locations":[{"start":{"line":70,"column":64},"end":{"line":70,"column":84}},{"start":{"line":70,"column":87},"end":{"line":70,"column":88}}],"line":70},"9":{"loc":{"start":{"line":70,"column":25},"end":{"line":70,"column":61}},"type":"binary-expr","locations":[{"start":{"line":70,"column":25},"end":{"line":70,"column":37}},{"start":{"line":70,"column":41},"end":{"line":70,"column":61}}],"line":70},"10":{"loc":{"start":{"line":71,"column":23},"end":{"line":71,"column":85}},"type":"cond-expr","locations":[{"start":{"line":71,"column":60},"end":{"line":71,"column":78}},{"start":{"line":71,"column":81},"end":{"line":71,"column":85}}],"line":71},"11":{"loc":{"start":{"line":71,"column":23},"end":{"line":71,"column":57}},"type":"binary-expr","locations":[{"start":{"line":71,"column":23},"end":{"line":71,"column":35}},{"start":{"line":71,"column":39},"end":{"line":71,"column":57}}],"line":71},"12":{"loc":{"start":{"line":88,"column":71},"end":{"line":88,"column":103}},"type":"cond-expr","locations":[{"start":{"line":88,"column":80},"end":{"line":88,"column":97}},{"start":{"line":88,"column":101},"end":{"line":88,"column":103}}],"line":88},"13":{"loc":{"start":{"line":94,"column":8},"end":{"line":96,"column":9}},"type":"if","locations":[{"start":{"line":94,"column":8},"end":{"line":96,"column":9}},{"start":{"line":94,"column":8},"end":{"line":96,"column":9}}],"line":94},"14":{"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},"15":{"loc":{"start":{"line":116,"column":8},"end":{"line":118,"column":9}},"type":"if","locations":[{"start":{"line":116,"column":8},"end":{"line":118,"column":9}},{"start":{"line":116,"column":8},"end":{"line":118,"column":9}}],"line":116},"16":{"loc":{"start":{"line":130,"column":8},"end":{"line":132,"column":9}},"type":"if","locations":[{"start":{"line":130,"column":8},"end":{"line":132,"column":9}},{"start":{"line":130,"column":8},"end":{"line":132,"column":9}}],"line":130},"17":{"loc":{"start":{"line":130,"column":12},"end":{"line":130,"column":46}},"type":"binary-expr","locations":[{"start":{"line":130,"column":12},"end":{"line":130,"column":16}},{"start":{"line":130,"column":20},"end":{"line":130,"column":46}}],"line":130},"18":{"loc":{"start":{"line":133,"column":16},"end":{"line":133,"column":26}},"type":"binary-expr","locations":[{"start":{"line":133,"column":16},"end":{"line":133,"column":20}},{"start":{"line":133,"column":24},"end":{"line":133,"column":26}}],"line":133},"19":{"loc":{"start":{"line":139,"column":69},"end":{"line":139,"column":100}},"type":"binary-expr","locations":[{"start":{"line":139,"column":69},"end":{"line":139,"column":82}},{"start":{"line":139,"column":86},"end":{"line":139,"column":100}}],"line":139}},"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":0,"20":1,"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":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":5,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":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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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 CLI_DONE: 'Added DynamoDB Auto Scaling to CloudFormation!',\n CLI_RESOURCE: ' - Building configuration for resource \"table/%s%s\"',\n CLI_SKIP: 'Skipping DynamoDB Auto Scaling: %s!',\n CLI_START: 'Configure DynamoDB Auto Scaling …',\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\ninterface Defaults {\n read: CapacityConfiguration,\n write: CapacityConfiguration\n}\n\nclass Plugin {\n public hooks: {}\n\n /**\n * Constructur\n */\n constructor (private serverless: Serverless) {\n this.hooks = {\n 'before:package:createDeploymentArtifacts': 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 * Get the current service region\n */\n private getRegion(): string {\n return this.serverless.getProvider('aws').getRegion()\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): Defaults {\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 data = this.defaults(config)\n\n const options: Options = {\n index,\n region: this.getRegion(),\n service: this.getServiceName(),\n stage: this.getStage(),\n table\n }\n\n // Start processing configuration\n this.serverless.cli.log(\n util.format(text.CLI_RESOURCE, table, (index ? ('/index/' + index) : ''))\n )\n\n // Add role to manage Auto Scaling policies\n const resources: any[] = [\n new Role(options)\n ]\n\n // Only add Auto Scaling for read capacity if configuration set is available\n if (!!config.read) {\n resources.push(...this.getPolicyAndTarget(options, data, true))\n }\n\n // Only add Auto Scaling for write capacity if configuration set is available\n if (!!config.write) {\n resources.push(...this.getPolicyAndTarget(options, data, false))\n }\n\n return resources\n }\n\n private getPolicyAndTarget(options: Options, data: Defaults, read: boolean): any[] {\n return [\n new Policy(options, false, data.read.usage * 100, 60, 60),\n new Target(options, false, data.read.minimum, data.read.maximum)\n ]\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(text.CLI_START))\n ).then(\n () => this.process()\n ).then(\n () => this.serverless.cli.log(util.format(text.CLI_DONE))\n ).catch(\n (err: Error) => this.serverless.cli.log(util.format(text.CLI_SKIP, err.message))\n )\n }\n}\n\nmodule.exports = Plugin\n"]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"f26d3fd7dcc13f88042fbf091da3df70140e0634"} | ||
{"/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":17,"column":1}},"8":{"start":{"line":23,"column":8},"end":{"line":23,"column":37}},"9":{"start":{"line":24,"column":8},"end":{"line":26,"column":10}},"10":{"start":{"line":32,"column":8},"end":{"line":32,"column":61}},"11":{"start":{"line":38,"column":8},"end":{"line":38,"column":56}},"12":{"start":{"line":44,"column":8},"end":{"line":44,"column":62}},"13":{"start":{"line":50,"column":8},"end":{"line":50,"column":60}},"14":{"start":{"line":51,"column":8},"end":{"line":51,"column":68}},"15":{"start":{"line":52,"column":8},"end":{"line":52,"column":77}},"16":{"start":{"line":53,"column":8},"end":{"line":53,"column":82}},"17":{"start":{"line":54,"column":8},"end":{"line":54,"column":87}},"18":{"start":{"line":55,"column":8},"end":{"line":55,"column":75}},"19":{"start":{"line":56,"column":8},"end":{"line":56,"column":86}},"20":{"start":{"line":62,"column":8},"end":{"line":73,"column":10}},"21":{"start":{"line":79,"column":21},"end":{"line":79,"column":42}},"22":{"start":{"line":80,"column":24},"end":{"line":86,"column":9}},"23":{"start":{"line":88,"column":8},"end":{"line":88,"column":107}},"24":{"start":{"line":90,"column":26},"end":{"line":92,"column":9}},"25":{"start":{"line":94,"column":8},"end":{"line":96,"column":9}},"26":{"start":{"line":95,"column":12},"end":{"line":95,"column":81}},"27":{"start":{"line":98,"column":8},"end":{"line":100,"column":9}},"28":{"start":{"line":99,"column":12},"end":{"line":99,"column":83}},"29":{"start":{"line":101,"column":8},"end":{"line":101,"column":25}},"30":{"start":{"line":107,"column":8},"end":{"line":110,"column":10}},"31":{"start":{"line":116,"column":24},"end":{"line":116,"column":26}},"32":{"start":{"line":117,"column":29},"end":{"line":117,"column":31}},"33":{"start":{"line":118,"column":24},"end":{"line":118,"column":52}},"34":{"start":{"line":119,"column":8},"end":{"line":121,"column":9}},"35":{"start":{"line":120,"column":12},"end":{"line":120,"column":32}},"36":{"start":{"line":122,"column":8},"end":{"line":126,"column":11}},"37":{"start":{"line":123,"column":28},"end":{"line":123,"column":133}},"38":{"start":{"line":123,"column":83},"end":{"line":123,"column":132}},"39":{"start":{"line":124,"column":12},"end":{"line":124,"column":50}},"40":{"start":{"line":125,"column":12},"end":{"line":125,"column":76}},"41":{"start":{"line":125,"column":51},"end":{"line":125,"column":74}},"42":{"start":{"line":127,"column":8},"end":{"line":127,"column":25}},"43":{"start":{"line":133,"column":8},"end":{"line":135,"column":9}},"44":{"start":{"line":134,"column":12},"end":{"line":134,"column":26}},"45":{"start":{"line":136,"column":8},"end":{"line":136,"column":37}},"46":{"start":{"line":142,"column":8},"end":{"line":142,"column":317}},"47":{"start":{"line":142,"column":69},"end":{"line":142,"column":100}},"48":{"start":{"line":142,"column":122},"end":{"line":142,"column":315}},"49":{"start":{"line":142,"column":170},"end":{"line":142,"column":314}},"50":{"start":{"line":142,"column":221},"end":{"line":142,"column":313}},"51":{"start":{"line":145,"column":8},"end":{"line":145,"column":298}},"52":{"start":{"line":145,"column":44},"end":{"line":145,"column":59}},"53":{"start":{"line":145,"column":72},"end":{"line":145,"column":124}},"54":{"start":{"line":145,"column":137},"end":{"line":145,"column":151}},"55":{"start":{"line":145,"column":164},"end":{"line":145,"column":215}},"56":{"start":{"line":145,"column":232},"end":{"line":145,"column":296}},"57":{"start":{"line":148,"column":0},"end":{"line":148,"column":24}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":22,"column":4},"end":{"line":22,"column":5}},"loc":{"start":{"line":22,"column":28},"end":{"line":27,"column":5}},"line":22},"1":{"name":"(anonymous_1)","decl":{"start":{"line":31,"column":4},"end":{"line":31,"column":5}},"loc":{"start":{"line":31,"column":15},"end":{"line":33,"column":5}},"line":31},"2":{"name":"(anonymous_2)","decl":{"start":{"line":37,"column":4},"end":{"line":37,"column":5}},"loc":{"start":{"line":37,"column":21},"end":{"line":39,"column":5}},"line":37},"3":{"name":"(anonymous_3)","decl":{"start":{"line":43,"column":4},"end":{"line":43,"column":5}},"loc":{"start":{"line":43,"column":16},"end":{"line":45,"column":5}},"line":43},"4":{"name":"(anonymous_4)","decl":{"start":{"line":49,"column":4},"end":{"line":49,"column":5}},"loc":{"start":{"line":49,"column":15},"end":{"line":57,"column":5}},"line":49},"5":{"name":"(anonymous_5)","decl":{"start":{"line":61,"column":4},"end":{"line":61,"column":5}},"loc":{"start":{"line":61,"column":21},"end":{"line":74,"column":5}},"line":61},"6":{"name":"(anonymous_6)","decl":{"start":{"line":78,"column":4},"end":{"line":78,"column":5}},"loc":{"start":{"line":78,"column":36},"end":{"line":102,"column":5}},"line":78},"7":{"name":"(anonymous_7)","decl":{"start":{"line":106,"column":4},"end":{"line":106,"column":5}},"loc":{"start":{"line":106,"column":44},"end":{"line":111,"column":5}},"line":106},"8":{"name":"(anonymous_8)","decl":{"start":{"line":115,"column":4},"end":{"line":115,"column":5}},"loc":{"start":{"line":115,"column":28},"end":{"line":128,"column":5}},"line":115},"9":{"name":"(anonymous_9)","decl":{"start":{"line":122,"column":24},"end":{"line":122,"column":25}},"loc":{"start":{"line":122,"column":35},"end":{"line":126,"column":9}},"line":122},"10":{"name":"(anonymous_10)","decl":{"start":{"line":123,"column":69},"end":{"line":123,"column":70}},"loc":{"start":{"line":123,"column":83},"end":{"line":123,"column":132}},"line":123},"11":{"name":"(anonymous_11)","decl":{"start":{"line":125,"column":41},"end":{"line":125,"column":42}},"loc":{"start":{"line":125,"column":51},"end":{"line":125,"column":74}},"line":125},"12":{"name":"(anonymous_12)","decl":{"start":{"line":132,"column":4},"end":{"line":132,"column":5}},"loc":{"start":{"line":132,"column":20},"end":{"line":137,"column":5}},"line":132},"13":{"name":"(anonymous_13)","decl":{"start":{"line":141,"column":4},"end":{"line":141,"column":5}},"loc":{"start":{"line":141,"column":14},"end":{"line":143,"column":5}},"line":141},"14":{"name":"(anonymous_14)","decl":{"start":{"line":142,"column":57},"end":{"line":142,"column":58}},"loc":{"start":{"line":142,"column":69},"end":{"line":142,"column":100}},"line":142},"15":{"name":"(anonymous_15)","decl":{"start":{"line":142,"column":110},"end":{"line":142,"column":111}},"loc":{"start":{"line":142,"column":122},"end":{"line":142,"column":315}},"line":142},"16":{"name":"(anonymous_16)","decl":{"start":{"line":142,"column":159},"end":{"line":142,"column":160}},"loc":{"start":{"line":142,"column":170},"end":{"line":142,"column":314}},"line":142},"17":{"name":"(anonymous_17)","decl":{"start":{"line":142,"column":207},"end":{"line":142,"column":208}},"loc":{"start":{"line":142,"column":221},"end":{"line":142,"column":313}},"line":142},"18":{"name":"(anonymous_18)","decl":{"start":{"line":144,"column":4},"end":{"line":144,"column":5}},"loc":{"start":{"line":144,"column":28},"end":{"line":146,"column":5}},"line":144},"19":{"name":"(anonymous_19)","decl":{"start":{"line":145,"column":38},"end":{"line":145,"column":39}},"loc":{"start":{"line":145,"column":44},"end":{"line":145,"column":59}},"line":145},"20":{"name":"(anonymous_20)","decl":{"start":{"line":145,"column":66},"end":{"line":145,"column":67}},"loc":{"start":{"line":145,"column":72},"end":{"line":145,"column":124}},"line":145},"21":{"name":"(anonymous_21)","decl":{"start":{"line":145,"column":131},"end":{"line":145,"column":132}},"loc":{"start":{"line":145,"column":137},"end":{"line":145,"column":151}},"line":145},"22":{"name":"(anonymous_22)","decl":{"start":{"line":145,"column":158},"end":{"line":145,"column":159}},"loc":{"start":{"line":145,"column":164},"end":{"line":145,"column":215}},"line":145},"23":{"name":"(anonymous_23)","decl":{"start":{"line":145,"column":223},"end":{"line":145,"column":224}},"loc":{"start":{"line":145,"column":232},"end":{"line":145,"column":296}},"line":145}},"branchMap":{"0":{"loc":{"start":{"line":64,"column":25},"end":{"line":64,"column":87}},"type":"cond-expr","locations":[{"start":{"line":64,"column":62},"end":{"line":64,"column":81}},{"start":{"line":64,"column":84},"end":{"line":64,"column":87}}],"line":64},"1":{"loc":{"start":{"line":64,"column":25},"end":{"line":64,"column":59}},"type":"binary-expr","locations":[{"start":{"line":64,"column":25},"end":{"line":64,"column":36}},{"start":{"line":64,"column":40},"end":{"line":64,"column":59}}],"line":64},"2":{"loc":{"start":{"line":65,"column":25},"end":{"line":65,"column":85}},"type":"cond-expr","locations":[{"start":{"line":65,"column":62},"end":{"line":65,"column":81}},{"start":{"line":65,"column":84},"end":{"line":65,"column":85}}],"line":65},"3":{"loc":{"start":{"line":65,"column":25},"end":{"line":65,"column":59}},"type":"binary-expr","locations":[{"start":{"line":65,"column":25},"end":{"line":65,"column":36}},{"start":{"line":65,"column":40},"end":{"line":65,"column":59}}],"line":65},"4":{"loc":{"start":{"line":66,"column":23},"end":{"line":66,"column":82}},"type":"cond-expr","locations":[{"start":{"line":66,"column":58},"end":{"line":66,"column":75}},{"start":{"line":66,"column":78},"end":{"line":66,"column":82}}],"line":66},"5":{"loc":{"start":{"line":66,"column":23},"end":{"line":66,"column":55}},"type":"binary-expr","locations":[{"start":{"line":66,"column":23},"end":{"line":66,"column":34}},{"start":{"line":66,"column":38},"end":{"line":66,"column":55}}],"line":66},"6":{"loc":{"start":{"line":69,"column":25},"end":{"line":69,"column":90}},"type":"cond-expr","locations":[{"start":{"line":69,"column":64},"end":{"line":69,"column":84}},{"start":{"line":69,"column":87},"end":{"line":69,"column":90}}],"line":69},"7":{"loc":{"start":{"line":69,"column":25},"end":{"line":69,"column":61}},"type":"binary-expr","locations":[{"start":{"line":69,"column":25},"end":{"line":69,"column":37}},{"start":{"line":69,"column":41},"end":{"line":69,"column":61}}],"line":69},"8":{"loc":{"start":{"line":70,"column":25},"end":{"line":70,"column":88}},"type":"cond-expr","locations":[{"start":{"line":70,"column":64},"end":{"line":70,"column":84}},{"start":{"line":70,"column":87},"end":{"line":70,"column":88}}],"line":70},"9":{"loc":{"start":{"line":70,"column":25},"end":{"line":70,"column":61}},"type":"binary-expr","locations":[{"start":{"line":70,"column":25},"end":{"line":70,"column":37}},{"start":{"line":70,"column":41},"end":{"line":70,"column":61}}],"line":70},"10":{"loc":{"start":{"line":71,"column":23},"end":{"line":71,"column":85}},"type":"cond-expr","locations":[{"start":{"line":71,"column":60},"end":{"line":71,"column":78}},{"start":{"line":71,"column":81},"end":{"line":71,"column":85}}],"line":71},"11":{"loc":{"start":{"line":71,"column":23},"end":{"line":71,"column":57}},"type":"binary-expr","locations":[{"start":{"line":71,"column":23},"end":{"line":71,"column":35}},{"start":{"line":71,"column":39},"end":{"line":71,"column":57}}],"line":71},"12":{"loc":{"start":{"line":88,"column":71},"end":{"line":88,"column":103}},"type":"cond-expr","locations":[{"start":{"line":88,"column":80},"end":{"line":88,"column":97}},{"start":{"line":88,"column":101},"end":{"line":88,"column":103}}],"line":88},"13":{"loc":{"start":{"line":94,"column":8},"end":{"line":96,"column":9}},"type":"if","locations":[{"start":{"line":94,"column":8},"end":{"line":96,"column":9}},{"start":{"line":94,"column":8},"end":{"line":96,"column":9}}],"line":94},"14":{"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},"15":{"loc":{"start":{"line":119,"column":8},"end":{"line":121,"column":9}},"type":"if","locations":[{"start":{"line":119,"column":8},"end":{"line":121,"column":9}},{"start":{"line":119,"column":8},"end":{"line":121,"column":9}}],"line":119},"16":{"loc":{"start":{"line":133,"column":8},"end":{"line":135,"column":9}},"type":"if","locations":[{"start":{"line":133,"column":8},"end":{"line":135,"column":9}},{"start":{"line":133,"column":8},"end":{"line":135,"column":9}}],"line":133},"17":{"loc":{"start":{"line":133,"column":12},"end":{"line":133,"column":46}},"type":"binary-expr","locations":[{"start":{"line":133,"column":12},"end":{"line":133,"column":16}},{"start":{"line":133,"column":20},"end":{"line":133,"column":46}}],"line":133},"18":{"loc":{"start":{"line":136,"column":16},"end":{"line":136,"column":26}},"type":"binary-expr","locations":[{"start":{"line":136,"column":16},"end":{"line":136,"column":20}},{"start":{"line":136,"column":24},"end":{"line":136,"column":26}}],"line":136},"19":{"loc":{"start":{"line":142,"column":69},"end":{"line":142,"column":100}},"type":"binary-expr","locations":[{"start":{"line":142,"column":69},"end":{"line":142,"column":82}},{"start":{"line":142,"column":86},"end":{"line":142,"column":100}}],"line":142}},"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":0,"20":1,"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":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":5,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":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;AAC7B,yCAAiC;AAEjC,MAAM,IAAI,GAAG;IACX,QAAQ,EAAE,gDAAgD;IAC1D,YAAY,EAAE,qDAAqD;IACnE,QAAQ,EAAE,qCAAqC;IAC/C,SAAS,EAAE,mCAAmC;IAC9C,qBAAqB,EAAE,kCAAkC;IACzD,qBAAqB,EAAE,sCAAsC;IAC7D,gBAAgB,EAAE,iCAAiC;CACpD,CAAA;AAOD;IAGE;;OAEG;IACH,YAAqB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;QACzC,IAAI,CAAC,KAAK,GAAG;YACX,0CAA0C,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC;SAClF,CAAA;IACH,CAAC;IAED;;OAEG;IACK,QAAQ;QACd,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAA;IACtD,CAAC;IAED;;OAEG;IACK,cAAc;QACpB,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,C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I,CACJ,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAC3D,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,IAAI,CAAC,QAAQ,CAAC,CAAC,CAC1D,CAAC,KAAK,CACL,CAAC,GAAU,KAAK,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CACjF,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 CLI_DONE: 'Added DynamoDB Auto Scaling to CloudFormation!',\n CLI_RESOURCE: ' - Building configuration for resource \"table/%s%s\"',\n CLI_SKIP: 'Skipping DynamoDB Auto Scaling: %s!',\n CLI_START: 'Configure DynamoDB Auto Scaling …',\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\ninterface Defaults {\n read: CapacityConfiguration,\n write: CapacityConfiguration\n}\n\nclass Plugin {\n public hooks: {}\n\n /**\n * Constructur\n */\n constructor (private serverless: Serverless) {\n this.hooks = {\n 'before:package:createDeploymentArtifacts': 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 * Get the current service region\n */\n private getRegion(): string {\n return this.serverless.getProvider('aws').getRegion()\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): Defaults {\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 data = this.defaults(config)\n\n const options: Options = {\n index,\n region: this.getRegion(),\n service: this.getServiceName(),\n stage: this.getStage(),\n table\n }\n\n // Start processing configuration\n this.serverless.cli.log(\n util.format(text.CLI_RESOURCE, table, (index ? ('/index/' + index) : ''))\n )\n\n // Add role to manage Auto Scaling policies\n const resources: any[] = [\n new Role(options)\n ]\n\n // Only add Auto Scaling for read capacity if configuration set is available\n if (!!config.read) {\n resources.push(...this.getPolicyAndTarget(options, data.read, true))\n }\n\n // Only add Auto Scaling for write capacity if configuration set is available\n if (!!config.write) {\n resources.push(...this.getPolicyAndTarget(options, data.write, false))\n }\n\n return resources\n }\n\n /**\n * Create Policy and Target resource\n */\n private getPolicyAndTarget(options: Options, data: CapacityConfiguration, read: boolean): any[] {\n return [\n new Policy(options, read, data.usage * 100, 60, 60),\n new Target(options, read, data.minimum, data.maximum)\n ]\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(text.CLI_START))\n ).then(\n () => this.process()\n ).then(\n () => this.serverless.cli.log(util.format(text.CLI_DONE))\n ).catch(\n (err: Error) => this.serverless.cli.log(util.format(text.CLI_SKIP, err.message))\n )\n }\n}\n\nmodule.exports = Plugin\n"]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"93de9bd38dafe29b4140859931bbbd3e81931a67"} | ||
,"/home/ubuntu/serverless-dynamodb-autoscaling/src/aws/name.ts": {"path":"/home/ubuntu/serverless-dynamodb-autoscaling/src/aws/name.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":5,"column":13},"end":{"line":12,"column":1}},"4":{"start":{"line":14,"column":4},"end":{"line":14,"column":56}},"5":{"start":{"line":17,"column":4},"end":{"line":17,"column":73}},"6":{"start":{"line":20,"column":4},"end":{"line":20,"column":56}},"7":{"start":{"line":24,"column":8},"end":{"line":24,"column":31}},"8":{"start":{"line":27,"column":8},"end":{"line":27,"column":33}},"9":{"start":{"line":30,"column":8},"end":{"line":30,"column":34}},"10":{"start":{"line":33,"column":8},"end":{"line":33,"column":33}},"11":{"start":{"line":36,"column":8},"end":{"line":36,"column":34}},"12":{"start":{"line":39,"column":8},"end":{"line":39,"column":38}},"13":{"start":{"line":42,"column":8},"end":{"line":42,"column":39}},"14":{"start":{"line":45,"column":8},"end":{"line":45,"column":50}},"15":{"start":{"line":48,"column":21},"end":{"line":48,"column":66}},"16":{"start":{"line":49,"column":8},"end":{"line":49,"column":74}},"17":{"start":{"line":52,"column":8},"end":{"line":52,"column":44}},"18":{"start":{"line":55,"column":8},"end":{"line":55,"column":71}},"19":{"start":{"line":58,"column":8},"end":{"line":58,"column":76}},"20":{"start":{"line":61,"column":8},"end":{"line":61,"column":72}},"21":{"start":{"line":64,"column":8},"end":{"line":68,"column":19}},"22":{"start":{"line":71,"column":8},"end":{"line":71,"column":36}},"23":{"start":{"line":74,"column":8},"end":{"line":79,"column":32}},"24":{"start":{"line":82,"column":0},"end":{"line":82,"column":23}}},"fnMap":{"0":{"name":"clean","decl":{"start":{"line":13,"column":9},"end":{"line":13,"column":14}},"loc":{"start":{"line":13,"column":22},"end":{"line":15,"column":1}},"line":13},"1":{"name":"truncate","decl":{"start":{"line":16,"column":9},"end":{"line":16,"column":17}},"loc":{"start":{"line":16,"column":25},"end":{"line":18,"column":1}},"line":16},"2":{"name":"ucfirst","decl":{"start":{"line":19,"column":9},"end":{"line":19,"column":16}},"loc":{"start":{"line":19,"column":23},"end":{"line":21,"column":1}},"line":19},"3":{"name":"(anonymous_3)","decl":{"start":{"line":23,"column":4},"end":{"line":23,"column":5}},"loc":{"start":{"line":23,"column":25},"end":{"line":25,"column":5}},"line":23},"4":{"name":"(anonymous_4)","decl":{"start":{"line":26,"column":4},"end":{"line":26,"column":5}},"loc":{"start":{"line":26,"column":17},"end":{"line":28,"column":5}},"line":26},"5":{"name":"(anonymous_5)","decl":{"start":{"line":29,"column":4},"end":{"line":29,"column":5}},"loc":{"start":{"line":29,"column":18},"end":{"line":31,"column":5}},"line":29},"6":{"name":"(anonymous_6)","decl":{"start":{"line":32,"column":4},"end":{"line":32,"column":5}},"loc":{"start":{"line":32,"column":17},"end":{"line":34,"column":5}},"line":32},"7":{"name":"(anonymous_7)","decl":{"start":{"line":35,"column":4},"end":{"line":35,"column":5}},"loc":{"start":{"line":35,"column":18},"end":{"line":37,"column":5}},"line":35},"8":{"name":"(anonymous_8)","decl":{"start":{"line":38,"column":4},"end":{"line":38,"column":5}},"loc":{"start":{"line":38,"column":22},"end":{"line":40,"column":5}},"line":38},"9":{"name":"(anonymous_9)","decl":{"start":{"line":41,"column":4},"end":{"line":41,"column":5}},"loc":{"start":{"line":41,"column":23},"end":{"line":43,"column":5}},"line":41},"10":{"name":"(anonymous_10)","decl":{"start":{"line":44,"column":4},"end":{"line":44,"column":5}},"loc":{"start":{"line":44,"column":17},"end":{"line":46,"column":5}},"line":44},"11":{"name":"(anonymous_11)","decl":{"start":{"line":47,"column":4},"end":{"line":47,"column":5}},"loc":{"start":{"line":47,"column":20},"end":{"line":50,"column":5}},"line":47},"12":{"name":"(anonymous_12)","decl":{"start":{"line":51,"column":4},"end":{"line":51,"column":5}},"loc":{"start":{"line":51,"column":11},"end":{"line":53,"column":5}},"line":51},"13":{"name":"(anonymous_13)","decl":{"start":{"line":54,"column":4},"end":{"line":54,"column":5}},"loc":{"start":{"line":54,"column":17},"end":{"line":56,"column":5}},"line":54},"14":{"name":"(anonymous_14)","decl":{"start":{"line":57,"column":4},"end":{"line":57,"column":5}},"loc":{"start":{"line":57,"column":22},"end":{"line":59,"column":5}},"line":57},"15":{"name":"(anonymous_15)","decl":{"start":{"line":60,"column":4},"end":{"line":60,"column":5}},"loc":{"start":{"line":60,"column":17},"end":{"line":62,"column":5}},"line":60},"16":{"name":"(anonymous_16)","decl":{"start":{"line":63,"column":4},"end":{"line":63,"column":5}},"loc":{"start":{"line":63,"column":25},"end":{"line":69,"column":5}},"line":63},"17":{"name":"(anonymous_17)","decl":{"start":{"line":70,"column":4},"end":{"line":70,"column":5}},"loc":{"start":{"line":70,"column":13},"end":{"line":72,"column":5}},"line":70},"18":{"name":"(anonymous_18)","decl":{"start":{"line":73,"column":4},"end":{"line":73,"column":5}},"loc":{"start":{"line":73,"column":13},"end":{"line":80,"column":5}},"line":73}},"branchMap":{"0":{"loc":{"start":{"line":17,"column":11},"end":{"line":17,"column":72}},"type":"cond-expr","locations":[{"start":{"line":17,"column":32},"end":{"line":17,"column":37}},{"start":{"line":17,"column":40},"end":{"line":17,"column":72}}],"line":17},"1":{"loc":{"start":{"line":48,"column":21},"end":{"line":48,"column":66}},"type":"cond-expr","locations":[{"start":{"line":48,"column":49},"end":{"line":48,"column":56}},{"start":{"line":48,"column":59},"end":{"line":48,"column":66}}],"line":48},"2":{"loc":{"start":{"line":49,"column":49},"end":{"line":49,"column":72}},"type":"cond-expr","locations":[{"start":{"line":49,"column":56},"end":{"line":49,"column":62}},{"start":{"line":49,"column":65},"end":{"line":49,"column":72}}],"line":49},"3":{"loc":{"start":{"line":55,"column":45},"end":{"line":55,"column":68}},"type":"cond-expr","locations":[{"start":{"line":55,"column":52},"end":{"line":55,"column":58}},{"start":{"line":55,"column":61},"end":{"line":55,"column":68}}],"line":55},"4":{"loc":{"start":{"line":58,"column":50},"end":{"line":58,"column":73}},"type":"cond-expr","locations":[{"start":{"line":58,"column":57},"end":{"line":58,"column":63}},{"start":{"line":58,"column":66},"end":{"line":58,"column":73}}],"line":58},"5":{"loc":{"start":{"line":61,"column":46},"end":{"line":61,"column":69}},"type":"cond-expr","locations":[{"start":{"line":61,"column":53},"end":{"line":61,"column":59}},{"start":{"line":61,"column":62},"end":{"line":61,"column":69}}],"line":61},"6":{"loc":{"start":{"line":66,"column":12},"end":{"line":66,"column":52}},"type":"cond-expr","locations":[{"start":{"line":66,"column":19},"end":{"line":66,"column":45}},{"start":{"line":66,"column":48},"end":{"line":66,"column":52}}],"line":66}},"s":{"0":5,"1":5,"2":5,"3":5,"4":38,"5":38,"6":120,"7":9,"8":3,"9":3,"10":3,"11":3,"12":3,"13":3,"14":5,"15":5,"16":5,"17":7,"18":10,"19":8,"20":8,"21":30,"22":30,"23":30,"24":5},"f":{"0":38,"1":38,"2":120,"3":9,"4":3,"5":3,"6":3,"7":3,"8":3,"9":3,"10":5,"11":5,"12":7,"13":10,"14":8,"15":8,"16":30,"17":30,"18":30},"b":{"0":[30,8],"1":[2,3],"2":[1,4],"3":[5,5],"4":[4,4],"5":[4,4],"6":[30,0]},"inputSourceMap":{"version":3,"file":"name.js","sourceRoot":"","sources":["name.ts"],"names":[],"mappings":";;AAAA,2BAA0B;AAC1B,6BAA4B;AAE5B,MAAM,IAAI,GAAG;IACX,SAAS,EAAE,6BAA6B;IACxC,MAAM,EAAE,+BAA+B;IACvC,UAAU,EAAE,yBAAyB;IACrC,WAAW,EAAE,uBAAuB;IACpC,IAAI,EAAE,uBAAuB;IAC7B,MAAM,EAAE,sBAAsB;CAC/B,CAAA;AAED,eAAe,KAAa;IAC1B,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,CAAA;AACrD,CAAC;AAED,kBAAkB,KAAa;IAC7B,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;AAED,iBAA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MAAM,CAAC,KAAK,CACV,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,GAAG,MAAM,GAAG,OAAO,CAAC,CACjD,CAAA;IACH,CAAC;IAEM,WAAW,CAAC,IAAa;QAC9B,MAAM,CAAC,KAAK,CACV,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,GAAG,MAAM,GAAG,OAAO,CAAC,CACtD,CAAA;IACH,CAAC;IAEM,MAAM,CAAC,IAAa;QACzB,MAAM,CAAC,KAAK,CACV,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,GAAG,MAAM,GAAG,OAAO,CAAC,CAClD,CAAA;IACH,CAAC;IAEO,KAAK,CAAC,IAAY,EAAE,GAAG,IAAc;QAC3C,MAAM,CAAC;YACL,IAAI,CAAC,MAAM,EAAE;YACb,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI;YACxC,IAAI,CAAC,MAAM,EAAE;SACd,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACZ,CAAC;IAEO,MAAM;QACZ,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAA;IAC7B,CAAC;IAEO,MAAM;QACZ,MAAM,CAAC;YACL,IAAI,CAAC,OAAO,CAAC,KAAK;YAClB,IAAI,CAAC,OAAO,CAAC,KAAK;YAClB,IAAI,CAAC,OAAO,CAAC,KAAK;YAClB,IAAI,CAAC,OAAO,CAAC,MAAM;SACpB,CAAC,GAAG,CACH,OAAO,CACR,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACZ,CAAC;CACF;AAnFD,uBAmFC","sourcesContent":["import * as md5 from 'md5'\nimport * as util from 'util'\n\nconst TEXT = {\n DIMENSION: 'dynamodb:%s:%sCapacityUnits',\n METRIC: 'DynamoDB%sCapacityUtilization',\n POLICYROLE: 'DynamoDBAutoscalePolicy',\n POLICYSCALE: 'TableScalingPolicy-%s',\n ROLE: 'DynamoDBAutoscaleRole',\n TARGET: 'AutoScalingTarget-%s'\n}\n\nfunction clean(input: string): string {\n return truncate(input.replace(/[^a-z0-9+]+/gi, ''))\n}\n\nfunction truncate(input: string): string {\n return input.length <= 64 ? input : input.substr(0, 32) + md5(input)\n}\n\nfunction ucfirst(data: string): string {\n return data.charAt(0).toUpperCase() + data.slice(1)\n}\n\nexport default class Name {\n constructor(private options: Options) { }\n\n public metricRead(): string {\n return this.metric(true)\n }\n\n public metricWrite(): string {\n return this.metric(false)\n }\n\n public targetRead(): string {\n return this.target(true)\n }\n\n public targetWrite(): string {\n return this.target(false)\n }\n\n public policyScaleRead(): string {\n return this.policyScale(true)\n }\n\n public policyScaleWrite(): string {\n return this.policyScale(false)\n }\n\n public policyRole(): string {\n return clean(\n this.build(TEXT.POLICYROLE)\n )\n }\n\n public dimension(read: boolean): string {\n const type = this.options.index === '' ? 'table' : 'index'\n\n return util.format(TEXT.DIMENSION, type, read ? 'Read' : 'Write')\n }\n\n public role(): string {\n return clean(this.build(TEXT.ROLE))\n }\n\n public target(read: boolean): string {\n return clean(\n this.build(TEXT.TARGET, read ? 'Read' : 'Write')\n )\n }\n\n public policyScale(read: boolean): string {\n return clean(\n this.build(TEXT.POLICYSCALE, read ? 'Read' : 'Write')\n )\n }\n\n public metric(read: boolean): string {\n return clean(\n util.format(TEXT.METRIC, read ? 'Read' : 'Write')\n )\n }\n\n private build(data: string, ...args: string[]): string {\n return [\n this.prefix(),\n args ? util.format(data, ...args) : data,\n this.suffix()\n ].join('')\n }\n\n private prefix(): string {\n return this.options.service\n }\n\n private suffix(): string {\n return [\n this.options.table,\n this.options.index,\n this.options.stage,\n this.options.region\n ].map(\n ucfirst\n ).join('')\n }\n}\n"]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"3e0a046b61f949a099d35fe6a39fd7f9750ad030"} | ||
@@ -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":19},"end":{"line":3,"column":40}},"2":{"start":{"line":6,"column":8},"end":{"line":6,"column":23}},"3":{"start":{"line":7,"column":8},"end":{"line":7,"column":25}},"4":{"start":{"line":8,"column":8},"end":{"line":8,"column":27}},"5":{"start":{"line":9,"column":8},"end":{"line":9,"column":31}},"6":{"start":{"line":10,"column":8},"end":{"line":10,"column":33}},"7":{"start":{"line":11,"column":8},"end":{"line":11,"column":65}},"8":{"start":{"line":14,"column":37},"end":{"line":14,"column":64}},"9":{"start":{"line":15,"column":27},"end":{"line":15,"column":59}},"10":{"start":{"line":16,"column":23},"end":{"line":16,"column":50}},"11":{"start":{"line":17,"column":26},"end":{"line":17,"column":80}},"12":{"start":{"line":18,"column":8},"end":{"line":36,"column":10}},"13":{"start":{"line":39,"column":0},"end":{"line":39,"column":25}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":5,"column":4},"end":{"line":5,"column":5}},"loc":{"start":{"line":5,"column":57},"end":{"line":12,"column":5}},"line":5},"1":{"name":"(anonymous_1)","decl":{"start":{"line":13,"column":4},"end":{"line":13,"column":5}},"loc":{"start":{"line":13,"column":13},"end":{"line":37,"column":5}},"line":13}},"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":2,"13":2},"f":{"0":2,"1":2},"b":{},"inputSourceMap":{"version":3,"file":"policy.js","sourceRoot":"","sources":["policy.ts"],"names":[],"mappings":";;AAAA,yCAAiC;AAEjC,YAA4B,SAAQ,kBAAQ;IAG1C,YACE,OAAgB,EACR,IAAa,EACb,KAAa,EACb,OAAe,EACf,QAAgB;QACtB,KAAK,CAAC,OAAO,CAAC,CAAA;QAJR,SAAI,GAAJ,IAAI,CAAS;QACb,UAAK,GAAL,KAAK,CAAQ;QACb,YAAO,GAAP,OAAO,CAAQ;QACf,aAAQ,GAAR,QAAQ,CAAQ;QAPT,SAAI,GAAW,4CAA4C,CAAA;IAQzD,CAAC;IAEb,MAAM;QACX,MAAM,oBAAoB,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACxD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACnD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAE1C,MAAM,SAAS,GAAG,CAAE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAE,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;QAE1E,MAAM,CAAC;YACL,CAAC,UAAU,CAAC,EAAE;gBACZ,SAAS;gBACT,UAAU,EAAE;oBACV,UAAU;oBACV,UAAU,EAAE,uBAAuB;oBACnC,eAAe,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE;oBAChC,wCAAwC,EAAE;wBACxC,6BAA6B,EAAE;4BAC7B,oBAAoB;yBACrB;wBACD,eAAe,EAAE,IAAI,CAAC,OAAO;wBAC7B,gBAAgB,EAAE,IAAI,CAAC,QAAQ;wBAC/B,WAAW,EAAE,IAAI,CAAC,KAAK;qBACxB;iBACF;gBACD,IAAI,EAAE,IAAI,CAAC,IAAI;aAChB;SACF,CAAA;IACH,CAAC;CACF;AAtCD,yBAsCC","sourcesContent":["import Resource from './resource'\n\nexport default class Policy extends Resource {\n private readonly type: string = 'AWS::ApplicationAutoScaling::ScalingPolicy'\n\n constructor (\n options: Options,\n private read: boolean,\n private value: number,\n private scaleIn: number,\n private scaleOut: number\n ) { super(options) }\n\n public toJSON(): any {\n const PredefinedMetricType = this.name.metric(this.read)\n const PolicyName = this.name.policyScale(this.read)\n const Target = this.name.target(this.read)\n\n const DependsOn = [ this.options.table, Target ].concat(this.dependencies)\n\n return {\n [PolicyName]: {\n DependsOn,\n Properties: {\n PolicyName,\n PolicyType: 'TargetTrackingScaling',\n ScalingTargetId: { Ref: Target },\n TargetTrackingScalingPolicyConfiguration: {\n PredefinedMetricSpecification: {\n PredefinedMetricType\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":"545a804283946c5337ac2ce2db558ff164ef3bf3"} |
@@ -95,14 +95,17 @@ "use strict"; | ||
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; | ||
} | ||
/** | ||
* Create Policy and Target resource | ||
*/ | ||
getPolicyAndTarget(options, data, read) { | ||
return [ | ||
new policy_1.default(options, false, data.read.usage * 100, 60, 60), | ||
new target_1.default(options, false, data.read.minimum, data.read.maximum) | ||
new policy_1.default(options, read, data.usage * 100, 60, 60), | ||
new target_1.default(options, read, data.minimum, data.maximum) | ||
]; | ||
@@ -109,0 +112,0 @@ } |
@@ -5,3 +5,3 @@ { | ||
"homepage": "https://sbstjn.com/serverless-dynamodb-auto-scaling-with-cloudformation.html", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"main": "dist/plugin.js", | ||
@@ -8,0 +8,0 @@ "scripts": { |
@@ -115,3 +115,3 @@ import * as assert from 'assert' | ||
if (!!config.read) { | ||
resources.push(...this.getPolicyAndTarget(options, data, true)) | ||
resources.push(...this.getPolicyAndTarget(options, data.read, true)) | ||
} | ||
@@ -121,3 +121,3 @@ | ||
if (!!config.write) { | ||
resources.push(...this.getPolicyAndTarget(options, data, false)) | ||
resources.push(...this.getPolicyAndTarget(options, data.write, false)) | ||
} | ||
@@ -128,6 +128,9 @@ | ||
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) | ||
] | ||
@@ -134,0 +137,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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
309926
0.13%1688
0.36%