2

I'm attempting to deploy an app from one ElasticBeanstalk instance to another. Running pip install awsebcli --upgrade --user doesnt install the eb cli tool for some odd reason on the EC2 machine.

Does anyone know the equivalent of eb deploy using only the aws cli options?

Vinnie James
  • 5,763
  • 6
  • 43
  • 52

2 Answers2

4

This question is a bit confusing. Are you attempting to move code between EC2 instances in your Beanstalk environment?

If I'm assuming correctly, you've pulled/changed your code on one Beanstalk host. And now you're trying to propagate that change to the other instances using the EB CLI. That's not a best practice. Beanstalk has a mechanism to deploy your code to all instances.

The EB CLI is meant to be run from your workstation to push code from your IDE/editor to the Beanstalk hosts in AWS.

Beanstalk keeps a copy of that code revision in S3. And if the Beanstalk environment is load balanced then all instances will be running the same application version when scaling events or deployments occur because it will pull your code from a common source.

But to answer your question:

Does anyone know the equivalent of eb deploy using only the aws cli options?

You're gonna wanna ZIP and upload your code to S3 and note the S3 key and bucket values of where it's located.

Then create a new application version.

% aws elasticbeanstalk create-application-version --application-name="<APPLICATION_NAME>" --version-label="<NEW_VERSION_LABEL>" --source-bundle="{\"S3Bucket\": \"<S3_BUCKET_NAME>\",\"S3Key\": \"<S3_KEY>\"}"

Then deploy your new application version to the running environment.

% aws elasticbeanstalk update-environment --environment-id="<ENVIRONMENT_ID>" --version-label="<NEW_VERSION_LABEL>"
Tim Christensen
  • 371
  • 2
  • 10
  • Yes, exactly what I was looking for. But for a slightly different purpose. I plan to have one single instance act as a master build server, using a second app (multi machines) to serve up code for the build. A single webhook will push new code to master, which then deploys to the slaves in another EB app – Vinnie James Feb 08 '18 at 19:14
  • Have you looked into AWS CodeBuild and CodePipelines? Also, when you create your application version you can specify build configuration parameters and set a processing flag which will tell Beanstalk to build your app code with CodeBuild to generate an artifact of the compiled source to push to the instances. – Tim Christensen Feb 08 '18 at 19:18
  • Yes, I did some reading on those yesterday. Since we have a lot already invested in the current ELB setup, our current approach is working well enough for now. Do you know of any good blog posts on configuring CodeBuild/Pipelines? – Vinnie James Feb 08 '18 at 19:26
  • How do you deploy a compiled WAR/JAR file to an existing Elastic Beanstalk instance (using `aws`)? I don't need to upload the entire source tree. – Chloe Oct 31 '18 at 23:19
0

Reading is hard...

Linux requires you to "[a]dd the path to the executable file to your PATH variable"

export PATH=~/.local/bin:$PATH

eb --version now works

Vinnie James
  • 5,763
  • 6
  • 43
  • 52