14

I want to make an eb deploy in a clean environment. It tells me I first need to execute eb init.

When I do this I see the following:

Select a default region
1) us-east-1 : US East (N. Virginia)
2) us-west-1 : US West (N. California)
3) us-west-2 : US West (Oregon)
4) eu-west-1 : EU (Ireland)
5) eu-central-1 : EU (Frankfurt)
6) ap-south-1 : Asia Pacific (Mumbai)
7) ap-southeast-1 : Asia Pacific (Singapore)
8) ap-southeast-2 : Asia Pacific (Sydney)
9) ap-northeast-1 : Asia Pacific (Tokyo)
10) ap-northeast-2 : Asia Pacific (Seoul)
11) sa-east-1 : South America (Sao Paulo)
12) cn-north-1 : China (Beijing)
13) us-east-2 : US East (Ohio)
14) ca-central-1 : Canada (Central)
15) eu-west-2 : EU (London)
(default is 3):

As you can see the setup needs manual instructions. How can I automate this setup?

I tried

$ export AWS_ACCESS_KEY_ID="xxx"
$ export AWS_SECRET_ACCESS_KEY="xxx"
$ export AWS_DEFAULT_REGION="xxx"
$ eb init

But again it was necessary to choose the region etc (like above)?

How can I autogenerate my .aws to make an eb deployment without manual interaction, only commands?

EDIT I tried:

init --region eu-west-1 appname

This brought me already a bit further but now I receive:

Select the default environment.

You can change this later by typing "eb use [environment_name]".
1) app-dev
2) app-uat

How can I automate this setup in my eb init command?

DenCowboy
  • 13,884
  • 38
  • 114
  • 210
  • `eb init` just writes some config files right? No reason you have to use eb init for that. – jordanm Feb 08 '18 at 18:38
  • So I can make an eb deploy without doing eb init first? Because after setting env vars and doing my eb deploy it tells me: ERROR: This directory has not been set up with the EB CLI You must first run "eb init". – DenCowboy Feb 08 '18 at 18:45

3 Answers3

13
  1. I want to make an eb deploy in a clean environment. It tells me I first need to execute eb init.

Looks like you've solved this problem, but I'll clarify anyway: The EBCLI requires that the present working directory be rooted at an eb init-ed application. The EBCLI looks for a .elasticbeanstalk/config.yml directory to determine whether the PWD has been eb init-ed. Almost all eb operations require the PWD to have been init-ed with a Beanstalk application.

  1. EDIT I tried: eb init --region eu-west-1 appname ...

You're almost there. In order to suppress the interactive mode, which is what you are trying to do, you need to pass the --platform flag. I can clearly see how inconvenient this is, but what you need is:

eb init --region eu-west-1 --platform <platform-name> appname

Where <platform-name> is the name of the language your app is in. Passing the --platform argument suppresses the interactive mode according to the documentation.

Once that is done, you can execute:

  • eb use <environment name> followed by eb deploy, or just

  • eb deploy <environment-name>

progfan
  • 2,454
  • 3
  • 22
  • 28
  • 2
    I can't get this to work either. The documentation is very poor. I tried eb init pathfinder --platform arn:aws:elasticbeanstalk:eu-west-2::platform/Puma with Ruby 2.6 running on 64bit Amazon Linux/2.9.0 | and got the error | eb: error: unrecognized arguments: with Ruby 2.6 running on 64bit Amazon Linux/2.9.0 | – Tom Feb 20 '19 at 17:49
  • Looks to me like some sloppy regex is going on in the background – Tom Feb 20 '19 at 17:50
  • This is a common problem while interacting with shells -- enclose the platform name within quotes -- `eb init pathfinder --platform "arn:aws:elasticbeanstalk:eu-west-2::platform/Puma with Ruby 2.6 running on 64bit Amazon Linux/2.9.0"` should work. If it doesn't, then it indeed is a regex problem. – progfan Feb 20 '19 at 20:01
  • 5
    Tried in quotes and out of quotes, every which way. No joy. I've given up on Elastic Beanstalk for the time being, the documentation is just so bad. – Tom Feb 20 '19 at 23:25
  • Okay, you could also write feedback on AWS Forums. (Also, FWIW, I think what's missing from the above suggestion is the `--region` argument, if I think I know what your problem is.) – progfan Feb 21 '19 at 01:23
  • Its still asks for environment name – armourbear May 29 '19 at 19:55
1

I guess you're trying to develop a CI/CD, you can check my Jenkinsfile here

You can pass input to eb deploy command using printf command:

printf '\n\n\n\n\n' | eb init ${EB_APPLICATION} --region ${AWS_REGION} --platform ${EB_PLATFORM}
Khaled AbuShqear
  • 1,230
  • 14
  • 24
  • its working for me thanks for posting this. I'm trying to deploy multiple regions using the BitBucket pipeline. Thanks once again – Kishore Nov 15 '22 at 18:00
0

I've fixed EBS deployment from Azure DevOps, using cmd task with eb init by adding this

--platform "arn:aws:elasticbeanstalk:us-east-1::platform/Tomcat 8.5 with Java 8 running on 64bit Amazon Linux/3.3.0"

full command

eb init --profile eb-cli --region us-east-1 --platform "arn:aws:elasticbeanstalk:us-east-1::platform/Tomcat 8.5 with Java 8 running on 64bit Amazon Linux/3.3.0" ${{ parameters.ENVIRONMENT }} -v

I got this with eb profile show command