Example usage for com.amazonaws.services.kinesis AmazonKinesisClient withRegion

List of usage examples for com.amazonaws.services.kinesis AmazonKinesisClient withRegion

Introduction

In this page you can find the example usage for com.amazonaws.services.kinesis AmazonKinesisClient withRegion.

Prototype

@Deprecated
public <T extends AmazonWebServiceClient> T withRegion(Region region) 

Source Link

Document

Fluent method for #setRegion(Region) .

Usage

From source file:org.apache.beam.sdk.io.kinesis.TalendKinesisProvider.java

License:Open Source License

@Override
public AmazonKinesis get() {
    AWSCredentialsProviderChain credentials = null;
    if (specifyCredentials) {
        credentials = new AWSCredentialsProviderChain(new BasicAWSCredentialsProvider(accessKey, secretKey),
                new DefaultAWSCredentialsProviderChain(), new AnonymousAWSCredentialsProvider());
    } else {/*w  w  w .j  a  v  a2 s  . c  o m*/
        // do not be polluted by hidden accessKey/secretKey
        credentials = new AWSCredentialsProviderChain(new DefaultAWSCredentialsProviderChain(),
                new AnonymousAWSCredentialsProvider());
    }
    if (specifySTS) {
        STSAssumeRoleSessionCredentialsProvider.Builder builder = new STSAssumeRoleSessionCredentialsProvider.Builder(
                roleArn, roleSessionName).withLongLivedCredentialsProvider(credentials);
        if (specifyRoleExternalId) {
            builder = builder.withExternalId(roleExternalId);
        }
        if (specifySTSEndpoint) {
            builder = builder.withServiceEndpoint(stsEndpoint);
        }
        credentials = new AWSCredentialsProviderChain(builder.build());
    }
    AmazonKinesisClient client = new AmazonKinesisClient(credentials);
    client.withRegion(region);
    if (specifyEndpoint) {
        client.setEndpoint(endpoint);
    }
    return client;
}