Skip to content

Instantly share code, notes, and snippets.

@ajsharp
Last active January 9, 2021 05:36
Show Gist options
  • Save ajsharp/f597cc61dc71ad048508 to your computer and use it in GitHub Desktop.
Save ajsharp/f597cc61dc71ad048508 to your computer and use it in GitHub Desktop.
This Makefile exposes commands to do a manual deploy to AWS Elastic Beanstalk using the AWS CLI. Normally, you would do a deploy with the `eb` command, but using the AWS CLI is more convenient for orchestrating continuous deployment from a CI server.
deployment:
production:
branch: master
commands:
- make deploy
VERSION=$(shell git rev-parse --short HEAD)
DESC=$(shell git log -1 --pretty=%B)
BUCKET_NAME="my-bucket"
PROJECT_NAME="my-project"
REGION="us-east-1"
ENV_NAME="elasticbeanstalk-environment-name"
archive:
git archive --format=zip -o $(VERSION).zip HEAD
create_version:
aws s3 cp $(VERSION).zip s3://$(BUCKET_NAME)/$(PROJECT_NAME)/
aws elasticbeanstalk create-application-version --application-name $(PROJECT_NAME) --description "$(DESC)" --version-label $(VERSION) --source-bundle S3Bucket="$(BUCKET_NAME)",S3Key="$(PROJECT_NAME)/$(VERSION).zip" --region $(REGION)
update_environment:
aws elasticbeanstalk update-environment --environment-name $(ENV_NAME) --version-label $(VERSION) --region $(REGION)
clean_deploy:
rm $(VERSION).zip
deploy: archive create_version update_environment clean_deploy
@ajsharp
Copy link
Author

ajsharp commented Jan 21, 2016

Run make deploy after changing the variables to match your project to run a deploy. The circle.yml file can be used with CircleCI to do continuous deployment when a branch passes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment