{"id":20770810,"url":"https://github.com/codemonauts/rds-backup-lambda","last_synced_at":"2025-12-25T00:41:08.580Z","repository":{"id":82653911,"uuid":"164458249","full_name":"codemonauts/rds-backup-lambda","owner":"codemonauts","description":"Small lambda function to copy automated RDS snapshots into another region","archived":false,"fork":false,"pushed_at":"2024-03-17T12:16:24.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-18T07:12:01.658Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/codemonauts.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":"2019-01-07T16:14:14.000Z","updated_at":"2024-03-06T16:53:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"0ea1a687-dba2-4a22-a962-5f148e06c5bb","html_url":"https://github.com/codemonauts/rds-backup-lambda","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/codemonauts%2Frds-backup-lambda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonauts%2Frds-backup-lambda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonauts%2Frds-backup-lambda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonauts%2Frds-backup-lambda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codemonauts","download_url":"https://codeload.github.com/codemonauts/rds-backup-lambda/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243104204,"owners_count":20236943,"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":[],"created_at":"2024-11-17T12:12:08.227Z","updated_at":"2025-12-25T00:41:08.572Z","avatar_url":"https://github.com/codemonauts.png","language":"Python","readme":"# rds-backup-lambda\n\nSmall AWS Lambda function to copy automated RDS snapshots into another region.\n\n## Installation by hand\n\n### Role and policy\n\nCreate a role for the Lambda function and add the following policy. Please replace the `\u003cREGION\u003e` and `\u003cACCOUNTID\u003e` with your values.\n\n```json\n{\n    \"Version\": \"2012-10-17\",\n    \"Statement\": [\n        {\n            \"Action\": [\n                \"rds:ListTagsForResource\",\n                \"rds:Describe*\",\n                \"rds:DeleteDBSnapshot\",\n                \"rds:CopyDBSnapshot\",\n                \"rds:CopyDBClusterSnapshot\",\n                \"rds:CopyCustomDBEngineVersion\",\n                \"rds:AddTagsToResource\"\n            ],\n            \"Effect\": \"Allow\",\n            \"Resource\": \"*\"\n        },\n        {\n            \"Action\": [\n                \"logs:PutLogEvents\",\n                \"logs:CreateLogStream\"\n            ],\n            \"Effect\": \"Allow\",\n            \"Resource\": \"arn:aws:logs:\u003cREGION\u003e:\u003cACCOUNTID\u003e:log-group:/aws/lambda/rds-backup:*\"\n        }\n    ]\n}\n```\n\n### Build package for Lambda\n\nRun the following command to build a `package.zip` with the code for the Lambda function.\n\n```shell\nmake build\n```\n\n### Lambda function\n\nYou can create the Lambda function with the console. The following settings are recommended:\n\n- Timeout wit 60 seconds or more (depends on the number of snapshots to copy).\n- Runtime is Python 3.13 or newer.\n- The handler is `main.lambda_handler`.\n- Architecture can be `arm64` or `x86_64`.\n\nOr create a Lambda function with the AWS CLI. Replace the `\u003cARN\u003e` with the ARN of the role created above:\n\n```shell\naws lambda create-function \\\n    --function-name rds-backup \\\n    --runtime python3.13 \\\n    --zip-file fileb://package.zip \\\n    --handler main.lambda_handler \\\n    --timeout 60 \\\n    --publish \\\n    --architectures arm64 \\\n    --role \u003cARN\u003e\n```\n\nAdd the following environment configuration to the Lambda function:\n\n\n```shell\n# AWS account ID\nACCOUNT = \"1234567890\"\n# Region where the automated snapshots are located\nSOURCE_REGION = \"eu-west-1\"\n# Region where the automated snapshots should be copied to\nTARGET_REGION = \"eu-central-1\"\n# Comma separated list of RDS instances which snapshots should be copied\nSOURCE_DB = \"my-rds-instance\"\n# Comma-separated list of RDS clusters which snapshots should be copied\nSOURCE_CLUSTER = \"my-aurora-cluster\"\n# KMS Key in target region to use for snapshot encryption\nDEST_KMS = \"arn:aws:kms:eu-central-1:1234567890:key/abc123\"\n# Number of snapshots to keep\nKEEP_SNAPSHOTS = 1\n```\n\nYou have now a Lambda function without a trigger. We suggest to use an EventBridge schedule rule or the EventBridge Scheduler.\n\n## Installation by Terraform\n\nYou can use the `main.tf` to\n\n- Create all roles.\n- A log group.\n- The Lambda function itself.\n- A scheduler to invoke the Lambda function at a one days rate.\n\nIf you know what you do, you can do:\n\n```shell\nmake build\nmake plan\nmake deploy\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemonauts%2Frds-backup-lambda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodemonauts%2Frds-backup-lambda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemonauts%2Frds-backup-lambda/lists"}