{"id":15009376,"url":"https://github.com/pa/serverless-repo-git-backup","last_synced_at":"2025-07-11T14:13:03.087Z","repository":{"id":202220865,"uuid":"228714367","full_name":"pa/serverless-repo-git-backup","owner":"pa","description":"Backup all repositories in our Organization to AWS Code Commit","archived":false,"fork":false,"pushed_at":"2020-04-02T10:52:59.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-19T07:42:22.287Z","etag":null,"topics":["aws-cloudformation","aws-lambda","aws-sam","github-backup","python-3-6"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-12-17T22:43:22.000Z","updated_at":"2020-07-26T14:49:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"bc5220c9-1892-43bf-989e-4c578b3e5067","html_url":"https://github.com/pa/serverless-repo-git-backup","commit_stats":null,"previous_names":["pa/serverless-repo-git-backup"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pa%2Fserverless-repo-git-backup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pa%2Fserverless-repo-git-backup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pa%2Fserverless-repo-git-backup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pa%2Fserverless-repo-git-backup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pa","download_url":"https://codeload.github.com/pa/serverless-repo-git-backup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243233997,"owners_count":20258374,"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":["aws-cloudformation","aws-lambda","aws-sam","github-backup","python-3-6"],"created_at":"2024-09-24T19:24:47.773Z","updated_at":"2025-03-12T14:29:36.541Z","avatar_url":"https://github.com/pa.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Serverless\n\nThis is a template for Serverless backup of all repositories from Organization/User to AWS Code Commit - Below is a brief explanation of what I have generated for you:\n\n```bash\n.\n├── README.md                   \u003c-- This instructions file\n├── backup                      \u003c-- Source code for a lambda function\n│   ├── app.py                  \u003c-- Lambda function code\n│   ├── requirements.txt        \u003c-- Lambda function code\n├── template.yaml               \u003c-- SAM Template\n└── tests                       \u003c-- Unit tests\n    └── unit\n        ├── __init__.py\n        └── test_handler.py\n```\n\n## Requirements\n\n* Add GitHub Token to SSM Parameter store with name\n\n    ```bash\n    /GitHub/Token/\u003c Github Username or Organization Name\u003e\n\n    Example: /GitHub/Token/pramodh-ayyappan\n    ```\n\n* AWS CLI already configured with Administrator permission\n* [Python 3 installed](https://www.python.org/downloads/)\n* `pip3 install aws-sam-cli`\n* [Set Up Lambda Layers](#aws-lambda-layers)\n\n## Setup process\n\n**SAM CLI** is used to emulate Lambda uses our `template.yaml` to understand how to bootstrap this environment (runtime, where the source code is, etc.) - The Lambda Function will get triggered automatically on a daily basis:\n\n```yaml\n...\n ...\n Events:\n        Serverless:\n          Properties:\n            Method: post\n            Path: /github\n            RestApiId:\n              Ref: ServerlessAPI\n          Type: Api\n```\n\n## Packaging and deployment\n\nAWS Lambda Python runtime requires a flat folder with all dependencies including the application. SAM will use `CodeUri` property to know where to look up for both application and dependencies:\n\n```yaml\n...\n    ServerlessFunction:\n    Properties:\n      CodeUri: backup/\n            ...\n```\n\n## AWS Lambda Layers\n\n* Login into AWS Account\n* Go to this [link](https://github.com/aws-samples/aws-lambda-layer-awscli#option-2-deploy-from-sar-from-console-or-cli) and select a specific region and deploy.\n* Now copy generated AWS CLI Lambda Layer ARN and paste it in this file [template.yaml](template.yaml) at line 59.\n* For git binary we are going to use already existing layer `arn:aws:lambda:us-east-1:553035198032:layer:git:10`\n\n\n# SAM CLI commands\n\n## Building the project\n\n[AWS Lambda requires a flat folder](https://docs.aws.amazon.com/lambda/latest/dg/lambda-python-how-to-create-deployment-package.html) with the application as well as its dependencies in  deployment package. When you make changes to your source code or dependency manifest.\n\n```bash\nsam build\n```\n\n## Create S3 bucket\n\n```bash\naws s3 mb s3://BUCKET_NAME\n```\n\n## Package Lambda function defined locally and upload to S3 as an artifact\n\n```bash\nsam package \\\n    --output-template-file packaged.yaml \\\n    --s3-bucket REPLACE_THIS_WITH_YOUR_S3_BUCKET_NAME\n```\n\n## Deploy SAM template as a CloudFormation stack\n\n```bash\nsam deploy \\\n    --template-file packaged.yaml \\\n    --stack-name Serverless \\\n    --capabilities CAPABILITY_IAM \\\n    --parameter-overrides NotificationEmail=\"\u003cyour email\u003e\" GitOrgOrUser=\"\u003c Github User or Organisation\u003e\" GitTokenSSMParameterKey=\"\u003cssm parameter key for git access token\u003e\" VpcId=\"\u003cvpc id\u003e\" VpcSubnetIds=\"\u003csubnet id\u003e\"\n```\n\n## Describe Output section of CloudFormation stack previously created\n\n```bash\naws cloudformation describe-stacks \\\n    --stack-name Serverless-Pramodh \\\n    --query 'Stacks[].Outputs[?OutputKey==`ServerlessApi`]' \\\n    --output table\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpa%2Fserverless-repo-git-backup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpa%2Fserverless-repo-git-backup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpa%2Fserverless-repo-git-backup/lists"}