AWS CodeDeploy Alternative for On-Prem Deployments

Mir Adnan
2 min readOct 8, 2018

--

Last week I was trying to setup AWS CodeDeploy on an On-Prem Ubuntu Server 16.04. Unfortunately CodeDeploy supports only ruby2.0 version. Whereas Ubuntu 16.04 and above ship with ruby2.3

Eventually I decided to write my own S3CodeDeployer in GoLang. It has no dependencies. Its just a binary file that runs as service on your Linux machine.

Note: You’ll need to have versioning enabled for respective S3 Bucket.

This program will check for latest version and download tar ball / zip from S3 and extract all the files into respective Application directories as defined in yourconfig.yml . This agent will also run BeforeInstall and AfterInstall hooks once the application is deployed successfully.

A detailed document for Debian, Ubuntu and RPM is located at: https://miradnan.github.io/s3-code-deployer/

For demo purpose ill be using Ubuntu 16.04 (Xenial) .

First we need to add GnuPG Public Key:

$ wget — no-cache -O — https://api.bintray.com/users/miradnanali/keys/gpg/public.key | sudo apt-key add -

Add Source for Ubuntu 16.04

$ echo “deb [arch=amd64] https://dl.bintray.com/miradnanali/S3CodeDeployerDebian xenial main” > /etc/apt/sources.list.d/s3-codedeployer.list

Installation:

$ apt-get install s3-code-deployer

Create a config.yml file in /etc/s3-code-deployer/config.yml

revision_check_duration: 10 // in minutesaws:
accessKey: YOUR_AWS_ACCESS_KEY
secretKey: YOUR_AWS_SECRET_KEY
bucket: YOUR_AWS_DEPLOYMENT_BUCKET
region: YOUR_AWS_REGION
deployments:- application: staging.example.com
environment: staging
destination: /var/www/html/staging.example.com
s3_revision_file: example.com/staging.tar.gz
- application: www.example.com
environment: production
destination: /var/www/html/www.example.com
s3_revision_file: example.com/prod.tar.gz
# You can add as many applications as you want.

Thats it, now restart s3-code-deployer service:

$ service s3-code-deployer restart

That’s it! Your applications will now be auto-deployed once a tar ball is updated on your S3 Bucket.

--

--

Mir Adnan
Mir Adnan

No responses yet