Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/troyready/git-lfs-s3
Git LFS S3 Storage Service
https://github.com/troyready/git-lfs-s3
Last synced: 7 days ago
JSON representation
Git LFS S3 Storage Service
- Host: GitHub
- URL: https://github.com/troyready/git-lfs-s3
- Owner: troyready
- Created: 2019-11-07T03:14:47.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-06-19T15:57:07.000Z (5 months ago)
- Last Synced: 2024-08-01T15:33:29.931Z (3 months ago)
- Language: TypeScript
- Homepage:
- Size: 3.75 MB
- Stars: 60
- Watchers: 2
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Git LFS S3 Storage Service
This project deploys a [Serverless](https://serverless.com/cli/) [Git LFS](https://git-lfs.github.com/) service, with objects stored on S3 & authentication performed via a Cognito User Pool.
## Purpose
Provides a mechanism to use Git LFS to keep binaries/large files out of your git history that doesn't depend on your git hosting provider. Reasons to use this could include:
* Your git repo hosting doesn't include Git LFS support
* Your existing git repo hosting Git LFS support is cost-prohibitive
* You need to host the files yourself (e.g. retention/[purge](https://help.github.com/en/github/managing-large-files/removing-files-from-git-large-file-storage#git-lfs-objects-in-your-repository) requirements)## Deploying
### API
* Clone the project
* Execute:
* `npm install`
* If any errors arise try deleting `package-lock.json` and trying again
* sls deploy for your stage & region; e.g. for the "common" stage in oregon: `npx sls deploy -s common -r us-west-2 --verbose`Upon completion, the 2 relevant stack outputs to note are:
* `ServiceEndpoint`: This is your Git LFS url
* `UserPoolId`: This is your Cognito User Pool id### Users
After the serverless project is deployed (see `API` above), create a user in the user pool:
```bash
aws cognito-idp admin-create-user --user-pool-id USERPOOLID --username DESIREDUSERNAME --user-attributes Name=email,Value=DESIREDEMAILADDRESS Name=phone_number,Value="+1XXXXXXXXXX" --message-action SUPPRESS --region REGION
```(substituting `USERPOOLID`, `DESIREDUSERNAME`, `DESIREDEMAILADDRESS`, `REGION`, & the phone number `XXXXXXXXXX`)
Then set a password for that user (ensure it is not saved in your shell history, e.g. for [bash](https://stackoverflow.com/a/29188490/2547802) or [zsh](https://superuser.com/a/352858)):
```bash
aws cognito-idp admin-set-user-password --user-pool-id USERPOOLID --username DESIREDUSERNAME --password PASSWORDHERE --permanent --region REGION
```(substituting `USERPOOLID`, `DESIREDUSERNAME`, `PASSWORDHERE`, & `REGION`)
## Configuring a Repo to Use the Git LFS Service
### Prereqs (System-wide -- Once Per Workstation)
Install [Git LFS](https://github.com/git-lfs/git-lfs/wiki/Installation), e.g.:
```bash
brew install git-lfs
git lfs install
```### Setting up the repo
* Add any file patterns for Git LFS to track, e.g.: `git lfs track "*.deb"`
* Configure the url: `git config -f .lfsconfig remote.origin.lfsurl SERVICEENDPOINTHERE` (subtitute your ServiceEndpoint url)
* Commit the `.gitattributes` & `.lfsconfig` filesThat's it. On push/pull, you'll be prompted for Cognito credentials.
## Further Customization Ideas
* Add an API Gateway custom domain to the API to get a better URL
* Swap out authentication
* Any backend method (e.g. LDAP) could be adapted into the authorizer in place of the current Cognito AdminInitiateAuth process.