use of com.amazonaws.auth.AWSCredentialsProvider in project presto by prestodb.
the class GlueHiveMetastore method createAsyncGlueClient.
private static AWSGlueAsync createAsyncGlueClient(GlueHiveMetastoreConfig config, RequestMetricCollector metricsCollector) {
ClientConfiguration clientConfig = new ClientConfiguration().withMaxConnections(config.getMaxGlueConnections()).withMaxErrorRetry(config.getMaxGlueErrorRetries());
AWSGlueAsyncClientBuilder asyncGlueClientBuilder = AWSGlueAsyncClientBuilder.standard().withMetricsCollector(metricsCollector).withClientConfiguration(clientConfig);
if (config.getGlueEndpointUrl().isPresent()) {
checkArgument(config.getGlueRegion().isPresent(), "Glue region must be set when Glue endpoint URL is set");
asyncGlueClientBuilder.setEndpointConfiguration(new EndpointConfiguration(config.getGlueEndpointUrl().get(), config.getGlueRegion().get()));
} else if (config.getGlueRegion().isPresent()) {
asyncGlueClientBuilder.setRegion(config.getGlueRegion().get());
} else if (config.getPinGlueClientToCurrentRegion()) {
Region currentRegion = Regions.getCurrentRegion();
if (currentRegion != null) {
asyncGlueClientBuilder.setRegion(currentRegion.getName());
}
}
if (config.getAwsAccessKey().isPresent() && config.getAwsSecretKey().isPresent()) {
AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(new BasicAWSCredentials(config.getAwsAccessKey().get(), config.getAwsSecretKey().get()));
asyncGlueClientBuilder.setCredentials(credentialsProvider);
} else if (config.getIamRole().isPresent()) {
AWSCredentialsProvider credentialsProvider = new STSAssumeRoleSessionCredentialsProvider.Builder(config.getIamRole().get(), "roleSessionName").build();
asyncGlueClientBuilder.setCredentials(credentialsProvider);
}
return asyncGlueClientBuilder.build();
}
use of com.amazonaws.auth.AWSCredentialsProvider in project flink by apache.
the class AWSUtilTest method testGetCredentialsProvider.
@Test
public void testGetCredentialsProvider() {
Properties testConfig = new Properties();
testConfig.setProperty(AWS_CREDENTIALS_PROVIDER, "WEB_IDENTITY_TOKEN");
AWSCredentialsProvider credentialsProvider = AWSUtil.getCredentialsProvider(testConfig);
assertTrue(credentialsProvider instanceof WebIdentityTokenCredentialsProvider);
}
use of com.amazonaws.auth.AWSCredentialsProvider in project flink by apache.
the class AWSUtilTest method testGetCredentialsProviderAuto.
@Test
public void testGetCredentialsProviderAuto() {
Properties testConfig = new Properties();
testConfig.setProperty(AWS_CREDENTIALS_PROVIDER, "AUTO");
AWSCredentialsProvider credentialsProvider = AWSUtil.getCredentialsProvider(testConfig);
assertTrue(credentialsProvider instanceof DefaultAWSCredentialsProviderChain);
}
use of com.amazonaws.auth.AWSCredentialsProvider in project flink by apache.
the class AWSUtilTest method testGetCredentialsProviderNamedProfile.
@Test
public void testGetCredentialsProviderNamedProfile() {
Properties testConfig = new Properties();
testConfig.setProperty(AWS_CREDENTIALS_PROVIDER, "PROFILE");
testConfig.setProperty(AWSConfigConstants.profileName(AWS_CREDENTIALS_PROVIDER), "foo");
testConfig.setProperty(AWSConfigConstants.profilePath(AWS_CREDENTIALS_PROVIDER), "src/test/resources/profile");
AWSCredentialsProvider credentialsProvider = AWSUtil.getCredentialsProvider(testConfig);
assertTrue(credentialsProvider instanceof ProfileCredentialsProvider);
AWSCredentials credentials = credentialsProvider.getCredentials();
assertEquals("22222222222222222222", credentials.getAWSAccessKeyId());
assertEquals("wJalrXUtnFEMI/K7MDENG/bPxRfiCY2222222222", credentials.getAWSSecretKey());
}
use of com.amazonaws.auth.AWSCredentialsProvider in project flink by apache.
the class DynamoDBStreamsProxy method createKinesisClient.
/**
* Creates an AmazonDynamoDBStreamsAdapterClient. Uses it as the internal client interacting
* with the DynamoDB streams.
*
* @param configProps configuration properties
* @return an AWS DynamoDB streams adapter client
*/
@Override
protected AmazonKinesis createKinesisClient(Properties configProps) {
ClientConfiguration awsClientConfig = new ClientConfigurationFactory().getConfig();
setAwsClientConfigProperties(awsClientConfig, configProps);
AWSCredentialsProvider credentials = getCredentialsProvider(configProps);
awsClientConfig.setUserAgentPrefix(String.format(USER_AGENT_FORMAT, EnvironmentInformation.getVersion(), EnvironmentInformation.getRevisionInformation().commitId));
AmazonDynamoDBStreamsAdapterClient adapterClient = new AmazonDynamoDBStreamsAdapterClient(credentials, awsClientConfig);
if (configProps.containsKey(AWS_ENDPOINT)) {
adapterClient.setEndpoint(configProps.getProperty(AWS_ENDPOINT));
} else {
adapterClient.setRegion(Region.getRegion(Regions.fromName(configProps.getProperty(AWS_REGION))));
}
return adapterClient;
}
Aggregations