-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Support string or array for `table` property * Refactoring * Prepare basic index handling * Draft for index support * Add DependsOn for resource to wait for previous resources * Fix lint errors * Rewrite table/index handling * Update README.md * Update README.md * Fix lint errors * Update README.md * Update README.md * Update README.md and package description * Update README.md * Expand names.js function * Add stage variable to names.js * Pass stage to resource objects * Use stage in names.js * Remove arrow functions from names.js * Reformat JSON for resources * Fixed typos * Minor tweaks * Clean up process()
- Loading branch information
Showing
9 changed files
with
321 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,78 @@ | ||
const util = require('util') | ||
|
||
const clean = (input) => input.replace(/[^a-z0-9+]+/gi, '') | ||
function clean (input) { | ||
return input.replace(/[^a-z0-9+]+/gi, '') | ||
} | ||
|
||
const policyScale = (table, read) => clean(util.format('Table%sScalingPolicy-%s', read ? 'Read' : 'Write', table)) | ||
const policyRole = (table) => clean(util.format('DynamoDBAutoscalePolicy-%s', table)) | ||
const dimension = (read) => util.format('dynamodb:table:%sCapacityUnits', read ? 'Read' : 'Write') | ||
const target = (table, read) => clean(util.format('AutoScalingTarget%s-%s', read ? 'Read' : 'Write', table)) | ||
const metric = (read) => clean(util.format('DynamoDB%sCapacityUtilization', read ? 'Read' : 'Write')) | ||
const role = (table) => clean(util.format('DynamoDBAutoscaleRole-%s', table)) | ||
function policyScale (table, read, index, stage) { | ||
return clean( | ||
util.format( | ||
'Table%sScalingPolicy-%s%s%s', | ||
read ? 'Read' : 'Write', | ||
table, | ||
index || '', | ||
stage || '' | ||
) | ||
) | ||
} | ||
|
||
module.exports = { dimension, metric, policyScale, policyRole, role, target, clean } | ||
function policyRole (table, index, stage) { | ||
return clean( | ||
util.format( | ||
'DynamoDBAutoscalePolicy-%s%s%s', | ||
table, | ||
index || '', | ||
stage || '' | ||
) | ||
) | ||
} | ||
|
||
function dimension (read, index) { | ||
return util.format( | ||
'dynamodb:%s:%sCapacityUnits', | ||
index ? 'index' : 'table', | ||
read ? 'Read' : 'Write' | ||
) | ||
} | ||
|
||
function target (table, read, index, stage) { | ||
return clean( | ||
util.format( | ||
'AutoScalingTarget%s-%s%s%s', | ||
read ? 'Read' : 'Write', | ||
table, | ||
index || '', | ||
stage || '' | ||
) | ||
) | ||
} | ||
|
||
function metric (read) { | ||
return clean( | ||
util.format( | ||
'DynamoDB%sCapacityUtilization', | ||
read ? 'Read' : 'Write' | ||
) | ||
) | ||
} | ||
|
||
function role (table, index, stage) { | ||
return clean( | ||
util.format( | ||
'DynamoDBAutoscaleRole-%s%s%s', | ||
table, | ||
index || '', | ||
stage || '' | ||
) | ||
) | ||
} | ||
|
||
module.exports = { | ||
clean, | ||
dimension, | ||
metric, | ||
policyRole, | ||
policyScale, | ||
role, | ||
target | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.