public com.amazonaws.services.kinesis.AmazonKinesis build(AmazonKinesis kinesisProperties) { com.amazonaws.services.kinesis.AmazonKinesisClientBuilder clientBuilder = com.amazonaws.services.kinesis.AmazonKinesisClientBuilder.standard(); clientBuilder.setRegion(kinesisProperties.getRegion()); clientBuilder.setCredentials(new AWSCredentialsProvider() { @Override public AWSCredentials getCredentials() { return new BasicAWSCredentials(kinesisProperties.getKey(), kinesisProperties.getSecret()); } @Override public void refresh() { } }); clientBuilder.setClientConfiguration(new ClientConfiguration()); return clientBuilder.build(); }
/** * 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(); }
/** * Loads the test-specific Log4J configuration and resets the environment. */ public void setUp(String propertiesName, String streamName) throws Exception { URL config = ClassLoader.getSystemResource(propertiesName); assertNotNull("missing configuration: " + propertiesName, config); LogManager.resetConfiguration(); PropertyConfigurator.configure(config); localLogger = Logger.getLogger(getClass()); localClient = AmazonKinesisClientBuilder.defaultClient(); deleteStreamIfExists(streamName); }
@Override public AmazonKinesis create(KinesisSourceConnectorConfig config) { AmazonKinesisClientBuilder builder = AmazonKinesisClient.builder() .withCredentials(config.awsCredentialsProvider()) .withRegion(config.kinesisRegion); return builder.build(); }
@Override public AmazonKinesis getKinesisClient() { AmazonKinesisClientBuilder clientBuilder = AmazonKinesisClientBuilder.standard().withCredentials(getCredentialsProvider()); if (serviceEndpoint == null) { clientBuilder.withRegion(region); } else { clientBuilder.withEndpointConfiguration( new AwsClientBuilder.EndpointConfiguration(serviceEndpoint, region.getName())); } return clientBuilder.build(); }
private static AmazonKinesis getKinesisClient(ClientConfiguration awsClientConfig, KinesisConfigBean conf) throws StageException { AmazonKinesisClientBuilder builder = AmazonKinesisClientBuilder .standard() .withClientConfiguration(checkNotNull(awsClientConfig)) .withCredentials(AWSUtil.getCredentialsProvider(conf.awsConfig)); if (AWSRegions.OTHER == conf.region) { builder.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(conf.endpoint, null)); } else { builder.withRegion(conf.region.getLabel()); } return builder.build(); }
@BeforeClass public void beforeClass() { String awsRegion = "us-east-1"; String awsAccessKeyId = "<access key id>"; String awsSecretAccessKey = "<secret access key>"; BasicAWSCredentials basicAWSCredentials = new BasicAWSCredentials(awsAccessKeyId, awsSecretAccessKey); client = AmazonKinesisClientBuilder.standard() .withCredentials(new AWSStaticCredentialsProvider(basicAWSCredentials)) .withRegion(awsRegion) .build(); }
public static AmazonKinesisClient createKinesisClient() { BasicCredentialsProvider credentials = BasicCredentialsProvider.standard(); AmazonKinesisClient client = !credentials.isValid() ? null : (AmazonKinesisClient) AmazonKinesisClientBuilder.standard() .withCredentials(credentials) .withRegion("eu-west-1").build(); return client; }
public WatermarkTracker(String region, String streamName) { this.streamName = streamName; this.kinesisClient = AmazonKinesisClientBuilder.standard().withRegion(region).build(); }
/** * Factory method called by smoketest */ public static AmazonKinesis createClient() { return AmazonKinesisClientBuilder.defaultClient(); }
public void setClientBuilder(AmazonKinesisClientBuilder clientBuilder) { this.clientBuilder = clientBuilder; }