public S3Location unmarshall(StaxUnmarshallerContext context) throws Exception { S3Location s3Location = new S3Location(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return s3Location; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("S3Bucket", targetDepth)) { s3Location.setS3Bucket(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("S3Key", targetDepth)) { s3Location.setS3Key(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return s3Location; } } } }
private S3Location uploadCodeBundle(File warFile) { if (!warFile.exists()) throw new RuntimeException("war-file " + warFile + " does not exist."); log.info("Uploading {} to Amazon S3", warFile); String bucketName = elasticBeanstalk.createStorageLocation().getS3Bucket(); String key = createS3KeyFromFileName(warFile.getName()); s3.putObject(bucketName, key, warFile); return new S3Location(bucketName, key); }
private S3Location uploadCodeBundle(File warFile) { if (!warFile.exists()) throw new RuntimeException("war-file " + warFile + " does not exist."); log.info("Uploading {} to Amazon S3", warFile); String bucketName = elasticBeanstalk.createStorageLocation().getS3Bucket(); String key = createS3KeyFromFileName(warFile.getName()); s3.putObject(bucketName, key, warFile); return new S3Location(bucketName, key); }
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()); } }
vRequest.setSourceBundle(new S3Location(bucketName, s3key)); System.out.println("Creating application version " + versionLabel + "...");
protected Object executeInternal() throws MojoExecutionException { if (skipExisting) { if (versionLabelExists()) { getLog().info("VersionLabel " + versionLabel + " already exists. Skipping creation of new application-version"); return null; } } CreateApplicationVersionRequest request = new CreateApplicationVersionRequest(); request.setApplicationName(applicationName); request.setDescription(versionDescription); request.setAutoCreateApplication(autoCreateApplication); if (StringUtils.isNotBlank(s3Bucket) && StringUtils.isNotBlank(s3Key)) { request.setSourceBundle(new S3Location(s3Bucket, s3Key)); } request.setDescription(versionDescription); request.setVersionLabel(versionLabel); CreateApplicationVersionResult result = getService().createApplicationVersion(request); return result.getApplicationVersion(); }
@TaskAction private void createVersion() { log.fine("Creating new application version"); AWSElasticBeanstalk client = AWSElasticBeanstalkClientBuilder.standard() .withCredentials(new DefaultAWSCredentialsProviderChain()) .withRegion(awsAppRegion) .build(); client.createApplicationVersion(new CreateApplicationVersionRequest() .withApplicationName(awsAppName) .withVersionLabel(newVersion) .withDescription("") .withSourceBundle(new S3Location() .withS3Bucket(awsAppBucket) .withS3Key(archiveName)) .withProcess(false)); log.fine("Created beanstalk application version for '" + awsAppName + "' with label '" + newVersion + "'"); } }
@TaskAction public void createVersion() { // to enable conventionMappings feature String appName = getAppName(); String versionLabel = getVersionLabel(); AwsBeanstalkPluginExtension ext = getProject().getExtensions().getByType(AwsBeanstalkPluginExtension.class); AWSElasticBeanstalk eb = ext.getClient(); try { eb.createApplicationVersion(new CreateApplicationVersionRequest() .withApplicationName(appName) .withVersionLabel(versionLabel) .withSourceBundle(new S3Location(getBucketName(), getKey()))); getLogger().info("version " + versionLabel + " @ " + appName + " created"); } catch (AmazonServiceException e) { if (!e.getMessage().contains("already exists.")) { throw e; } getLogger().warn("version " + versionLabel + " @ " + appName + " already exists."); } } }
public S3Location unmarshall(StaxUnmarshallerContext context) throws Exception { S3Location s3Location = new S3Location(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return s3Location; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("S3Bucket", targetDepth)) { s3Location.setS3Bucket(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("S3Key", targetDepth)) { s3Location.setS3Key(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return s3Location; } } } }
@Override public boolean perform() { log("Creating application version %s for application %s for path %s", getVersionLabel(), c.config.getApplicationName(), getS3ObjectPath()); CreateApplicationVersionRequest cavRequest = new CreateApplicationVersionRequest() .withApplicationName(c.config.getApplicationName()) .withAutoCreateApplication(true) .withSourceBundle(new S3Location(c.config.getBucketName(), getObjectKey())) .withVersionLabel(getVersionLabel()) .withDescription(getVersionDescription()); final CreateApplicationVersionResult result = getAwseb().createApplicationVersion(cavRequest); log("Created version: %s", result.getApplicationVersion().getVersionLabel()); return false; } }