com.amazonaws.services.elasticbeanstalk.model.S3Location Java Examples
The following examples show how to use
com.amazonaws.services.elasticbeanstalk.model.S3Location.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BeanstalkConnector.java From cloudml with GNU Lesser General Public License v3.0 | 6 votes |
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()); } }
Example #2
Source File: AmazonInstance.java From netbeans with Apache License 2.0 | 5 votes |
public S3Location createDefaultEmptyApplication() { assert !SwingUtilities.isEventDispatchThread(); AWSStaticCredentialsProvider creds = new AWSStaticCredentialsProvider(getCredentials(keyId, key)); AWSElasticBeanstalk client = AWSElasticBeanstalkClientBuilder.standard() .withCredentials(creds) .withRegion(regionCode) .build(); AmazonS3 s3 = AmazonS3ClientBuilder.standard() .withCredentials(creds) .withRegion(regionCode) .build(); String bucket = client.createStorageLocation().getS3Bucket(); boolean exist = false; try { s3.getObjectMetadata(bucket, DEFAULT_EMPTY_APPLICATION); exist = true; } catch (AmazonS3Exception ex) { // this mean object does not exist in S3 - fine } if (!exist) { try { s3.putObject(new PutObjectRequest( bucket, DEFAULT_EMPTY_APPLICATION, new ByteArrayInputStream(createEmptyWar()), new ObjectMetadata())); } catch (IOException ex) { LOG.log(Level.INFO, "Failed to create empty application war", ex); } } return new S3Location().withS3Bucket(bucket).withS3Key(DEFAULT_EMPTY_APPLICATION); }