弹性beanstalk中是否存在“上传和部署”按钮的API等效项?

时间:2022-08-25 09:27:43

Is there an API equivilent of the "Upload and Deploy" button in elastic beanstalk?

弹性beanstalk中是否存在“上传和部署”按钮的API等效项?

弹性beanstalk中是否存在“上传和部署”按钮的API等效项?

2 个解决方案

#1


Its a group of 3 api's

它是一组3个api

I'll use aws CLI syntax:

我将使用aws CLI语法:

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

#2


Here is the Java code used to deploy new project to existing environment.

以下是用于将新项目部署到现有环境的Java代码。

        //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)

#1


Its a group of 3 api's

它是一组3个api

I'll use aws CLI syntax:

我将使用aws CLI语法:

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

#2


Here is the Java code used to deploy new project to existing environment.

以下是用于将新项目部署到现有环境的Java代码。

        //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)