use of software.amazon.awssdk.auth.credentials.AwsCredentials in project flink by apache.
the class AWSGeneralUtilTest method testGetCredentialsProviderNamedProfile.
@Test
public void testGetCredentialsProviderNamedProfile() {
Properties properties = TestUtil.properties(AWS_CREDENTIALS_PROVIDER, "PROFILE");
properties.setProperty(AWSConfigConstants.profileName(AWS_CREDENTIALS_PROVIDER), "foo");
properties.setProperty(AWSConfigConstants.profilePath(AWS_CREDENTIALS_PROVIDER), "src/test/resources/profile");
AwsCredentialsProvider credentialsProvider = AWSGeneralUtil.getCredentialsProvider(properties);
assertTrue(credentialsProvider instanceof ProfileCredentialsProvider);
AwsCredentials credentials = credentialsProvider.resolveCredentials();
assertEquals("22222222222222222222", credentials.accessKeyId());
assertEquals("wJalrXUtnFEMI/K7MDENG/bPxRfiCY2222222222", credentials.secretAccessKey());
}
use of software.amazon.awssdk.auth.credentials.AwsCredentials in project flink by apache.
the class AWSGeneralUtilTest method testGetCredentialsProviderBasic.
@Test
public void testGetCredentialsProviderBasic() {
Properties properties = TestUtil.properties(AWS_CREDENTIALS_PROVIDER, "BASIC");
properties.setProperty(AWSConfigConstants.accessKeyId(AWS_CREDENTIALS_PROVIDER), "ak");
properties.setProperty(AWSConfigConstants.secretKey(AWS_CREDENTIALS_PROVIDER), "sk");
AwsCredentials credentials = AWSGeneralUtil.getCredentialsProvider(properties).resolveCredentials();
assertEquals("ak", credentials.accessKeyId());
assertEquals("sk", credentials.secretAccessKey());
}
use of software.amazon.awssdk.auth.credentials.AwsCredentials in project flink by apache.
the class AWSGeneralUtilTest method testGetCredentialsProviderProfile.
@Test
public void testGetCredentialsProviderProfile() {
Properties properties = TestUtil.properties(AWS_CREDENTIALS_PROVIDER, "PROFILE");
properties.put(AWSConfigConstants.profileName(AWS_CREDENTIALS_PROVIDER), "default");
properties.put(AWSConfigConstants.profilePath(AWS_CREDENTIALS_PROVIDER), "src/test/resources/profile");
AwsCredentialsProvider credentialsProvider = AWSGeneralUtil.getCredentialsProvider(properties);
assertTrue(credentialsProvider instanceof ProfileCredentialsProvider);
AwsCredentials credentials = credentialsProvider.resolveCredentials();
assertEquals("11111111111111111111", credentials.accessKeyId());
assertEquals("wJalrXUtnFEMI/K7MDENG/bPxRfiCY1111111111", credentials.secretAccessKey());
}
use of software.amazon.awssdk.auth.credentials.AwsCredentials in project beam by apache.
the class AwsSerializableUtilsTest method testAwsCredentialsProviderSerialization.
@Test
public void testAwsCredentialsProviderSerialization() {
AwsCredentialsProvider awsCredentialsProvider = StaticCredentialsProvider.create(AwsBasicCredentials.create(ACCESS_KEY_ID, SECRET_ACCESS_KEY));
String awsCredentialsProviderSerialized = AwsSerializableUtils.serializeAwsCredentialsProvider(awsCredentialsProvider);
AwsCredentialsProvider awsCredentialsProviderDeserialized = AwsSerializableUtils.deserializeAwsCredentialsProvider(awsCredentialsProviderSerialized);
assertTrue(awsCredentialsProviderDeserialized instanceof StaticCredentialsProvider);
AwsCredentials awsCredentials = awsCredentialsProviderDeserialized.resolveCredentials();
assertEquals(ACCESS_KEY_ID, awsCredentials.accessKeyId());
assertEquals(SECRET_ACCESS_KEY, awsCredentials.secretAccessKey());
}
use of software.amazon.awssdk.auth.credentials.AwsCredentials in project beam by apache.
the class KinesisIOIT method runWrite.
/**
* Write test dataset into Kinesis stream.
*/
private void runWrite() {
ITOptions options = env.options();
AwsCredentials credentials = options.getAwsCredentialsProvider().resolveCredentials();
writePipeline.apply("Generate Sequence", GenerateSequence.from(0).to(options.getNumberOfRows())).apply("Prepare TestRows", ParDo.of(new TestRow.DeterministicallyConstructTestRowFn())).apply("Prepare Kinesis input records", ParDo.of(new ConvertToBytes())).apply("Write to Kinesis", org.apache.beam.sdk.io.kinesis.KinesisIO.write().withStreamName(options.getKinesisStream()).withPartitioner(new RandomPartitioner()).withAWSClientsProvider(credentials.accessKeyId(), credentials.secretAccessKey(), Regions.fromName(options.getAwsRegion().id()), options.getEndpoint() != null ? options.getEndpoint().toString() : null, !options.getUseLocalstack()));
writePipeline.run().waitUntilFinish();
}
Aggregations