Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the AWS account using the Elastic Beanstalk CLI

I deployed an app using elastic beanstalk to my personal AWS account..Now I want to change the AWS credentials so the eb cli knows to deploy to a different account. But it does not ask me for the AWS keys when I type "eb init". Where do I specify this?

like image 512
bpn Avatar asked Mar 22 '15 02:03

bpn


People also ask

Which command is used to view the Elastic Beanstalk events that are using AWS CLI?

The EB CLI is a command line interface for AWS Elastic Beanstalk that provides interactive commands that simplify creating, updating and monitoring environments from a local repository. Use the EB CLI as part of your everyday development and testing cycle as an alternative to the Elastic Beanstalk console.

How do you get the Elastic Beanstalk command line?

The easiest and recommended way to install the EB CLI is to use the EB CLI setup scripts available on GitHub. Use the scripts to install the EB CLI on Linux, macOS, or Windows. The scripts install the EB CLI and its dependencies, including Python and pip . The scripts also create a virtual environment for the EB CLI.


4 Answers

I had to add a new profile to this file ~/.aws/config. Example of the file with 2 profiles:

[profile eb-cli]
aws_access_key_id = XXXXXXXXXXXXX
aws_secret_access_key = XXXXXXXXXXXX

[profile eb-cli2]
aws_access_key_id = XXXXXXXXXX
aws_secret_access_key = XXXXXXXXXXXX

Also make sure to update the profile value in your application .elasticbeanstalk/config.yml

like image 76
bpn Avatar answered Oct 22 '22 00:10

bpn


Bpn's answer is correct just add the next step to avoid spending time as I did..

After updating the ~/.aws/config file, just run:

eb init --profile <profilename>

in order to switch between the account.

(in this case profilename = eb-cli2)

like image 43
Developeder Avatar answered Oct 21 '22 22:10

Developeder


Using export AWS_EB_PROFILE="default" I was able to use my key from my default profile from ~/.aws/credentials.

For more details: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-configuration.html

like image 4
Joël Avatar answered Oct 22 '22 00:10

Joël


The awsebcli tool automatically creates a file named ~/.aws/config and you can see your keys in there under the [profile eb-cli] category. Just change them there.

[profile eb-cli]
aws_access_key_id = ...
aws_secret_access_key = ...
like image 2
Dimitris Avatar answered Oct 21 '22 22:10

Dimitris