{"id":21690506,"url":"https://github.com/theuves/docdb-autoscaling","last_synced_at":"2025-04-12T09:40:48.585Z","repository":{"id":74194491,"uuid":"400009079","full_name":"theuves/docdb-autoscaling","owner":"theuves","description":"An auto-scaling solution for Amazon DocumentDB.","archived":false,"fork":false,"pushed_at":"2022-10-13T21:07:46.000Z","size":84,"stargazers_count":10,"open_issues_count":0,"forks_count":7,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-05T22:30:00.545Z","etag":null,"topics":["amazon-web-services","autoscaling","aws","aws-lambda","terraform","terraform-modules"],"latest_commit_sha":null,"homepage":"","language":"Python","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/theuves.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-26T01:53:01.000Z","updated_at":"2024-10-15T12:11:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"a423c52b-0bc9-4fb6-b8c9-b68cea8c4288","html_url":"https://github.com/theuves/docdb-autoscaling","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theuves%2Fdocdb-autoscaling","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theuves%2Fdocdb-autoscaling/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theuves%2Fdocdb-autoscaling/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theuves%2Fdocdb-autoscaling/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theuves","download_url":"https://codeload.github.com/theuves/docdb-autoscaling/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248548990,"owners_count":21122808,"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-web-services","autoscaling","aws","aws-lambda","terraform","terraform-modules"],"created_at":"2024-11-25T17:31:27.090Z","updated_at":"2025-04-12T09:40:48.575Z","avatar_url":"https://github.com/theuves.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# docdb-autoscaling\n\n[![Terraform](https://github.com/theuves/docdb-autoscaling/actions/workflows/terraform.yml/badge.svg)](https://github.com/theuves/docdb-autoscaling/actions/workflows/terraform.yml)\n[![License](https://img.shields.io/github/license/theuves/docdb-autoscaling)](https://github.com/theuves/docdb-autoscaling/blob/master/LICENSE)\n\nAn auto-scaling solution for Amazon DocumentDB.\n\nThis project is an [AWS Lambda](https://aws.amazon.com/lambda/) written in Python and deployed with [Terraform](https://www.terraform.io/) that easily implements auto-scaling functionality for [Amazon DocumentDB](https://aws.amazon.com/documentdb/).\n\n## Why?\n\nAmazon DocumentDB (with MongoDB compatibility) supports [up to 15 read replicas](https://docs.aws.amazon.com/documentdb/latest/developerguide/replication.html), but by default AWS does not provide an easy way to set up an auto-scaling policy for them.\n\n## The solution\n\nFollow below how the system works:\n\n![Architecture diagram](./assets/diagram.png)\n\nResources created by Terraform:\n\n- **[CloudWatch](https://aws.amazon.com/cloudwatch/) alarm** ─ will watch a CloudWatch metric from the Document Database cluster (e.g. `CPUUtilization`).\n- **[Simple Notification Service (SNS)](https://aws.amazon.com/sns/)** ─ will be triggered by CloudWatch when any metrics are matched.\n- **[AWS Lambda](https://aws.amazon.com/lambda/)** ─ will be triggered by the SNS and will be responsible for adding or removing read replicas in the Document Database cluster.\n\n## Terraform module\n\nYou can deploy the function with Terraform using the following syntax:\n\n```terraform\nmodule \"docdb-autoscaling-prod\" {\n  source             = \"github.com/theuves/docdb-autoscaling\"\n  cluster_identifier = \"my-prod-cluster\"\n  name               = \"docdb-autoscaling-prod\"\n  min_capacity       = 3\n  max_capacity       = 6\n\n  scaling_policy = [\n    {\n      metric_name = \"CPUUtilization\"\n      target      = 80\n      statistic   = \"Average\"\n      cooldown    = 300\n    }\n  ]\n}\n```\n\n## Deployment\n\nTo create the resources:\n\n```bash\nterraform init\nterraform plan\nterraform apply\n```\n\nTo destroy:\n\n```bash\nterraform destroy\n```\n\n## Input variables\n\n| Variable | Description | Type | Default value |\n|:---|:---|:---|:---|\n| `cluster_identifier` | DocumentDB cluster identifier. | `string` | n/a |\n| `name` | Resources name. | `string` | `\"docdb-autoscaling\"` |\n| `min_capacity` | The minimum capacity. | `number` | `0` |\n| `max_capacity` | The maximum capacity. | `number` | `15` |\n| `scaling_policy` | The auto-scaling policy. | [see here](#scaling_policy) | [see here](#scaling_policy) |\n\n### `scaling_policy`\n\nType:\n\n```terraform\nlist(object({\n  metric_name = string\n  target      = number\n  statistic   = string\n  cooldown    = number\n}))\n```\n\nDefault value:\n\n```terraform\n[\n  {\n    metric_name = \"CPUUtilization\"\n    target      = 60\n    statistic   = \"Average\"\n    cooldown    = 120\n  }\n]\n```\n\nOptions:\n\n- `metric_name` ─ Amazon DocumentDB metric name ([see the list](https://docs.aws.amazon.com/documentdb/latest/developerguide/cloud_watch.html)).\n- `target` ─ The value against which the specified statistic is compared.\n- `statistic` ─ The statistic to apply to the alarm's associated metric (supported values: `SampleCount`, `Average`, `Sum`, `Minimum`, `Maximum`). \n- `cooldown` ─ The cooldown period between scaling actions.\n\n## Output values\n\nn/a\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheuves%2Fdocdb-autoscaling","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheuves%2Fdocdb-autoscaling","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheuves%2Fdocdb-autoscaling/lists"}