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 0.1.2 to 0.2.0

2

package.json
{
"name": "serverless-dynamodb-autoscaling",
"description": "Serverless Plugin for Amazon DynamoDB Auto Scaling configuration.",
"version": "0.1.2",
"version": "0.2.0",
"main": "src/plugin.js",

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

@@ -31,3 +31,3 @@ # ⚡️ Serverless Plugin for DynamoDB Auto Scaling

Configure DynamoDB Auto Scaling in `serverless.yml`:
Configure DynamoDB Auto Scaling in `serverless.yml` with references to your DynamoDB CloudFormation resources for the `table` property:

@@ -37,3 +37,3 @@ ```yaml

capacities:
- name: custom-table # DynamoDB table name
- table: CustomTable # DynamoDB Resource
read:

@@ -47,3 +47,3 @@ minimum: 5 # Minimum read capacity

usage: 0.5 # Targeted usage percentage
- name: another-table
- table: AnotherTable
read:

@@ -55,6 +55,8 @@ minimum: 5

That's it! With the next deployment (`sls deploy`) serverless will add a CloudFormation configuration to enable Auto Scaling for the DynamoDB tables `custom-table` and `another-table`.
That's it! With the next deployment (`sls deploy`) serverless will add a CloudFormation configuration to enable Auto Scaling for the DynamoDB resources `CustomTable` and `AnotherTable`.
You must of course provide at least a configuration for `read` or `write` to enable Auto Scaling. The value for `usage` has a default of 75 percent.
**Notice:** *With the relese of `v0.2.x` the plugin introduced a breaking change. Starting with `v0.2.0` you need to provide the CloudFormation reference for the `table` property. In `v0.1.x` the plugin used a `name` property with the DynamoDB table name.*
## DynamoDB

@@ -61,0 +63,0 @@

@@ -16,2 +16,6 @@ const names = require('./names')

'Type': 'AWS::ApplicationAutoScaling::ScalingPolicy',
'DependsOn': [
this.table,
names.target(this.table, this.read)
],
'Properties': {

@@ -18,0 +22,0 @@ 'PolicyName': names.policyScale(this.table, this.read),

@@ -12,2 +12,5 @@ const names = require('./names')

'Type': 'AWS::IAM::Role',
'DependsOn': [
this.table
],
'Properties': {

@@ -50,3 +53,3 @@ 'RoleName': names.role(this.table),

],
'Resource': { 'Fn::Join': [ '', [ 'arn:aws:dynamodb:*:', { 'Ref': 'AWS::AccountId' }, ':table/' + this.table ] ] }
'Resource': { 'Fn::Join': [ '', [ 'arn:aws:dynamodb:*:', { 'Ref': 'AWS::AccountId' }, ':table/', { 'Ref': this.table } ] ] }
}

@@ -53,0 +56,0 @@ ]

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

const util = require('util')
const names = require('./names')

@@ -16,7 +15,10 @@

'Type': 'AWS::ApplicationAutoScaling::ScalableTarget',
'DependsOn': names.role(this.table),
'DependsOn': [
this.table,
names.role(this.table)
],
'Properties': {
'MaxCapacity': this.max,
'MinCapacity': this.min,
'ResourceId': util.format('table/%s', this.table),
'ResourceId': { 'Fn::Join': [ '', [ 'table/', { 'Ref': this.table } ] ] },
'RoleARN': { 'Fn::GetAtt': [ names.role(this.table), 'Arn' ] },

@@ -23,0 +25,0 @@ 'ScalableDimension': names.dimension(this.read),

@@ -31,3 +31,3 @@ 'use strict'

return {
name: config.name,
table: config.table,
read: {

@@ -52,3 +52,3 @@ usage: config.read && config.read.usage ? config.read.usage : 0.75,

return this.serverless.cli.log(
util.format(' - Skipping configuration for table "%s"', config.name)
util.format(' - Skipping configuration for resource "%s"', config.table)
)

@@ -63,7 +63,7 @@ }

this.serverless.cli.log(
util.format(' - Adding configuration for table "%s"', table.name)
util.format(' - Adding configuration for resource "%s"', table.table)
)
// Add role to manage Auto Scaling policies
resources.push(new Role(table.name))
resources.push(new Role(table.table))

@@ -73,4 +73,4 @@ // Only add Auto Scaling for read capacity if configuration set is available

resources.push(
new Policy(table.name, table.read.usage, true, 60, 60),
new Target(table.name, table.read.minimum, table.read.maximum, true)
new Policy(table.table, table.read.usage, true, 60, 60),
new Target(table.table, table.read.minimum, table.read.maximum, true)
)

@@ -82,4 +82,4 @@ }

resources.push(
new Policy(table.name, table.write.usage, false, 60, 60),
new Target(table.name, table.write.minimum, table.write.maximum, false)
new Policy(table.table, table.write.usage, false, 60, 60),
new Target(table.table, table.write.minimum, table.write.maximum, false)
)

@@ -86,0 +86,0 @@ }

@@ -14,6 +14,4 @@ const names = require('../../src/aws/names')

expect(d).toHaveProperty('Type', 'AWS::ApplicationAutoScaling::ScalableTarget')
expect(d).toHaveProperty('DependsOn', names.role('my-table-name'))
expect(d).toHaveProperty('Properties.MinCapacity', 4)
expect(d).toHaveProperty('Properties.MaxCapacity', 100)
expect(d).toHaveProperty('Properties.ResourceId', 'table/my-table-name')
expect(d).toHaveProperty('Properties.ScalableDimension', names.dimension(true))

@@ -34,6 +32,4 @@ expect(d).toHaveProperty('Properties.ServiceNamespace', 'dynamodb')

expect(d).toHaveProperty('Type', 'AWS::ApplicationAutoScaling::ScalableTarget')
expect(d).toHaveProperty('DependsOn', names.role('my-table-name'))
expect(d).toHaveProperty('Properties.MinCapacity', 100)
expect(d).toHaveProperty('Properties.MaxCapacity', 2000)
expect(d).toHaveProperty('Properties.ResourceId', 'table/my-table-name')
expect(d).toHaveProperty('Properties.ScalableDimension', names.dimension(false))

@@ -40,0 +36,0 @@ expect(d).toHaveProperty('Properties.ServiceNamespace', 'dynamodb')

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc