List of usage examples for com.amazonaws.regions Region getRegion
public static Region getRegion(Regions region)
From source file:com.nandanu.halomama.controller.AmazonClientManager.java
License:Open Source License
private void initClients() { // CognitoCachingCredentialsProvider credentials = new // CognitoCachingCredentialsProvider( // context, Constants.AWS_ACCOUNT_ID, Constants.COGNITO_POOL_ID, // Constants.COGNITO_ROLE_UNAUTH, null, Constants.COGNITO_REGION); CognitoCachingCredentialsProvider credentials = new CognitoCachingCredentialsProvider(context, Constants.AWS_ACCOUNT_ID, Constants.COGNITO_POOL_ID, Constants.COGNITO_ROLE_UNAUTH, null, Constants.COGNITO_REGION);//from w ww. java 2s. c om ddb = new AmazonDynamoDBClient(credentials); ddb.setRegion(Region.getRegion(Constants.DDB_REGION)); identityId = credentials.getIdentityId(); }
From source file:com.netflix.amazoncomponents.security.AmazonClientProvider.java
License:Apache License
public AmazonSimpleWorkflow getAmazonSimpleWorkflow(AWSCredentialsProviderChain providerChain, String region) { if (providerChain == null) { throw new IllegalArgumentException("Provider chain cannot be null"); }/*from w w w.j ava 2 s .co m*/ AmazonSimpleWorkflowClient client = new AmazonSimpleWorkflowClient(providerChain); if (region != null && region.length() > 0) { client.setRegion(Region.getRegion(Regions.fromName(region))); } return client; }
From source file:com.netflix.amazoncomponents.security.AmazonClientProvider.java
License:Apache License
protected <T extends AmazonWebServiceClient> T getClient(Class<T> impl, AmazonCredentials amazonCredentials, String region) throws IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException {/* w w w.j a v a 2 s. co m*/ Constructor<T> constructor = impl.getConstructor(AWSCredentials.class); T delegate = constructor.newInstance(amazonCredentials.getCredentials()); if (region != null && region.length() > 0) { delegate.setRegion(Region.getRegion(Regions.fromName(region))); } return delegate; }
From source file:com.netflix.bluespar.amazon.security.AmazonClientProvider.java
License:Apache License
public AmazonRoute53 getAmazonRoute53(AmazonCredentials credentials, String region) { AmazonRoute53Client amazonRoute53 = new AmazonRoute53Client(credentials.getCredentials()); if (region != null && region.length() > 0) { amazonRoute53.setRegion(Region.getRegion(Regions.fromName(region))); }/*from w w w. j a va 2 s. co m*/ return amazonRoute53; }
From source file:com.netflix.bluespar.amazon.security.AmazonClientProvider.java
License:Apache License
public AmazonElasticLoadBalancing getAmazonElasticLoadBalancing(AmazonCredentials credentials, String region) { AmazonElasticLoadBalancingClient amazonElasticLoadBalancing = new AmazonElasticLoadBalancingClient( credentials.getCredentials()); if (region != null && region.length() > 0) { amazonElasticLoadBalancing.setRegion(Region.getRegion(Regions.fromName(region))); }// w w w . j a v a2s. c o m return amazonElasticLoadBalancing; }
From source file:com.netflix.bluespar.amazon.security.AmazonClientProvider.java
License:Apache License
private GeneralAmazonClientInvocationHandler getInvocationHandler(AmazonWebServiceClient client, String region, AmazonCredentials amazonCredentials) { if (region != null && region.length() > 0) { client.setRegion(Region.getRegion(Regions.fromName(region))); }//www . j av a2s .com return new GeneralAmazonClientInvocationHandler(client, String.format(edda, region, amazonCredentials.getEnvironment()), this.httpClient == null ? new DefaultHttpClient() : this.httpClient, objectMapper); }
From source file:com.netflix.spinnaker.clouddriver.aws.security.AmazonClientProvider.java
License:Apache License
protected <T extends AmazonWebServiceClient> T getClient(Class<T> impl, AWSCredentialsProvider awsCredentialsProvider, String region) { checkAWSCredentialsProvider(awsCredentialsProvider); try {//from w ww .j a v a 2 s .c o m Constructor<T> constructor = impl.getConstructor(AWSCredentialsProvider.class, ClientConfiguration.class); ClientConfiguration clientConfiguration = new ClientConfiguration(); if (awsCredentialsProvider instanceof NetflixSTSAssumeRoleSessionCredentialsProvider) { RetryPolicy.RetryCondition delegatingRetryCondition = (originalRequest, exception, retriesAttempted) -> { NetflixSTSAssumeRoleSessionCredentialsProvider stsCredentialsProvider = (NetflixSTSAssumeRoleSessionCredentialsProvider) awsCredentialsProvider; if (exception instanceof AmazonServiceException) { ((AmazonServiceException) exception).getHttpHeaders().put("targetAccountId", stsCredentialsProvider.getAccountId()); } return retryPolicy.getRetryCondition().shouldRetry(originalRequest, exception, retriesAttempted); }; RetryPolicy delegatingRetryPolicy = new RetryPolicy(delegatingRetryCondition, retryPolicy.getBackoffStrategy(), retryPolicy.getMaxErrorRetry(), retryPolicy.isMaxErrorRetryInClientConfigHonored()); clientConfiguration.setRetryPolicy(delegatingRetryPolicy); } else { clientConfiguration.setRetryPolicy(retryPolicy); } if (proxy != null && proxy.isProxyConfigMode()) { proxy.apply(clientConfiguration); } clientConfiguration.setUseGzip(useGzip); T delegate = constructor.newInstance(awsCredentialsProvider, clientConfiguration); for (RequestHandler2 requestHandler : requestHandlers) { delegate.addRequestHandler(requestHandler); } if (region != null && region.length() > 0) { delegate.setRegion(Region.getRegion(Regions.fromName(region))); } return delegate; } catch (Exception e) { throw new RuntimeException("Instantiation of client implementation failed!", e); } }
From source file:com.nextdoor.bender.config.value.KmsValueConfig.java
License:Apache License
public String getValue() { if (this.value == null) { return value; }/* w ww. j a v a 2 s .c o m*/ /* * Ensure that the value is only decrypted once regardless of usage. This prevents KMS from * being called over and over from within the function to decrypt the same field. */ if (!this.decrypted) { try { this.value = Passwords.decrypt(this.value, Region.getRegion(this.region)); } catch (UnsupportedEncodingException e) { throw new ConfigurationException("Unable to decrypt", e); } this.decrypted = true; } return this.value; }
From source file:com.nike.cerberus.aws.KmsClientFactory.java
License:Apache License
/** * Returns a KMS client for the given region name. Clients are cached by region. * * @param regionName Region to configure a client for * @return AWS KMS client/*from w w w. j a v a2 s. c o m*/ */ public AWSKMSClient getClient(String regionName) { try { final Region region = Region.getRegion(Regions.fromName(regionName)); return getClient(region); } catch (IllegalArgumentException iae) { throw new IllegalArgumentException("Specified region is not valid.", iae); } }
From source file:com.nike.cerberus.config.CmsEnvPropertiesLoader.java
License:Apache License
public CmsEnvPropertiesLoader(final String bucketName, final String region, final String kmsKeyId) { final KMSEncryptionMaterialsProvider materialProvider = new KMSEncryptionMaterialsProvider(kmsKeyId); this.s3Client = new AmazonS3EncryptionClient(new DefaultAWSCredentialsProviderChain(), materialProvider, new CryptoConfiguration().withAwsKmsRegion(Region.getRegion(Regions.fromName(region)))) .withRegion(Region.getRegion(Regions.fromName(region))); this.bucketName = bucketName; }