Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EB Deploy to multiple environments

I have the same codebase (one git repository) that I want to upload to multiple elastic beanstalk environments. Is there a way to do this, and if so how should I set up my repository in such a way that I can push to multiple environments?

The environments are different language versions of the site, that I want to run in different beanstalks. The language is set by the environment parameters.

like image 441
adnan Avatar asked May 17 '15 14:05

adnan


People also ask

How many Applications and environments can I run with AWS Elastic Beanstalk?

Each environment runs only one application version at a time, however, you can run the same application version or different application versions in many environments simultaneously.

How does EB deploy work?

Description. Deploys the application source bundle from the initialized project directory to the running application. If git is installed, EB CLI uses the git archive command to create a . zip file from the contents of the most recent git commit command.

When launching an Elastic Beanstalk environment for the first time which three items must be selected?

Instance type, root volume, key pair, and AWS Identity and Access Management (IAM) role. Internal Amazon RDS database.

What are the two environments available in Elastic Beanstalk?

In AWS Elastic Beanstalk, you can create a load-balanced, scalable environment or a single-instance environment. The type of environment that you require depends on the application that you deploy.


3 Answers

To answer my own question. The AWS EB CLI 3+ has a nice interface to deploy to multiple environments. If you add another environment to your application you can simply deploy by using

eb deploy <environment-name>
like image 131
adnan Avatar answered Oct 08 '22 11:10

adnan


You can make the eb cli refer to different environments from different branches by adding config like the following to your .elasticbeanstalk/config.yml file:

branch-defaults:
  main:
    environment: staging
  production:
    environment: production

In this example When you run eb deploy from the "main" branch, it will deploy to your environment named "staging", whereas when you run it from the "production" branch, it will deploy to your environment named "production".

This approach requires each environment have a dedicated branch. To push one branch to multiple environments, you can use @adnan's answer and specify a branch when you use the eb deploy command:

eb deploy <environment_name>
like image 43
Zags Avatar answered Oct 08 '22 11:10

Zags


If you specify the version label you can use that version in the other eb deploy commands:

eb deploy my-first-env -l version-1 && eb deploy my-second-env --version version-1
like image 23
bbeecher Avatar answered Oct 08 '22 09:10

bbeecher