Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
deb/requirements/
deb/code.zip

rpm/code.zip

rpm/__pycache__
rpm/boto3*
rpm/botocore*
rpm/concurrent*
rpm/docutils*
rpm/dateutil*
rpm/six*
rpm/futures*
rpm/pyrpm*
rpm/tests*
rpm/jmespath*
rpm/python_gnupg*
rpm/python_dateutil*

rpm/code.zip

rpm/six.py
rpm/gnupg.py
rpm/gnupg.pyc
10 changes: 10 additions & 0 deletions deb/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ZIPPED := aptS3.py gnupg.py debian/*


all: requires compress

requires:
pip install -t . -r requirements.txt

compress:
zip code.zip $(ZIPPED)
80 changes: 80 additions & 0 deletions deb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@

# AWS Lambda APT repository manager for S3

Rewrite of [szinck/s3apt](https://github.com/szinck/s3apt) with a few changes and extra features - Release file is being generated and is signed with GPG key provided

## Setting up S3 and Lambda

Clone the repo and get all other required files
```
git clone https://github.com/tactycal/lambdaRepos.git
cd lambdaRepos/deb
pip install -t . -r requirements.txt
```

Compress all needed files
```
zip code.zip aptS3.py gnupg.py debian/*
```

Presuming you already have GPG key generated export public key
```
gpg --export-secret-key > secret.key
```

Create new lambda function, set handler to **s3apt.lambda_handler** and the triggers to:

* Object Created, suffix 'deb'
* Object Removed, suffix 'deb'
* If you are using certain directory as a repo, set it as prefix

Upload `code.zip` to lambda function

Set the environment variables

| Key | Value |
| --- | ---|
| PUBLIC | True/False |
| GPG_KEY | File |
| GPG_PASS | GPG key password |
| BUCKET_NAME | Bucket Name |
| CACHE_PREFIX | Directory |

**PUBLIC** Set to True for the outputs to be publicly readable

**GPG_KEY** Location of your GPG private key from root of the bucket (e.g. secret/private.key)

**GPG_PASS** Password of private key uploaded to GPG_KEY (Note: environental variables are/can be encripted using KMS keys)

**BUCKET_NAME** Name of the bucket. Should be the same as the one selected in triggers and the one you're using for repository

**CACHE_PREFIX** Path to folder for packages cache(e.g. deb/cache)


Make folder in your S3 bucket with the same name as CACHE_PREFIX variable

Upload secret key file to location you specified as GPG_KEY

Upload .deb file to desired folder, lambda function should now keep your repository up to date

## Setting up apt

First time set up
```
sudo echo "deb https://s3.$AWS_SERVER.amazonaws.com/$BUCKET_NAME/$PATH_TO_FOLDER_WITH_DEBIAN_FILES /" > /etc/apt/sources.list
#an example of link "https://s3.eu-central-1.amazonaws.com/testbucket/repo"
#add public key to trusted sources - you have to export public key or use key server
apt-key add <path to key>
sudo apt update
sudo apt install <packages>
```

Upgrading package
```
sudo apt update
sudo apt upgrade
```

## Notes

.deb, Release and Package files are and should be publicly accessible for previously mentioned method of setting up apt's sources list to work, if you don't want them to be, then change PUBLIC in environment variables to False and refer to szinck's guide [here](http://webscale.plumbing/managing-apt-repos-in-s3-using-lambda)
9 changes: 9 additions & 0 deletions deb/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
boto3==1.3.1
botocore==1.4.41
docutils==0.12
futures==3.0.5
jmespath==0.9.0
python-dateutil==2.5.3
python-debian==0.1.28
six==1.10.0
python-gnupg==0.4.1
Loading