public void prepareWar(File warFile, String versionLabel, String applicationName) { AmazonS3 s3 = new AmazonS3Client(awsCredentials); String bucketName = beanstalkClient.createStorageLocation().getS3Bucket(); String key; try { key = URLEncoder.encode(warFile.getName() + "-" + versionLabel, "UTF-8"); s3.putObject(bucketName, key, warFile); beanstalkClient.createApplicationVersion(new CreateApplicationVersionRequest() .withApplicationName(applicationName).withAutoCreateApplication(true) .withVersionLabel(versionLabel) .withSourceBundle(new S3Location(bucketName, key))); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block journal.log(Level.SEVERE, e.getMessage()); } }
@Override public boolean perform() throws Exception { log("Creating application version %s for application %s for path %s", getVersionLabel(), getApplicationName(), getS3ObjectPath()); CreateApplicationVersionRequest cavRequest = new CreateApplicationVersionRequest() .withApplicationName(getApplicationName()) .withAutoCreateApplication(true) .withSourceBundle(new S3Location(getBucketName(), getObjectKey())) .withVersionLabel(getVersionLabel()) .withDescription(getVersionDescription()); final CreateApplicationVersionResult result = getAwseb().createApplicationVersion(cavRequest); log("Created version: %s", result.getApplicationVersion().getVersionLabel()); return false; }
private void createApplicationVersion(String applicationName, AWSElasticBeanstalk eb, String bucketName, String objectName, String versionLabel) { log.info("creating version label=" + versionLabel); CreateApplicationVersionRequest request = new CreateApplicationVersionRequest() .withApplicationName(applicationName).withAutoCreateApplication(true) .withSourceBundle(new S3Location(bucketName, objectName)).withVersionLabel(versionLabel); eb.createApplicationVersion(request); }
public void createApplicationVersion(AWSElasticBeanstalk awseb) { AWSEBUtils.log(listener, "Creating application version %s for application %s for path %s", versionLabel, applicationName, s3ObjectPath); CreateApplicationVersionRequest cavRequest = new CreateApplicationVersionRequest().withApplicationName(applicationName).withAutoCreateApplication(true) .withSourceBundle(new S3Location(bucketName, objectKey)).withVersionLabel(versionLabel); awseb.createApplicationVersion(cavRequest); }
@Cacheable @Override public S3Location location() { if (this.exists()) { Logger.info( this, "No need to upload %s (%s) to S3, will use existing object", this.war, FileUtils.byteCountToDisplaySize(this.war.length()) ); } else { Logger.info( this, "Uploading %s (%s) to s3://%s/%s... (may take a few minutes)", this.war, FileUtils.byteCountToDisplaySize(this.war.length()), this.bucket, this.key ); final PutObjectResult res = this.client.putObject( this.bucket, this.key, this.war ); Logger.info( this, // @checkstyle LineLength (1 line) "Uploaded successfully to S3, etag=%s, expires=%s, exp.rule=%s, encryption=%s, version=%s", res.getETag(), res.getExpirationTime(), res.getExpirationTimeRuleId(), res.getServerSideEncryption(), res.getVersionId() ); } return new S3Location(this.bucket, this.key); }
/** * {@inheritDoc} */ @Override public S3Location location() { return this.origin.location(); }
/** * Get S3 location of an app. * @return The location */ S3Location location();