Last active
January 9, 2021 05:36
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
deployment: | |
production: | |
branch: master | |
commands: | |
- make deploy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run
make deploy
after changing the variables to match your project to run a deploy. Thecircle.yml
file can be used with CircleCI to do continuous deployment when a branch passes.