/** * Creates an AmazonKinesis client. * @param configProps configuration properties containing the access key, secret key, and region * @return a new AmazonKinesis client */ public static AmazonKinesis createKinesisClient(Properties configProps) { // set a Flink-specific user agent ClientConfiguration awsClientConfig = new ClientConfigurationFactory().getConfig() .withUserAgentPrefix(String.format(USER_AGENT_FORMAT, EnvironmentInformation.getVersion(), EnvironmentInformation.getRevisionInformation().commitId)); // utilize automatic refreshment of credentials by directly passing the AWSCredentialsProvider AmazonKinesisClientBuilder builder = AmazonKinesisClientBuilder.standard() .withCredentials(AWSUtil.getCredentialsProvider(configProps)) .withClientConfiguration(awsClientConfig) .withRegion(Regions.fromName(configProps.getProperty(AWSConfigConstants.AWS_REGION))); if (configProps.containsKey(AWSConfigConstants.AWS_ENDPOINT)) { // Set signingRegion as null, to facilitate mocking Kinesis for local tests builder.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration( configProps.getProperty(AWSConfigConstants.AWS_ENDPOINT), null)); } return builder.build(); }
/** * Creates an Amazon Kinesis Client. * @param configProps configuration properties containing the access key, secret key, and region * @return a new Amazon Kinesis Client */ public static AmazonKinesisClient createKinesisClient(Properties configProps) { // set a Flink-specific user agent ClientConfiguration awsClientConfig = new ClientConfigurationFactory().getConfig(); awsClientConfig.setUserAgent("Apache Flink " + EnvironmentInformation.getVersion() + " (" + EnvironmentInformation.getRevisionInformation().commitId + ") Kinesis Connector"); // utilize automatic refreshment of credentials by directly passing the AWSCredentialsProvider AmazonKinesisClient client = new AmazonKinesisClient( AWSUtil.getCredentialsProvider(configProps), awsClientConfig); client.setRegion(Region.getRegion(Regions.fromName(configProps.getProperty(AWSConfigConstants.AWS_REGION)))); if (configProps.containsKey(AWSConfigConstants.AWS_ENDPOINT)) { client.setEndpoint(configProps.getProperty(AWSConfigConstants.AWS_ENDPOINT)); } return client; }
@SdkTestInternalApi AmazonS3Builder(SdkFunction<AmazonS3ClientParamsWrapper, AmazonS3> clientFactory, ClientConfigurationFactory clientConfigFactory, AwsRegionProvider regionProvider) { super(clientConfigFactory, regionProvider); this.clientFactory = clientFactory; }
/** * Get or initialize the S3 client. * Note: this method must be synchronized because we're accessing the * {@link #s3Client} field and we're calling this method from a worker thread. * @return the S3 client */ private synchronized AmazonS3 getS3Client() { if (s3Client == null) { BasicAWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey); AmazonS3ClientBuilder builder = AmazonS3ClientBuilder .standard() .withCredentials(new AWSStaticCredentialsProvider(credentials)); if (forceSignatureV2) { ClientConfigurationFactory configFactory = new ClientConfigurationFactory(); ClientConfiguration config = configFactory.getConfig(); config.setSignerOverride("S3SignerType"); builder = builder.withClientConfiguration(config); } String endpoint = "http://" + host + ":" + port; String clientRegion = null; if (!ServiceUtils.isS3USStandardEndpoint(endpoint)) { clientRegion = AwsHostNameUtils.parseRegion(host, AmazonS3Client.S3_SERVICE_NAME); } builder = builder.withEndpointConfiguration(new EndpointConfiguration( endpoint, clientRegion)); builder = builder.withPathStyleAccessEnabled(pathStyleAccess); s3Client = builder.build(); } return s3Client; }
/** * Create AWS client configuration and return it. * @return AWS client configuration */ private ClientConfiguration createClientConfiguration() { ClientConfigurationFactory configFactory = new ClientConfigurationFactory(); ClientConfiguration config = configFactory.getConfig(); String s3SignerOverride = conf.getS3SignerOverride(); if (StringUtils.isNotBlank(s3SignerOverride)) { config.setSignerOverride(s3SignerOverride); } return config; }
public static ClientConfiguration forAWS(@NotNull HttpUrl proxyUrl) { return new ClientConfigurationFactory().getConfig() .withProxyHost(proxyUrl.host()) .withProxyPort(proxyUrl.port()) .withProxyUsername(proxyUrl.username()) .withProxyPassword(proxyUrl.password()); }
protected AwsSyncClientBuilder(ClientConfigurationFactory clientConfigFactory) { super(clientConfigFactory); }
@SdkTestInternalApi protected AwsSyncClientBuilder(ClientConfigurationFactory clientConfigFactory, AwsRegionProvider regionProvider) { super(clientConfigFactory, regionProvider); }
protected AwsAsyncClientBuilder(ClientConfigurationFactory clientConfigFactory) { super(clientConfigFactory); }
@SdkTestInternalApi protected AwsAsyncClientBuilder(ClientConfigurationFactory clientConfigFactory, AwsRegionProvider regionProvider) { super(clientConfigFactory, regionProvider); }
protected AwsClientBuilder(ClientConfigurationFactory clientConfigFactory) { this(clientConfigFactory, DEFAULT_REGION_PROVIDER); }
@SdkTestInternalApi protected AwsClientBuilder(ClientConfigurationFactory clientConfigFactory, AwsRegionProvider regionProvider) { this.clientConfigFactory = clientConfigFactory; this.regionProvider = regionProvider; }
@SdkTestInternalApi AmazonS3ClientBuilder(SdkFunction<AmazonS3ClientParamsWrapper, AmazonS3> clientFactory, ClientConfigurationFactory clientConfigFactory, AwsRegionProvider regionProvider) { super(clientFactory, clientConfigFactory, regionProvider); }
private AmazonTestWebserviceClientBuilder() { super(new ClientConfigurationFactory()); }