简体   繁体   中英

How to upload and deploy on Elastic Beanstalk with the aws cli?

My Settings: - I've got a multidocker application specified in my Dockerrun.aws.json file. - The images of my applications are stored on ECR.

In the AWS console for Elastic Beanstalk, I can "upload and deploy" a new Dockerrun.aws.json file. And then Elastic Beanstalk deploys that version.

Is it possible to do the same ("upload and deploy") via the aws elasticbeanstalk command line?

The closest thing I found was aws elasticbeanstalk rebuild-environment --environment-id $ENVIRONMENT_ID . But that only rebuilds the existing environment with existing Dockerrun.aws.json file. What if I want to deploy my environment with another version of my Dockerrun.aws.json file in the cli?

Yes, you can create a new deployment using the AWS CLI, and as you figured, RebuildEnvironment is not the API call. You are looking for a combination of three calls -- one to S3, and two to Beanstalk

  1. create a zip file of your application code
  2. Upload the zip file to S3. Note the bucket and key names (This would make the new version available to AWS and hence to Beanstalk)
  3. perform a call to ElasticBeanstalk's CreateApplicationVersion API:

     aws elasticbeanstalk create-application-version --application-name <beanstalk-app> --version-label <a unique label for this version of code> --description <description of your changes> --source-bundle S3Bucket="<bucket name previously noted",S3Key="<key name previously noted" 
  4. perform a call to Beanstalk's UpdateEnvironment API:

     aws elasticbeanstalk update-environment --environment-name <name of environment> --version-label <label of app. version created above> 

Clearly, this is tedious, so I also suggest you look into deploying through the EBCLI, which does all these things for you through a single command -- eb deploy

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM