List of usage examples for com.amazonaws.auth DefaultAWSCredentialsProviderChain DefaultAWSCredentialsProviderChain
public DefaultAWSCredentialsProviderChain()
From source file:com.mweagle.tereus.aws.CloudFormation.java
License:Open Source License
public Optional<DescribeStacksResult> updateStack(final UpdateStackRequest request, final Region awsRegion, Logger logger) {//from w ww. jav a 2 s . c o m DefaultAWSCredentialsProviderChain credentialProviderChain = new DefaultAWSCredentialsProviderChain(); final AmazonCloudFormationAsyncClient awsClient = new AmazonCloudFormationAsyncClient( credentialProviderChain.getCredentials()); awsClient.setRegion(awsRegion); logger.info("Updating stack: {}", request.getStackName()); Optional<DescribeStacksResult> completionResult = Optional.empty(); try { final List<StackEvent> priorEvents = getStackEvents(awsClient, request.getStackName(), logger); logger.info("Total number of pre-existing stack events: {}", priorEvents.size()); Future<UpdateStackResult> updateStackResult = awsClient.updateStackAsync(request); final UpdateStackResult stackResult = updateStackResult.get(); logger.info("Stack ({}) creation in progress.", stackResult.getStackId()); completionResult = waitForStackComplete(awsClient, request.getStackName(), priorEvents, logger); } catch (Exception ex) { logger.error(ex); } return completionResult; }
From source file:com.mweagle.tereus.aws.S3Resource.java
License:Open Source License
public boolean exists() { DefaultAWSCredentialsProviderChain credentialProviderChain = new DefaultAWSCredentialsProviderChain(); final AmazonS3Client awsClient = new AmazonS3Client(credentialProviderChain); try {/*from ww w . j a va2 s . c o m*/ awsClient.getObjectMetadata(bucketName, getS3Path()); } catch (AmazonServiceException e) { return false; } return true; }
From source file:com.mweagle.tereus.aws.S3Resource.java
License:Open Source License
public Optional<String> upload() { try {// w w w . j av a2 s .com DefaultAWSCredentialsProviderChain credentialProviderChain = new DefaultAWSCredentialsProviderChain(); final TransferManager transferManager = new TransferManager(credentialProviderChain.getCredentials()); final ObjectMetadata metadata = new ObjectMetadata(); if (this.inputStreamLength.isPresent()) { metadata.setContentLength(this.inputStreamLength.get()); } final PutObjectRequest uploadRequest = new PutObjectRequest(bucketName, keyName, this.inputStream, metadata); final Upload templateUpload = transferManager.upload(uploadRequest); templateUpload.waitForUploadResult(); this.resourceURL = Optional.of(getS3Path()); } catch (Exception ex) { throw new RuntimeException(ex); } return this.resourceURL; }
From source file:com.mweagle.tereus.aws.S3Resource.java
License:Open Source License
@Override public void close() { if (!this.released && this.resourceURL.isPresent()) { DefaultAWSCredentialsProviderChain credentialProviderChain = new DefaultAWSCredentialsProviderChain(); final AmazonS3Client awsClient = new AmazonS3Client(credentialProviderChain); final String[] parts = this.resourceURL.get().split("/"); final String keyname = parts[parts.length - 1]; awsClient.deleteObject(bucketName, keyname); }//from w ww . j av a 2 s.c om }
From source file:com.mweagle.tereus.input.TereusAWSInput.java
License:Open Source License
public TereusAWSInput(final String awsRegion, final boolean dryRun, final String loggerName) { this.awsRegion = (null != awsRegion) ? Region.getRegion(Regions.fromName(awsRegion)) : Region.getRegion(Regions.US_EAST_1); this.dryRun = dryRun; DefaultAWSCredentialsProviderChain credentialProviderChain = new DefaultAWSCredentialsProviderChain(); this.awsCredentials = credentialProviderChain.getCredentials(); this.logger = LogManager.getLogger(loggerName); }
From source file:com.netflix.atlas.client.CloudWatchObserver.java
License:Apache License
/** * Create the observer with a given configuration. *//*from w ww. j a v a 2 s .co m*/ public CloudWatchObserver(PluginConfig config, PushManager pushManager) { this.config = config; this.pushManager = pushManager; final AWSCredentialsProvider credentialsProvider = new DefaultAWSCredentialsProviderChain(); final AmazonCloudWatchClient cloudWatchClient = new AmazonCloudWatchClient(credentialsProvider); final String region = NetflixEnvironment.region(); if (region != null) { cloudWatchClient.setEndpoint(String.format("monitoring.%s.amazonaws.com", region)); } this.cloudWatchMetricObserver = new CloudWatchMetricObserver(getName(), config.getCloudwatchNamespace(), cloudWatchClient); }
From source file:com.netflix.exhibitor.core.s3.DefaultS3CredentialsProviderImpl.java
License:Apache License
public DefaultS3CredentialsProviderImpl() { this(new DefaultAWSCredentialsProviderChain()); }
From source file:com.netflix.iep.aws.AwsClientFactory.java
License:Apache License
AWSCredentialsProvider createCredentialsProvider(String name, String accountId) { final AWSCredentialsProvider dflt = new DefaultAWSCredentialsProviderChain(); final Config cfg = getConfig(name, "credentials"); if (cfg.hasPath("role-arn")) { return createAssumeRoleProvider(cfg, accountId, dflt); } else {// www . j a v a 2 s .c o m if (accountId != null) { LOGGER.warn("requested account, {}, ignored, no role ARN configured", accountId); } return dflt; } }
From source file:com.netflix.servo.tag.aws.AwsInjectableTag.java
License:Apache License
static String getAutoScaleGroup() { try {/* w ww . j ava 2 s . c o m*/ String credFileProperty = System.getProperties().getProperty(AwsPropertyKeys.awsCredentialsFile); AWSCredentials credentials; if (credFileProperty != null) { credentials = new PropertiesCredentials(new File(credFileProperty)); } else { credentials = new DefaultAWSCredentialsProviderChain().getCredentials(); } AmazonAutoScaling autoScalingClient = new AmazonAutoScalingClient(credentials); return autoScalingClient .describeAutoScalingInstances( new DescribeAutoScalingInstancesRequest().withInstanceIds(getInstanceId())) .getAutoScalingInstances().get(0).getAutoScalingGroupName(); } catch (Exception e) { log.error("Unable to get ASG name.", e); return undefined; } }
From source file:com.netflix.simianarmy.aws.AWSClient.java
License:Apache License
/** * This constructor will use the {@link DefaultAWSCredentialsProviderChain} to obtain credentials. * * @param region/*from w ww . ja va 2 s . co m*/ * the region */ public AWSClient(String region) { this(new DefaultAWSCredentialsProviderChain().getCredentials(), region); }