com.amazonaws.regions.Region r = Regions.getCurrentRegion();
/** create a task statistics store for the given queue name */ public SQSTaskStatisticsStore(String queueName) { Region current = Regions.getCurrentRegion(); if (current != null) { LOG.info("Assuming statistics queue is in region {}", current); sqs.setEndpoint("sqs." + current.toString() + ".amazonaws.com"); } try { queueUrl = sqs.getQueueUrl(queueName).getQueueUrl(); } catch (Exception e) { LOG.error("Unable to initialize statistics store", e); } LOG.info("Sending statistics to SQS queue {}", queueName); }
/** * Configuring the CloudWatch client. * * Credentials are loaded from the Amazon EC2 Instance Metadata Service */ private AmazonCloudWatchClient createCloudWatchClient() { AmazonCloudWatchClient cloudWatchClient = new AmazonCloudWatchClient(new InstanceProfileCredentialsProvider()); cloudWatchClient.setRegion(checkNotNull(Regions.getCurrentRegion(), "Problems getting AWS metadata")); return cloudWatchClient; }
private static AWSGlueAsync createAsyncGlueClient(GlueHiveMetastoreConfig config) { ClientConfiguration clientConfig = new ClientConfiguration().withMaxConnections(config.getMaxGlueConnections()); AWSGlueAsyncClientBuilder asyncGlueClientBuilder = AWSGlueAsyncClientBuilder.standard() .withClientConfiguration(clientConfig); if (config.getGlueRegion().isPresent()) { asyncGlueClientBuilder.setRegion(config.getGlueRegion().get()); } else if (config.getPinGlueClientToCurrentRegion()) { Region currentRegion = Regions.getCurrentRegion(); if (currentRegion != null) { asyncGlueClientBuilder.setRegion(currentRegion.getName()); } } return asyncGlueClientBuilder.build(); }
Region region = Regions.getCurrentRegion(); if (region != null) { clientBuilder.withRegion(region.getName());
Region region = Regions.getCurrentRegion(); if (region != null) { clientBuilder = clientBuilder.withRegion(region.getName());
@Override public String getRegion() throws SdkClientException { return Regions.getCurrentRegion().getName(); } }
@Provides @Singleton protected Region provideAmazonRegion() { return Objects.firstNonNull(Regions.getCurrentRegion(), Region.getRegion(Regions.US_EAST_1)); }
@ConditionalOnMissingBean(name = "elasticsearchJestAwsRegion") @Bean(name = "elasticsearchJestAwsRegion") public String regionFromEC2() { // Try to determine current region ( work on EC2 instance ) Region region = Regions.getCurrentRegion(); if (region != null) { return region.getName(); } // Nothing else , back to default return Regions.DEFAULT_REGION.getName(); }
CLOUDWATCH.get().setRegion(Regions.getCurrentRegion() == null ? Region.getRegion(Regions.US_EAST_1) : Regions.getCurrentRegion());
/** * Constructor with default CloudWatch client and default DynamoDBAsync. * * @param configuration * The configuration for this emitter. * @deprecated Deprecated by {@link #DynamoDBReplicationEmitter(DynamoDBStreamsConnectorConfiguration, AmazonDynamoDBAsync, AmazonCloudWatchAsync)} */ @Deprecated public DynamoDBReplicationEmitter(final DynamoDBStreamsConnectorConfiguration configuration) { this(configuration.APP_NAME, configuration.DYNAMODB_ENDPOINT, configuration.REGION_NAME, configuration.DYNAMODB_DATA_TABLE_NAME, (AmazonCloudWatchAsync) new AmazonCloudWatchAsyncClient(new DefaultAWSCredentialsProviderChain(), Executors.newFixedThreadPool(MAX_THREADS)).withRegion(Regions.getCurrentRegion() == null ? Region.getRegion(Regions.US_EAST_1) : Regions.getCurrentRegion()), new DefaultAWSCredentialsProviderChain()); }
/** * Configuring the CloudWatch client. * * Credentials are loaded from the Amazon EC2 Instance Metadata Service */ private AmazonCloudWatchClient createCloudWatchClient() { AmazonCloudWatchClient cloudWatchClient = new AmazonCloudWatchClient(new InstanceProfileCredentialsProvider()); cloudWatchClient.setRegion(checkNotNull(Regions.getCurrentRegion(), "Problems getting AWS metadata")); return cloudWatchClient; }
private static Region getStartingRegion(final String keyArn) { final String region = parseRegionfromKeyArn(keyArn); if (region != null) { return RegionUtils.getRegion(region); } final Region currentRegion = Regions.getCurrentRegion(); if (currentRegion != null) { return currentRegion; } return Region.getRegion(Regions.DEFAULT_REGION); }
} else { if (StringUtils.isNullOrEmpty(region)) { com.amazonaws.regions.Region s3Region = Regions.getCurrentRegion(); if (s3Region != null) { region = s3Region.getName();
private static AWSGlueAsync createAsyncGlueClient(GlueHiveMetastoreConfig config) { ClientConfiguration clientConfig = new ClientConfiguration().withMaxConnections(config.getMaxGlueConnections()); AWSGlueAsyncClientBuilder asyncGlueClientBuilder = AWSGlueAsyncClientBuilder.standard() .withClientConfiguration(clientConfig); if (config.getGlueRegion().isPresent()) { asyncGlueClientBuilder.setRegion(config.getGlueRegion().get()); } else if (config.getPinGlueClientToCurrentRegion()) { Region currentRegion = Regions.getCurrentRegion(); if (currentRegion != null) { asyncGlueClientBuilder.setRegion(currentRegion.getName()); } } return asyncGlueClientBuilder.build(); }
val currentRegion = Regions.getCurrentRegion(); if (currentRegion != null && StringUtils.isBlank(region)) { region = currentRegion.getName();
/** * Determine region. If not specified tries to determine region from where the * application is running or fall back to the default. * * @return Region to configure the client */ private Region findRegion() { boolean regionProvided = !Validator.isBlank(this.region); if(!regionProvided) { // Determine region from where application is running, or fall back to default region Region currentRegion = Regions.getCurrentRegion(); if(currentRegion != null) { return currentRegion; } return Region.getRegion(Regions.fromName(AppenderConstants.DEFAULT_REGION)); } return Region.getRegion(Regions.fromName(this.region)); }
private static Region getRegion(EnvVars vars) { if (vars.get(AWS_DEFAULT_REGION) != null) { return Region.getRegion(Regions.fromName(vars.get(AWS_DEFAULT_REGION))); } if (vars.get(AWS_REGION) != null) { return Region.getRegion(Regions.fromName(vars.get(AWS_REGION))); } if (System.getenv(AWS_DEFAULT_REGION) != null) { return Region.getRegion(Regions.fromName(System.getenv(AWS_DEFAULT_REGION))); } if (System.getenv(AWS_REGION) != null) { return Region.getRegion(Regions.fromName(System.getenv(AWS_REGION))); } Region currentRegion = Regions.getCurrentRegion(); if (currentRegion != null) { return currentRegion; } return Region.getRegion(Regions.DEFAULT_REGION); } }
private AmazonS3Client createAmazonS3Client(URI uri, Configuration hadoopConfig, ClientConfiguration clientConfig) { AWSCredentialsProvider credentials = getAwsCredentialsProvider(uri, hadoopConfig); EncryptionMaterialsProvider emp = createEncryptionMaterialsProvider(hadoopConfig); AmazonS3Client client; if (emp != null) { client = new AmazonS3EncryptionClient(credentials, emp, clientConfig, new CryptoConfiguration(), METRIC_COLLECTOR); } else { client = new AmazonS3Client(credentials, clientConfig, METRIC_COLLECTOR); } // use local region when running inside of EC2 if (pinS3ClientToCurrentRegion) { Region region = Regions.getCurrentRegion(); if (region != null) { client.setRegion(region); } } return client; }
Region region = Regions.getCurrentRegion(); if (region != null) { clientBuilder = clientBuilder.withRegion(region.getName());