6

I have the following .elasticbeanstalk/config.yml

branch-defaults:
  default:
    environment: MyDev-env
deploy:
  artifact: target/App-Sprint9-SNAPSHOT-bin.zip
environment-defaults:
  MyDev-env:
    branch: null
    repository: null
global:
  application_name: App
  default_ec2_keyname: app
  default_platform: arn:aws:elasticbeanstalk:us-east-9::platform/Tomcat 8 with Java
    8 running on 64bit Amazon Linux/3.1.0
  default_region: us-east-9
  include_git_submodules: true
  instance_profile: null
  platform_name: null
  platform_version: null
  profile: null
  sc: git
  workspace_type: Application

When I try to deploy with eb deploy -l XXX, it complains:

ERROR: This branch does not have a default environment. You must either specify an environment by typing "eb deploy my-env-name" or set a default environment by typing "eb use my-env-name".

But I do have a default environment! It's specified in the very first 3 lines! Why doesn't it use it? If I use eb use environment then it just adds another row under branch-defaults: with the current branch, and I have to do the same thing all over again with a new branch.

EB CLI 3.14.11 (Python 3.7.1) and EB CLI 3.15.3 (Python 3.7.3)

Chloe
  • 25,162
  • 40
  • 190
  • 357
  • Hey Chloe. I'm able to reproduce this issue with a similar config file. I noticed however that if I removed 'git' in the 'sc' property and replaced it with 'null' then it allowed me to perform an `eb deploy` without problems. I'm unaware if this is a bug with the ebcli or if perhaps a misconfiguration with how git interacts with the ebcli. – ChaseAllbee Sep 23 '19 at 21:24
  • @ChaseAllbee I set `sc: null` and deleted `sprint9: environment: MyDev-env` and it still gave me the error. I'm on Windows. – Chloe Sep 23 '19 at 21:37
  • I see. Could you try two things: add the `environment: MyDev-env` back into the config file and then run the deploy command you've been running but with the `--debug` flag on. I'd like to see if there's any extra information we could glean about this issue. – ChaseAllbee Sep 23 '19 at 22:14
  • @ChaseAllbee Here is the log. I don't know what you mean by 'add the `environment:`' back as there is already a `default: environment:`. I don't know which line you were referring to. I'm not sure why you would want to see the logs when it is working with `sprint9: environment:`. https://www.pastiebin.com/5d8954bd967f3 – Chloe Sep 23 '19 at 23:30
  • Oh I misunderstood what you had removed. I was suggesting re-adding the `sprint9: environment: MyDev-env` to the config file to see if simply removing the sc flag would fix the issue. I was hoping to see the logs incase there was some information as to what the root cause of the issue might be on the ebcli, although it appears there isn't much more information being provided in the debug. – ChaseAllbee Sep 24 '19 at 17:46

3 Answers3

1

The reason is it is missing env values of config. I did eb init that started working.

Pranu Pranav
  • 353
  • 3
  • 8
1

I found out that the the branch-defaults refers to the AWS CodeCommit feature branches (same as with the environment-defaults section). Since you would expect it to understand Git but it doesn't, that's probably why you're not getting it to work. Setup CodeCommit and then it will do what you want.

branch-defaults:
  default:
    environment: my-webapi-prod-env-1
  webapi-aws-prod:
    environment: my-webapi-prod-env-1
  webapi-aws-stag:
    environment: my-webapi-stag-env-1
  workerapi-aws-prod:
    environment: my-webapi-worker-env-2
environment-defaults:
  my-webapi-prod-env-1:
    branch: null
    repository: null
global:
  application_name: my-webapi
  branch: null
  default_ec2_keyname: my-ec2-keypair
  default_platform: Docker
  default_region: us-east-1
  include_git_submodules: true
  instance_profile: null
  platform_name: null
  platform_version: null
  profile: null
  repository: null
  sc: null
  workspace_type: Application
Tim B.
  • 11
  • 1
  • 1
0

Sorry for the lame answer, but I'm pretty sure you have to set up the default environment for each branch, or just use eb deploy my-env

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

Juan Fuentes
  • 1,743
  • 2
  • 20
  • 33