{"id":19274024,"url":"https://github.com/sbstjn/serverless-dynamodb-autoscaling","last_synced_at":"2025-04-06T17:12:55.283Z","repository":{"id":57689262,"uuid":"97621903","full_name":"sbstjn/serverless-dynamodb-autoscaling","owner":"sbstjn","description":"Serverless Plugin for Amazon DynamoDB Auto Scaling configuration.","archived":false,"fork":false,"pushed_at":"2018-08-07T22:01:49.000Z","size":89,"stargazers_count":148,"open_issues_count":13,"forks_count":25,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-30T15:11:11.665Z","etag":null,"topics":["amazon","aws","capacity","cloudformation","dynamodb","scaling","serverless","sls"],"latest_commit_sha":null,"homepage":"https://sbstjn.com/serverless-dynamodb-auto-scaling-with-cloudformation.html","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sbstjn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-18T16:41:30.000Z","updated_at":"2025-03-22T21:41:35.000Z","dependencies_parsed_at":"2022-09-26T20:53:29.114Z","dependency_job_id":null,"html_url":"https://github.com/sbstjn/serverless-dynamodb-autoscaling","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbstjn%2Fserverless-dynamodb-autoscaling","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbstjn%2Fserverless-dynamodb-autoscaling/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbstjn%2Fserverless-dynamodb-autoscaling/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbstjn%2Fserverless-dynamodb-autoscaling/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sbstjn","download_url":"https://codeload.github.com/sbstjn/serverless-dynamodb-autoscaling/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247517916,"owners_count":20951719,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amazon","aws","capacity","cloudformation","dynamodb","scaling","serverless","sls"],"created_at":"2024-11-09T20:44:50.541Z","updated_at":"2025-04-06T17:12:55.251Z","avatar_url":"https://github.com/sbstjn.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ⚡️ Serverless Plugin for DynamoDB Auto Scaling\n\n[![npm](https://img.shields.io/npm/v/serverless-dynamodb-autoscaling.svg)](https://www.npmjs.com/package/serverless-dynamodb-autoscaling)\n[![CircleCI](https://img.shields.io/circleci/project/github/sbstjn/serverless-dynamodb-autoscaling/master.svg)](https://circleci.com/gh/sbstjn/serverless-dynamodb-autoscaling)\n[![license](https://img.shields.io/github/license/sbstjn/serverless-dynamodb-autoscaling.svg)](https://github.com/sbstjn/serverless-dynamodb-autoscaling/blob/master/LICENSE.md)\n[![Coveralls](https://img.shields.io/coveralls/sbstjn/serverless-dynamodb-autoscaling.svg)](https://coveralls.io/github/sbstjn/serverless-dynamodb-autoscaling)\n\nWith this plugin for [serverless](https://serverless.com), you can enable DynamoDB Auto Scaling for tables and **Global Secondary Indexes** easily in your `serverless.yml` configuration file. The plugin supports multiple tables and indexes, as well as separate configuration for `read` and `write` capacities using Amazon's [native DynamoDB Auto Scaling](https://aws.amazon.com/blogs/aws/new-auto-scaling-for-amazon-dynamodb/).\n\n## Usage\n\nAdd the [NPM package](https://www.npmjs.com/package/serverless-dynamodb-autoscaling) to your project:\n\n```bash\n# Via yarn\n$ yarn add serverless-dynamodb-autoscaling\n\n# Via npm\n$ npm install serverless-dynamodb-autoscaling\n```\n\nAdd the plugin to your `serverless.yml`:\n\n```yaml\nplugins:\n  - serverless-dynamodb-autoscaling\n```\n\n## Configuration\n\nConfigure DynamoDB Auto Scaling in `serverless.yml` with references to your DynamoDB CloudFormation resources for the `table` property. The `index` configuration is optional to apply Auto Scaling *Global Secondary Index*.\n\n```yaml\ncustom:\n  capacities:\n    - table: CustomTable  # DynamoDB Resource\n      index:              # List or single index name\n        - custom-index-name\n      read:\n        minimum: 5        # Minimum read capacity\n        maximum: 1000     # Maximum read capacity\n        usage: 0.75       # Targeted usage percentage\n      write:\n        minimum: 40       # Minimum write capacity\n        maximum: 200      # Maximum write capacity\n        usage: 0.5        # Targeted usage percentage\n```\n\nThat's it! With the next deployment, [serverless](https://serverless.com) will add a CloudFormation configuration to enable Auto Scaling for the DynamoDB resources `CustomTable` and its *Global Secondary Index* called `custom-index-name`. \n\nYou must provide at least a configuration for `read` or `write` to enable Auto Scaling!\n\n### Defaults\n\n```yaml\nmaximum: 200\nminimum: 5\nusage: 0.75\n```\n\n### Index\n\nIf you only want to enable Auto Scaling for the index, use `indexOnly: true` to skip Auto Scaling for the general DynamoDB table.\n\n### API Throtteling\n\nCloudWatch has very strict [API rate limits](http://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_limits.html)! If you plan to configure Auto Scaling for multiple DynamoDB tables or *Global Secondary Indexes*, request an increase of the rate limits first! Otherwise, you might run into an error like this:\n\n```\nAn error occurred while provisioning your stack: XYZ - Unable to create alarms for scaling policy XYZ due to reason: \nRate exceeded (Service: AmazonCloudWatch; Status Code: 400; Error Code: Throttling; Request ID: XYZ).\n```\n\n### Breaking Changes\n\n*There have been multiple breaking changes regarding CloudFormation resource names in the past. If you end up with an error, that your CloudFormation Stack cannot be updated, try to remove the `custom \u003e capacities` configuration from your `serverless.yml` file and deploy the service without any Auto Scaling configuration. After that, just re-add your previous configuration and deploy your service again.*\n\n## DynamoDB\n\nThe example serverless configuration above works fine for a DynamoDB table CloudFormation resource like this:\n\n```yaml\nresources:\n  Resources:\n    CustomTable:\n      Type: AWS::DynamoDB::Table\n      Properties:\n        TableName: custom-table\n        AttributeDefinitions:\n          - AttributeName: key\n            AttributeType: S\n        KeySchema:\n          - AttributeName: key\n            KeyType: HASH\n        ProvisionedThroughput:\n          ReadCapacityUnits: 5\n          WriteCapacityUnits: 5\n        GlobalSecondaryIndexes:\n          - IndexName: custom-index-name\n            KeySchema:\n              - AttributeName: key\n                KeyType: HASH\n            Projection:\n              ProjectionType: ALL\n            ProvisionedThroughput:\n              ReadCapacityUnits: 5\n              WriteCapacityUnits: 5\n```\n\n## License\n\nFeel free to use the code, it's released using the [MIT license](LICENSE.md).\n\n## Thanks\n\n- [TrentBartlem](https://github.com/TrentBartlem)'s [Gist](https://gist.github.com/TrentBartlem/292be37d496361d551fff6659d87fb0e) \n- [daniel](https://forums.aws.amazon.com/message.jspa?messageID=789667#jive-message-792127)'s post in the AWS Developer Forums\n\n## Contribution\n\nYou are welcome to contribute to this project! 😘 \n\nTo make sure you have a pleasant experience, please read the [code of conduct](CODE_OF_CONDUCT.md). It outlines core values and beliefs and will make working together a happier experience.\n\n### Local Development\n\nIf you plan to change the TypeScript files and link the package to another project, use the `link` and `build` yarn commands:\n\n```\n$ \u003e yarn link\n$ \u003e yarn build:watch # or \"yarn build\"\n```\n\nUse your local build of the package in another project:\n\n```\n$ \u003e yarn link serverless-dynamodb-autoscaling\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbstjn%2Fserverless-dynamodb-autoscaling","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsbstjn%2Fserverless-dynamodb-autoscaling","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbstjn%2Fserverless-dynamodb-autoscaling/lists"}