# How to setup Elastic Beanstalk Deployment?

**URL:** <https://discuss.circleci.com/t/how-to-setup-elastic-beanstalk-deployment/6154>\
**Category:** Build Environment\
**Tags:** elasticbeanstalk, circle-yml\
**Created:** [September 11, 2016, 2:36am UTC](https://discuss.circleci.com/t/how-to-setup-elastic-beanstalk-deployment/6154 "2016-09-11T02:36:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![hardreggaecafe](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/hardreggaecafe/32/27208_2.png) [@hardreggaecafe](https://discuss.circleci.com/u/hardreggaecafe)\
**Post date:** [September 11, 2016, 2:36am UTC](https://discuss.circleci.com/t/how-to-setup-elastic-beanstalk-deployment/6154/1 "2016-09-11T02:36:20Z")

</div>

I can’t figure out how to setup elastic beanstalk on CirclCI.

I have two brunch, which is master and staging.  
As you can see, master means production environment and staging means development.

First I set up environment variable.

And next, made circleci.yml like this.

```auto
machine:
  python:
    version: 2.7.6

dependencies:
  pre:
    - pip install awsebcli
    - printenv

database:
  override:
    - exit 0

test:
  override:
    - exit 0

deployment:
  staging:
    branch: staging
    commands:
      - eb deploy vegewel-staging
  production:
    branch: master
    commands:
      - eb deploy vegewel

```

And also set up .elasticbeanstalk/config.yml like this.

```auto
branch-defaults:
  master:
    environment: vegewel
  staging:
    environment: vegewel-staging
global:
  application_name: vegewel
  default_ec2_keyname: vegewel
  default_platform: 64bit Amazon Linux 2016.03 v2.1.6 running Ruby 2.3 (Passenger
    Standalone)
  default_region: ap-northeast-1
  profile: eb-cli
  sc: git

```

But every time I check on circleci console, I’ve been facing this problem.

```auto
eb deploy vegewel-staging
ERROR: The config profile (eb-cli) could not be found

```

Any idea? Thanks in advance.

---

<div class="post-metadata">

**Author:** ![hardreggaecafe](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/hardreggaecafe/32/27208_2.png) [@hardreggaecafe](https://discuss.circleci.com/u/hardreggaecafe)\
**Post date:** [September 11, 2016, 12:04pm UTC](https://discuss.circleci.com/t/how-to-setup-elastic-beanstalk-deployment/6154/3 "2016-09-11T12:04:56Z")

</div>

I noticed  
`profile: eb-cli`  
is cause of error. It attaches local environment.  
When I delete this, it works.

---

<div class="post-metadata">

**Author:** ![tomers](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/tomers/32/15089_2.png) [@tomers](https://discuss.circleci.com/u/tomers)\
**Post date:** [January 8, 2017, 12:33pm UTC](https://discuss.circleci.com/t/how-to-setup-elastic-beanstalk-deployment/6154/4 "2017-01-08T12:33:09Z")

</div>

It seems that the missing /home/ubuntu/.aws/config file causes the error message "ERROR: The config profile (eb-cli) could not be found"  
I followed instructions in the following gist: [https://gist.github.com/RobertoSchneiders/9e0e73e836a80d53a21e](https://gist.github.com/RobertoSchneiders/9e0e73e836a80d53a21e), which resolved the issue by explicitly creating this file.  
I created ./scripts/deploy.sh file with the following content:

```
#!/usr/bin/env bash
set -x
set -e

AWS_CONFIG_FILE=$HOME/.aws/config

mkdir $HOME/.aws
touch $AWS_CONFIG_FILE
chmod 600 $AWS_CONFIG_FILE

echo "[profile eb-cli]" > $AWS_CONFIG_FILE
echo "aws_access_key_id=$AWS_ACCESS_KEY_ID" >> $AWS_CONFIG_FILE
echo "aws_secret_access_key=$AWS_SECRET_ACCESS_KEY" >> $AWS_CONFIG_FILE

eb deploy my-environment-production 2>&1 | tee $CIRCLE_ARTIFACTS/eb_deploy_output.txt
# Temporary hack to overcome issue eith 'eb deploy' returning exit code 0 on error
# See http://stackoverflow.com/questions/23771923/elasticbeanstalk-deployment-error-command-hooks-directoryhooksexecutor-py-p
grep -v -c -q -i error $CIRCLE_ARTIFACTS/eb_deploy_output.txt

```

and then in circle.yml I put:

```
deployment:
  production:
    branch: master
    commands:
      - ./scripts/deploy.sh

```

HTH

---

<div class="post-metadata">

**Author:** ![andre](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/andre/32/15661_2.png) [@andre](https://discuss.circleci.com/u/andre)\
**Post date:** [March 14, 2017, 11:42am UTC](https://discuss.circleci.com/t/how-to-setup-elastic-beanstalk-deployment/6154/5 "2017-03-14T11:42:10Z")

</div>

Another solution is simply:

```
AWS_EB_PROFILE=default eb deploy <environment>
```

---

<div class="post-metadata">

**Author:** ![cgreening](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/cgreening/32/14246_2.png) [@cgreening](https://discuss.circleci.com/u/cgreening)\
**Post date:** [May 8, 2017, 7:21pm UTC](https://discuss.circleci.com/t/how-to-setup-elastic-beanstalk-deployment/6154/6 "2017-05-08T19:21:23Z")

</div>

I recently blogged about this: [https://blog.cmgresearch.com/2017/05/07/step-5-use-circleci-to-deploy-to-elastic-beanstalk.html](https://blog.cmgresearch.com/2017/05/07/step-5-use-circleci-to-deploy-to-elastic-beanstalk.html) - You can also just do:

```auto
eb deploy --profile default

```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [June 18, 2018, 11:38am UTC](https://discuss.circleci.com/t/how-to-setup-elastic-beanstalk-deployment/6154/7 "2018-06-18T11:38:41Z")

</div>

Closed on June 18, 2018, 11:38am UTC


