Search code examples
amazon-web-servicesamazon-elastic-beanstalkebcli

How to use eb init without manual instructions


I want to make an eb deploy in a clean environment. It tells me I first need to execute eb init.

When I do this I see the following:

Select a default region
1) us-east-1 : US East (N. Virginia)
2) us-west-1 : US West (N. California)
3) us-west-2 : US West (Oregon)
4) eu-west-1 : EU (Ireland)
5) eu-central-1 : EU (Frankfurt)
6) ap-south-1 : Asia Pacific (Mumbai)
7) ap-southeast-1 : Asia Pacific (Singapore)
8) ap-southeast-2 : Asia Pacific (Sydney)
9) ap-northeast-1 : Asia Pacific (Tokyo)
10) ap-northeast-2 : Asia Pacific (Seoul)
11) sa-east-1 : South America (Sao Paulo)
12) cn-north-1 : China (Beijing)
13) us-east-2 : US East (Ohio)
14) ca-central-1 : Canada (Central)
15) eu-west-2 : EU (London)
(default is 3):

As you can see the setup needs manual instructions. How can I automate this setup?

I tried

$ export AWS_ACCESS_KEY_ID="xxx"
$ export AWS_SECRET_ACCESS_KEY="xxx"
$ export AWS_DEFAULT_REGION="xxx"
$ eb init

But again it was necessary to choose the region etc (like above)?

How can I autogenerate my .aws to make an eb deployment without manual interaction, only commands?

EDIT I tried:

init --region eu-west-1 appname

This brought me already a bit further but now I receive:

Select the default environment.

You can change this later by typing "eb use [environment_name]".
1) app-dev
2) app-uat

How can I automate this setup in my eb init command?


Solution

    1. I want to make an eb deploy in a clean environment. It tells me I first need to execute eb init.

    Looks like you've solved this problem, but I'll clarify anyway: The EBCLI requires that the present working directory be rooted at an eb init-ed application. The EBCLI looks for a .elasticbeanstalk/config.yml directory to determine whether the PWD has been eb init-ed. Almost all eb operations require the PWD to have been init-ed with a Beanstalk application.

    1. EDIT I tried: eb init --region eu-west-1 appname ...

    You're almost there. In order to suppress the interactive mode, which is what you are trying to do, you need to pass the --platform flag. I can clearly see how inconvenient this is, but what you need is:

    eb init --region eu-west-1 --platform <platform-name> appname

    Where <platform-name> is the name of the language your app is in. Passing the --platform argument suppresses the interactive mode according to the documentation.

    Once that is done, you can execute:

    • eb use <environment name> followed by eb deploy, or just

    • eb deploy <environment-name>