Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Settings to deploy to AWS Elastic Beanstalk on CircleCi (EB Cli 3)

This is how I configured the deploy of my rails apps to AWS Elastic Beanstalk through CircleCI 1.0.

If you are using the Circle CI 2.0, take a look at this article from ryansimms

Configure Environments Variables

On Project Settings > Environment Variables add this keys:

    The aws user must have the right permissions. This can be hard, maybe, this can help you.

Create a bash script to create the eb config file


set -x
set -e

mkdir /home/ubuntu/.aws
touch /home/ubuntu/.aws/config
chmod 600 /home/ubuntu/.aws/config
echo "[profile eb-cli]" > /home/ubuntu/.aws/config
echo "aws_access_key_id=$AWS_ACCESS_KEY_ID" >> /home/ubuntu/.aws/config
echo "aws_secret_access_key=$AWS_SECRET_ACCESS_KEY" >> /home/ubuntu/.aws/config

Configure circle.yml

Add the awsebcli dependency:

    - sudo apt-get update
    - sudo apt-get install python-dev
    - sudo pip install awsebcli

Add the deployment config:

    branch: master
      - bash ./
      - eb deploy
  • If your deploy user don't have the elasticbeanstalk:DescribeEvents permission, the eb deploy will run for ever. CircleCI will cancel it after 10 minutes and break the build with timeout.

Create the EB Cli config file

eb init will create this file for you. However, if you don't want to run it, you can simply create and configure this file manualy:


    environment: you-environment-name
  application_name: your-application-name
  default_ec2_keyname: ec2-key-pair-name
  default_platform: 64bit Amazon Linux 2015.03 v1.4.3 running Ruby 2.2 (Puma)
  default_region: sa-east-1
  profile: eb-cli
  sc: git
Copy link

tripper54 commented Jan 18, 2017

@joemccall86 It's probably a good idea to leave those entries in gitignore. This lets you do things like eb ssh into different environments without changing the config in VC.

I got around this by storing a config.yml elsewhere in my codebase and copying into place for circleci:

    tag: /release-.*/
    owner: me
      - mkdir .elasticbeanstalk
      - cp resources/circle/eb/config.yml .elasticbeanstalk/config.yml
      - eb deploy --profile default

Copy link

vivekna1 commented Mar 13, 2017

I am trying to follow your cue i.e " fill the AWS KEY and SECRET in the CircleCI site, you can remove the bash ./ and just use the command eb deploy --profile default"
It asks for running eb init and
eb init is stuck without selecting any option, (new to eb commands). What needs to be done here?

Copy link

merliecat commented Apr 12, 2017

I got the same issue, i.e. I needed to put 'eb init' and the process was halted when it asked for an option.
The solution was to choose an option from the list (for me it was '15: eu-west-2') and then do the following: -
- echo 15 | eb init
I.e. pipe the selected response into the 'eb init' command.

Copy link

kevin-coyle commented Apr 24, 2017

    - sudo apt-get install libyaml-dev libpython2.7-dev
    - sudo pip install 'awsebcli==3.7.4' --force-reinstall

This works for me

Copy link

jkaldenbach commented May 25, 2017

To use the current version of awsebcli on the 14.04, I had to install python-dev (solves the Python.H issue) and update pip (solves Import Error: No module named packaging.version):

    - sudo apt-get install python-dev
    - sudo pip install --upgrade pip
    - sudo pip install awsebcli

Copy link

osazemeu commented Jun 14, 2017

@jkaldenbach was the only solution that worked for me. Thanks guys

Copy link

rahul-raina commented Jun 19, 2017

@osazemeu -- had to end up using easy install

    - sudo apt-get install python-dev
    - sudo easy_install --upgrade six
    - sudo pip install awsebcli

Copy link

theoutlander commented Nov 1, 2017

Thanks a lot! I had to use a slightly modified version:

#!/usr/bin/env bash
mkdir ~/.aws
touch ~/.aws/config
chmod 600 ~/.aws/config
echo "[profile eb-cli]" > ~/.aws/config
echo "aws_access_key_id=$AWS_ACCESS_KEY_ID" >> ~/.aws/config
echo "aws_secret_access_key=$AWS_SECRET_ACCESS_KEY" >> ~/.aws/config

Also, specifying the keys in the CircleCI UI made them available only as environment variables. Not sure why it didn't create these files!

Copy link

ryansimms commented Jan 8, 2018

Thanks for this, it was a big help for getting started with deploying to Elastic Beanstalk via CircleCi.

For those coming to this page that want to use CircleCi 2.0 (as I did), I wrote up the steps I took after hours of trial and error, hopefully they'll help someone:

Copy link

molayodecker commented Mar 30, 2020

I am get this error
ERROR: InvalidProfileError - The config profile (default) could not be found

This error means that is need to set the Environment variables for AWS on CircleCI. Which i have done. I even went under Permissions to set my aws Permissions. I even created a script to copy my aws credentials but nothings seems to work

            - run: 
                name: Create aws credentials
                command: |
                    chmod +x ./
                    bash ./
            - run:
                name: Deploying
                working_directory: /
                command: |
                    eb deploy TcwlApp-env
#!/usr/bin/env bash

set -x
set -e

mkdir ~/.aws
touch ~/.aws/config
chmod 600 ~/.aws/config
echo "[profile prod]" > ~/.aws/config
echo "aws_access_key_id=$AWS_ACCESS_KEY_ID" >> ~/.aws/config
echo "aws_secret_access_key=$AWS_SECRET_ACCESS_KEY" >> ~/.aws/config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment