I have 2 AWS machines, 1.dev (ec2) 2. prod (elastic beanstalk)
. I build and deploy on dev (machine1) after every commit which results into a war file (which will also be uploaded on an S3 bucket using s3cmd tool). Then I test the newly deployed war on dev machine, if it seems fine, then I download the war from dev(ec2) and then upload it to the prod machine (Elastic beanstalk).
Is there a way to make elastic beanstalk to take the war directly from the S3 bucket, rather than downloading it from ec2 and then uploading it to elastic beanstalk?
I tried creating new environment and then gave s3 bucket path for application version, but it din't work. (gave some error saying "this can only be done in VPC").
I have got the best answer in this post :
it requires 3 simple steps using AWS CLI:
- Upload to S3 bucket: aws s3 cp /var/lib/tomcat7/webapps/ROOT.war s3://elasticbeanstalk-ap-southeast-1-xxxxxx/myROOT.war
- Create application version: aws elasticbeanstalk create-application-version --application-name your_app_name --version-label your_version_label --source-bundle S3Bucket=elasticbeanstalk-ap-southeast-1-xxxxxx,S3Key=myROOT.war
- Update your environment: aws elasticbeanstalk update-environment --environment-name your_environment_name --version-label your_version_label
I have created a bash script, which takes just 3 seconds for all the above steps. Do go through the link for more descriptive answer.
If your s3 war file is in mybucket/test/myapp.war then creating an application version with the s3 bucket as mybucket
and test/myapp.war
is the way to do it. Not sure why you are getting the VPC related error. When and where do you see that error? When you create an application version or when you create an environment? Does the API call throw the error message immediately do you see that in the events later?
来源:https://stackoverflow.com/questions/25683649/deploy-war-from-s3-to-aws-elastic-beanstalk