AWS Elastic Beanstalk
Developer Guide (API Version 2010-12-01)
AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Configure the EB CLI

After installing the EB CLI, you are ready to configure your project folder with eb init.

Run eb init in your application's project directory to configure the EB CLI and your project.

The following example shows the configuration steps when running eb init for the first time in a project folder named eb:

To initialize an EB CLI project

  1. First, the EB CLI prompts you to select a region. Type the number that corresponds to the region that you would like to use and press Enter.

    ~/eb $ eb init
    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 (Columbus)
    14) ca-central-1 : Canada (Central)
    15) eu-west-2 : EU (London)
    (default is 3): 3
  2. Next, provide your access key and secret key so that the EB CLI can manage resources for you. Access keys are created in the AWS Identity and Access Management management console. If you don't have keys, see How Do I Get Security Credentials? in the Amazon Web Services General Reference.

    You have not yet set up your credentials or your credentials are incorrect
    You must provide your credentials.
    (aws-access-id): AKIAJOUAASEXAMPLE
    (aws-secret-key): 5ZRIrtTM4ciIAvd4EXAMPLEDtm+PiPSzpoK
  3. An application in Elastic Beanstalk is a resource that contains a set of application versions (source), environments, and saved configurations that are associated with a single web application. Each time you deploy your source code to Elastic Beanstalk using the EB CLI, a new application version is created and added to the list.

    Select an application to use
    1) [ Create new Application ]
    (default is 1): 1
  4. The default application name is the name of the folder in which you run eb init. Enter any name that describes your project.

    Enter Application Name
    (default is "eb"): eb
    Application eb has been created.
  5. Select a platform that matches the language or framework that your web application is developed in. If you haven't started developing an application yet, choose a platform that you are interested in. You will see how to launch a sample application shortly, and you can always change this setting later.

    Select a platform.
    1) Node.js
    2) PHP
    3) Python
    4) Ruby
    5) Tomcat
    6) IIS
    7) Docker
    8) Multi-container Docker
    9) GlassFish
    10) Go
    11) Java
    (default is 1): 1
  6. Choose yes to assign an SSH key pair to the instances in your Elastic Beanstalk environment, allowing you to connect directly to them for troubleshooting.

    Do you want to set up SSH for your instances?
    (y/n): y
  7. Choose an existing key pair or create a new one. To use eb init to create a new key pair, you must have ssh-keygen installed on your local machine and available from the command line. The CLI registers the new key pair with Amazon EC2 for you and stores the private key locally in a folder named .ssh in your user directory.

    Select a keypair.
    1) [ Create new KeyPair ]
    (default is 1): 1

Your EB CLI installation is now configured and ready to use. See Managing Elastic Beanstalk Environments with the EB CLI for instructions on creating and working with an Elastic Beanstalk environment.

Ignoring files with .ebignore

You can tell the EB CLI to ignore certain files in your project directory with a .ebignore file. This file works like a .gitignore. When you deploy your project directory to Elastic Beanstalk and create a new application version, the EB CLI will not include files specified by the .ebignore in the source bundle that it creates.

If no .ebignore is present, but a .gitignore is, the EB CLI will ignore files specified in the .gitignore. If an .ebignore file is present, the EB CLI will not read the .gitignore.


In Windows, adding an .ebignore file causes the EB CLI to follow symbolic links and include the linked file when creating a source bundle. This is a known issue and will be fixed in a future update.

Using Named Profiles

If you store your credentials as a named profile in a credentials or config file, you can use the --profile option to explicitly specify a profile. For example, the following command creates a new application using the user2 profile.

$ eb init --profile user2

You can also change the default profile by setting the AWS_EB_PROFILE environment variable. When this variable is set, the EB CLI will read credentials from the specified profile instead of default or eb-cli.

Linux, OS X, or Unix

$ export AWS_EB_PROFILE=user2


> set AWS_EB_PROFILE=user2

Deploying an Artifact Instead of the Project Folder

You can tell the EB CLI to deploy a ZIP or WAR file that you generate as part of a separate build process by adding the following lines to .elasticbeanstalk/config.yml in your project folder.

  artifact: path/to/

If you configure the EB CLI in your Git repository, and you don't commit the artifact to source, use the --staged option to deploy the latest build:

~/eb$ eb deploy --staged

Configuration Settings and Precedence

The EB CLI uses a provider chain to look for AWS credentials in a number of different places, including system or user environment variables and local AWS configuration files.

The AWS CLI looks for credentials and configuration settings in the following order:

  1. Command Line Options – a named profile can be specified with --profile to override default settings.

  2. Environment VariablesAWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY

  3. The AWS credentials file – located at ~/.aws/credentials on Linux and OS X systems or at C:\Users\USERNAME\.aws\credentials on Windows systems. This file can contain multiple named profiles in addition to a default profile.

  4. The AWS CLI configuration file – located at ~/.aws/config on Linux and OS X systems or C:\Users\USERNAME\.aws\config on Windows systems. This file can contain a default profile, named profiles, and AWS CLI specific configuration parameters for each.

  5. Legacy EB CLI configuration file – located at ~/.elasticbeanstalk/config on Linux and OS X systems or C:\Users\USERNAME\.elasticbeanstalk/config on Windows systems.

  6. Instance profile credentials – these credentials can be used on EC2 instances with an assigned instance role, and are delivered through the Amazon EC2 metadata service. The instance profile must have permission to use Elastic Beanstalk.

If the credentials file contains a named profile with the name "eb-cli", the EB CLI will prefer that profile over the default profile. If no profiles are found, or a profile is found but does not have permission to use Elastic Beanstalk, the EB CLI prompts you to enter keys.

Instance Metadata

To use the EB CLI from an EC2 instance, create a role that has access to the resources needed and assign that role to the instance when it is launched. Launch the instance and install the EB CLI with pip:

~$ sudo pip install awsebcli

pip comes pre-installed on Amazon Linux.

The EB CLI will read credentials from the instance metadata. For more information, see Granting Applications that Run on Amazon EC2 Instances Access to AWS Resources in IAM User Guide.