Is there an API equivilent of the "Upload and Deploy" button in elastic beanstalk?
Asked
Active
Viewed 90 times
2 Answers
5
Its a group of 3 api's
I'll use aws CLI syntax:
s3api put-object --bucket value --key value --body file.zip
elasticbeanstalk create-application-version --application-name myapp --version-label someversion --source-bundle S3Bucket=value,S3Key=value
elasticbeanstalk update-environment --environment-name --version-label someversion

Nick Humrich
- 14,905
- 8
- 62
- 85
-
This is exactly the approach took but with powershell :) – jaywayco May 07 '15 at 16:50
1
Here is the Java code used to deploy new project to existing environment.
//To deploy new war file to the enviroinment
CreateStorageLocationResult location = service.beansTalk().createStorageLocation();
String bucket = location.getS3Bucket();
File file = new File("FirstServlet.war");
PutObjectRequest object = new PutObjectRequest(bucket, "FirstServlet.war", file);
PutObjectResult res = service.s3().putObject(object);
System.out.println(res.getClass());
CreateApplicationVersionRequest versionRequest = new CreateApplicationVersionRequest();
versionRequest.setVersionLabel("First Servlet");
versionRequest.setApplicationName("SampleApplication");
S3Location s3 = new S3Location(bucket, "FirstServlet.war");
versionRequest.setSourceBundle(s3);
CreateApplicationVersionResult resu = service.beansTalk().createApplicationVersion(versionRequest);
System.out.println(resu);
UpdateEnvironmentRequest updateRequest = new UpdateEnvironmentRequest();
updateRequest.setEnvironmentId("xxx");
updateRequest.setVersionLabel("First Servlet");
UpdateEnvironmentResult result = service.beansTalk().updateEnvironment(updateRequest);
System.out.println(result)