List of usage examples for com.amazonaws.regions Region toString
@Override
public String toString()
From source file:br.com.ingenieux.mojo.beanstalk.util.EnvironmentHostnameUtil.java
License:Apache License
public static String ensureSuffix(String cname, Region region) { if (PATTERN_HOSTNAME.matcher(cname).matches()) { return cname; } else {//w w w . ja v a 2s .c om return format("%s.%s.elasticbeanstalk.com", cname, region.toString()); } }
From source file:com.pearson.eidetic.driver.threads.subthreads.ErrorChecker.java
private void loggerOuputSnapshotErrors(List<Snapshot> error_snapshots, Region region) { for (Snapshot snapshot : error_snapshots) { logger.info("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"SnapshotInErrorState\", region=\"" + region.toString() + ", snapshot_id=\"" + snapshot.getSnapshotId() + "\""); }/*from w w w. j a va 2s.com*/ }
From source file:org.broadleafcommerce.vendor.amazon.s3.S3ConfigurationServiceImpl.java
License:Apache License
private void initS3ConfigurationImpl() { final long ts1 = System.currentTimeMillis(); s3config = new S3Configuration(); s3config.setAwsSecretKey(lookupProperty("aws.s3.secretKey")); s3config.setDefaultBucketName(lookupProperty("aws.s3.defaultBucketName")); s3config.setDefaultBucketRegion(RegionUtils.getRegion(lookupProperty("aws.s3.defaultBucketRegion"))); s3config.setGetAWSAccessKeyId(lookupProperty("aws.s3.accessKeyId")); s3config.setEndpointURI(lookupProperty("aws.s3.endpointURI")); s3config.setBucketSubDirectory(lookupProperty("aws.s3.bucketSubDirectory")); String uploadedAssetStorageBucketSubDirectory = lookupProperty( "aws.s3.uploadedAssetStorageBucketSubDirectory"); if (!Strings.isNullOrEmpty(uploadedAssetStorageBucketSubDirectory)) { s3config.setUploadedAssetStorageBucketSubDirectory(uploadedAssetStorageBucketSubDirectory); }/*from ww w .ja v a 2 s .c o m*/ final String staticAssetFileExtensionPatternStr = lookupProperty("aws.s3.staticAssetFileExtensionPattern"); if (!Strings.isNullOrEmpty(staticAssetFileExtensionPatternStr)) { s3config.setStaticAssetFileExtensionPattern(staticAssetFileExtensionPatternStr); } final String manifestVersionKey = lookupProperty("aws.s3.manifestVersionKey"); if (!Strings.isNullOrEmpty(manifestVersionKey)) { String versionSubDirectory = Manifests.read(manifestVersionKey); if (!Strings.isNullOrEmpty(versionSubDirectory)) { versionSubDirectory = "dev"; } s3config.setVersionSubDirectory(versionSubDirectory); } final boolean accessSecretKeyBlank = StringUtils.isEmpty(s3config.getAwsSecretKey()); final boolean accessKeyIdBlank = StringUtils.isEmpty(s3config.getGetAWSAccessKeyId()); final boolean bucketNameBlank = StringUtils.isEmpty(s3config.getDefaultBucketName()); final Region region = s3config.getDefaultBucketRegion(); final long ts2 = System.currentTimeMillis(); if (LOG.isTraceEnabled()) { final String msg = String.format("%s - using s3://%s/%s in region %s; setup time = %dms", s3config.getEndpointURI(), s3config.getDefaultBucketName(), s3config.getBucketSubDirectory(), region.toString(), ts2 - ts1); LOG.trace(msg); } if (region == null || accessSecretKeyBlank || accessKeyIdBlank || bucketNameBlank) { StringBuilder errorMessage = new StringBuilder("Amazon S3 Configuration Error : "); if (accessSecretKeyBlank) { errorMessage.append("aws.s3.secretKey was blank,"); } if (accessKeyIdBlank) { errorMessage.append("aws.s3.accessKeyId was blank,"); } if (bucketNameBlank) { errorMessage.append("aws.s3.defaultBucketName was blank,"); } if (region == null) { errorMessage.append("aws.s3.defaultBucketRegion was set to an invalid value of " + s3config.getDefaultBucketRegion()); } throw new IllegalArgumentException(errorMessage.toString()); } }
From source file:org.zalando.stups.fullstop.plugin.instance.RunInstancePlugin.java
License:Apache License
protected Optional<List<SecurityGroup>> getSecurityGroupsForIds(final List<String> securityGroupIds, final CloudTrailEvent event) { Region region = getRegion(event); String accountId = getAccountId(event); AmazonEC2Client amazonEC2Client = getClient(accountId, region); if (amazonEC2Client == null) { throw new RuntimeException( String.format("Somehow we could not create an Client with accountId: %s and region: %s", accountId, region.toString())); } else {//w ww . j a va2 s . co m try { DescribeSecurityGroupsRequest request = new DescribeSecurityGroupsRequest(); request.setGroupIds(securityGroupIds); DescribeSecurityGroupsResult result = amazonEC2Client.describeSecurityGroups(request); return Optional.of(result.getSecurityGroups()); } catch (AmazonClientException e) { LOG.warn("Unable to get SecurityGroups for SecurityGroupIds [{}] | {}", securityGroupIds.toString(), e.getMessage()); return Optional.empty(); } } }
From source file:org.zalando.stups.fullstop.plugin.RunInstancePlugin.java
License:Apache License
protected Optional<List<SecurityGroup>> getSecurityGroupsForIds(final List<String> securityGroupIds, final CloudTrailEvent event) { Region region = getRegion(event); String accountId = getAccountId(event); AmazonEC2Client amazonEC2Client = getClient(accountId, region); if (amazonEC2Client == null) { throw new RuntimeException( String.format("Somehow we could not create an Client with accountId: %s and region: %s", accountId, region.toString())); } else {/* w w w. ja v a2 s . com*/ try { DescribeSecurityGroupsRequest request = new DescribeSecurityGroupsRequest(); request.setGroupIds(securityGroupIds); DescribeSecurityGroupsResult result = amazonEC2Client.describeSecurityGroups(request); return Optional.of(result.getSecurityGroups()); } catch (AmazonClientException e) { // TODO, better ways? String message = String.format("Unable to get SecurityGroups for SecurityGroupIds [%s] | %s", securityGroupIds.toString(), e.getMessage()); violationStore.save(new ViolationBuilder(message).withEvent(event).build()); return Optional.empty(); } } }
From source file:org.zalando.stups.fullstop.plugin.SaveSecurityGroupsPlugin.java
License:Apache License
public String getSecurityGroup(List<String> securityGroupIds, Region region, String accountId) { DescribeSecurityGroupsResult result = null; ObjectMapper objectMapper = new ObjectMapper(); String securityGroups = null; AmazonEC2Client amazonEC2Client = cachingClientProvider.getClient(AmazonEC2Client.class, accountId, region); if (amazonEC2Client == null) { throw new RuntimeException( String.format("Somehow we could not create an Client with accountId: %s and region: %s", accountId, region.toString())); } else {//from w w w. jav a2 s. co m try { DescribeSecurityGroupsRequest request = new DescribeSecurityGroupsRequest(); request.setGroupIds(securityGroupIds); result = amazonEC2Client.describeSecurityGroups(request); } catch (AmazonClientException e) { LOG.error(e.getMessage()); } try { securityGroups = objectMapper.writeValueAsString(result); } catch (JsonProcessingException e) { LOG.error(e.getMessage()); } return securityGroups; } }