codedeploy-multideployer
codedeploy-multideployer uses AWS CodeDeploy to deploy multiple applications on the same instance in one shot.
Motivation
AWS CodeDeploy is a great tool, but it's designed to deploy only one application to a single instance. Associating multiple deployment groups to the same AutoScaling group is not recommended:
- https://stackoverflow.com/questions/43134523/multiple-aws-codedeploy-applications-in-a-newly-added-instance
- https://stackoverflow.com/questions/38979802/how-can-i-deploy-multiple-applications-to-a-instance-using-aws-codedeploy
codedeploy-multideployer groups multiple deploys in one so only one deployment group needs to be associated to an AutoScaling group.
Requirements
- Python >= 3.4
- AWS CodeDeploy
- codedeploy-local (see below)
codedeploy-local
codedeploy_local is a feature not yet integrated to any release in AWS CodeDeploy. It allows to localy deploy a specific release to a specific instance.
codedeploy_multideployer uses this tool to locally deploy all the required applications to a deployment group.
How to install
It can be installed either system-wide or inside a virtualenv:
python3 setup.py install
CodeDeploy agent needs to be installed following AWS documentation
codedeploy_local also has to be installed independently from the regular codedeploy-agent. As this tool is not yet ready for production, some changes are required before it can be used. We've opened a pull request to the main project so this change is merged into master.
Until then it needs to be installed with our modifications on a different path:
git clone https://github.com/wuakitv/aws-codedeploy-agent.git
cd aws-codedeploy-agent/
gem build codedeploy_agent-1.1.0.gemspec
gem install --no-ri --no-rdoc \
--install-dir=/opt/codedeploy-local \
--bindir=/opt/codedeploy-local/bin \
aws_codedeploy_agent-0.1.gem
cp -r certs/ /opt/codedeploy-local/gems/aws_codedeploy_agent-0.1/
cat << EOF > /usr/local/bin/codedeploy-local
#!/bin/bash
GEM_PATH=/opt/codedeploy-local /opt/codedeploy-local/gems/aws_codedeploy_agent-0.1/bin/codedeploy-local
EOF
chmod +x /usr/local/bin/codedeploy-local
Example deploy
codedeploy-multideployer is designed to work using an independent repository where all the applications to be deployed and their releases are specified in a YAML file.
The wuakitv/codedeploy-multideployer-example repository has an example configuration to deploy the awslabs/aws-codedeploy-sample-tomcat application.
In your AWS CodeDeploy console, configure a new application and deployment group. Then deploy a new revision of the wuakitv/codedeploy-multideployer-example repository.
Once the new deploy is triggered the following will happen:
- Every codedeploy-agent installed in each instance will receive a signal and will start the deployment lifecycle
- When reached the AfterInstall hook, codedeploy-multideployer will be triggered as specified in the after_install.sh script
- codedeploy-multideployer will parse the provided multideployer.yaml file and process each one of the specified applications.
- For each app, codedeploy-multideployer will download the code directly from GitHub. If the specified repository is not public, appropiate credentials should be provided via the
MULTIDEPLOYER_GITHUB_TOKENenvironment variable or the--github-tokenparameter - After the code has been downloaded, codedeploy-local be executed with the required parameters. Each application needs to have an
appspec.ymlfile with the instructions on how to deploy it. - codedeploy-local will copy all the files specified in the
appspec.ymlfile and run the scripts for each one of the hooks - If the application to be deployed has already been deployed with the same release hash and the parameter
forcein themultideployer.yamlfile is nottrue, the deployment will be skipped - If one application's deployment fails, the whole deployment will fail

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
