EladG
EladG

Reputation: 804

Elastic Beanstalk: Deploy branch to env

I'm considering migration for custom hosted Rails app to Elastic Beanstalk.

I've create a simple Rails app and manage to deploy it to on Elastic beanstalk. There are still a few thing I still didn't manage to get:

  1. How can I deploy a branch or a specific code to my app?
  2. Is the deployed version is from last commit or my current workspace?
  3. What are the best practices when handling deployment on Beanstalk?

Amazon have this document (link) but it seems to be deprecated and I can't figure how to do it on current version

elad:...$ eb --version EB CLI 3.7 (Python 2.7.1)

Upvotes: 3

Views: 2309

Answers (2)

Jarad
Jarad

Reputation: 18953

Someone considering their options could take a look at AWS Code Pipeline. You define the specific GitHub repo branch. If you push a change to that branch, Code Pipeline detects it and starts a pipeline process.

This is relevant to Elastic Beanstalk because on Step 4 of Code Pipeline, you can deploy to AWS Elastic Beanstalk (among others).

AWS CodePipeline

Upvotes: 0

Hieu Pham
Hieu Pham

Reputation: 6692

I'm not sure my solution is the best practices or not, I just show here, welcome all comments on this.

  1. How can I deploy a branch or a specific code to my app?
  • Beanstalk support deploy the last commit in current branch (which was actually uploaded to S3 firstly) by using EB command line
  • Deploy from a zipped file which was also actually updated to S3 after that Here is what in in your environment settings in Beanstalk console

enter image description here

enter image description here

  1. Is the deployed version is from last commit or my current workspace?
  • From last commit

3.What are the best practices when handling deployment on Beanstalk?

My solution #1: Define which branch will be deployed to a specific environment

In .elasticbeanstalk/config.yml

# .....
branch-defaults:
  develop:
    environment: mercury-dev-staging
  master:
    environment: mercury-dev
# .....

Relying on this config, I always switch to develop branch to deploy to mercury-dev-staging env, and master one for mercury-dev. This will avoid some mistakes like deploying develop branch to production env

My solution #2: Define some alias commands for quick deployment:

In ~/.bash_profile (I'm using MacOS)

alias deploy_production="eb deploy mercury-dev;"
alias deploy_staging="eb deploy mercury-dev-staging;"

Now I just type deploy_staging for staging deployment, this is convenient but risky, because you may deploy your developing feature to production.

Upvotes: 2

Related Questions