Reputation: 4857
I am using Elastic Beanstalk and I have created 3 different environments. I used awsebcli. All of a sudden the command eb list
doesn't show me my enviroments because of which I am unable to deploy the environment. The error I am getting is ERROR: This branch does not have a default environment. You must either specify an environment by typing "eb status my-env-name" or set a default environment by typing "eb use my-env-name".
I tried eb status 'my-env-name'
, again I got an error : ERROR: The environment name 'my-env-name' could not be found.
In short: I am unable to use any eb
command.
Upvotes: 12
Views: 16648
Reputation: 420
In my case, I've launched EB environment with AWS web console.
I was using eb cli with A(previous environment).
eb deploy
And I want to change my eb cli environment into B(new environment). However several commands not working for me(Never show environment B).
eb init
eb list
Finally, I removed .elasticbeanstalk
directory and succeeded eb init
.
I think EB has lots of unstable issues for its custom setting.
Upvotes: 0
Reputation: 1152
I faced the same issue here. It turned out being a region related trick.
In my case, it initially seems like related to the way I created the environment. I used the following command to create the env:
eb create --sample -r ap-southeast-1 -im 2 -ix 4 --vpc.elbpublic --vpc.ec2subnets AppSubA, AppSubB --vpc.dbsubnets DbSubA, DbSubB node-express-dev
Note that I created the env in Singapore region. After that, if I use "eb list", the result is empty. Why? I will touch upon it later.
However, if I use the command like this:
eb create --sample node-express-env
The "eb list" will be able to find the created env.
For the 1st cmd, as I said, it was created in Singapore. However, before the creation, in the "eb init" cmd, I didn't specify region. So, "eb cli" is by default in us-west-2. That's why it cannot list the created env. To fix it, before the creation, the command
eb init -p "64bit Amazon Linux 2 v5.5.3 running Node.js 16" --region ap-southeast-1
should be perfomed.
For the 2nd cmd, it is created in us-west-2, and "eb cli" is also in the same region. Both are in the default region. As a result, it can show it.
Hopefully this can help some cases.
Upvotes: 0
Reputation: 7822
Perhaps this may help others. I already had an existing environment on Beanstalk and was setting up a new Mac.
For some reason, the eb init
did create a file in ~/.aws/config
. However, it only have key and secret. To get it to work, I need to add the region as well.
# ~/.aws/config
[profile eb-cli]
aws_access_key_id = XXX
aws_secret_access_key = XXX
region=us-west-2
Next, I find my beanstalk config file in my application (i.e. project/.ebelasticbeanstalk/config.yml) and ensure that under global, it has profile: eb-cli
# project/.ebelasticbeanstalk/config.yml
global:
default_region: us-west-2
profile: eb-cli
sc: git
workspace_type: Application
After making those edits, eb list
shows the environment I am expecting and I can do eb deploy
again.
Upvotes: 3
Reputation: 37993
Did you forgot to run eb create --single
after eb init
?
This command creates a new environment. See EB CLI Command Reference »
Upvotes: 7
Reputation: 9356
The message itself is clear. You haven't set an environment for the branch you are working on.
You can either switch to the branch it's configure, but this means the changes you have in the current branch won't be available on deploy, unless you merge thos changes or you can set an environment for the branch you currently are using the command eb use name-of-your-env
. This last can also be configured in the Elastic Beanstalk configuration file of your application.
Hope this helps.
Upvotes: 3