Search in sources :

Example 1 with StaticCredentialsProvider

use of software.amazon.awssdk.auth.credentials.StaticCredentialsProvider 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());
}
Also used : StaticCredentialsProvider(software.amazon.awssdk.auth.credentials.StaticCredentialsProvider) AwsCredentials(software.amazon.awssdk.auth.credentials.AwsCredentials) AwsCredentialsProvider(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider) Test(org.junit.Test)

Example 2 with StaticCredentialsProvider

use of software.amazon.awssdk.auth.credentials.StaticCredentialsProvider in project beam by apache.

the class KinesisIOReadTest method testBuildWithBasicCredentials.

@Test
public void testBuildWithBasicCredentials() {
    Region region = Region.US_EAST_1;
    AwsBasicCredentials credentials = AwsBasicCredentials.create(KEY, SECRET);
    StaticCredentialsProvider credentialsProvider = StaticCredentialsProvider.create(credentials);
    Read read = KinesisIO.read().withAWSClientsProvider(KEY, SECRET, region);
    assertThat(read.getClientConfiguration()).isEqualTo(ClientConfiguration.create(credentialsProvider, region, null));
}
Also used : Read(org.apache.beam.sdk.io.aws2.kinesis.KinesisIO.Read) StaticCredentialsProvider(software.amazon.awssdk.auth.credentials.StaticCredentialsProvider) Region(software.amazon.awssdk.regions.Region) AwsBasicCredentials(software.amazon.awssdk.auth.credentials.AwsBasicCredentials) Test(org.junit.Test)

Example 3 with StaticCredentialsProvider

use of software.amazon.awssdk.auth.credentials.StaticCredentialsProvider in project beam by apache.

the class KinesisIOReadTest method testBuildWithBasicCredentialsAndCustomEndpoint.

@Test
public void testBuildWithBasicCredentialsAndCustomEndpoint() {
    String customEndpoint = "localhost:9999";
    Region region = Region.US_WEST_1;
    AwsBasicCredentials credentials = AwsBasicCredentials.create("key", "secret");
    StaticCredentialsProvider credentialsProvider = StaticCredentialsProvider.create(credentials);
    Read read = KinesisIO.read().withAWSClientsProvider(KEY, SECRET, region, customEndpoint);
    assertThat(read.getClientConfiguration()).isEqualTo(ClientConfiguration.create(credentialsProvider, region, URI.create(customEndpoint)));
}
Also used : Read(org.apache.beam.sdk.io.aws2.kinesis.KinesisIO.Read) StaticCredentialsProvider(software.amazon.awssdk.auth.credentials.StaticCredentialsProvider) Region(software.amazon.awssdk.regions.Region) AwsBasicCredentials(software.amazon.awssdk.auth.credentials.AwsBasicCredentials) Test(org.junit.Test)

Example 4 with StaticCredentialsProvider

use of software.amazon.awssdk.auth.credentials.StaticCredentialsProvider in project flink by apache.

the class GlueSchemaRegistryAvroKinesisITCase method setUp.

@Before
public void setUp() throws Exception {
    Assume.assumeTrue("Access key not configured, skipping test...", !StringUtils.isNullOrWhitespaceOnly(ACCESS_KEY));
    Assume.assumeTrue("Secret key not configured, skipping test...", !StringUtils.isNullOrWhitespaceOnly(SECRET_KEY));
    StaticCredentialsProvider gsrCredentialsProvider = StaticCredentialsProvider.create(AwsBasicCredentials.create(ACCESS_KEY, SECRET_KEY));
    Properties properties = KINESALITE.getContainerProperties();
    kinesisClient = new GSRKinesisPubsubClient(properties, gsrCredentialsProvider);
    kinesisClient.createStream(INPUT_STREAM, 2, properties);
    kinesisClient.createStream(OUTPUT_STREAM, 2, properties);
    System.setProperty(SdkSystemSetting.CBOR_ENABLED.property(), "false");
}
Also used : StaticCredentialsProvider(software.amazon.awssdk.auth.credentials.StaticCredentialsProvider) Properties(java.util.Properties) Before(org.junit.Before)

Example 5 with StaticCredentialsProvider

use of software.amazon.awssdk.auth.credentials.StaticCredentialsProvider in project flink by apache.

the class GlueSchemaRegistryJsonKinesisITCase method setUp.

@Before
public void setUp() throws Exception {
    Assume.assumeTrue("Access key not configured, skipping test...", !StringUtils.isNullOrWhitespaceOnly(ACCESS_KEY));
    Assume.assumeTrue("Secret key not configured, skipping test...", !StringUtils.isNullOrWhitespaceOnly(SECRET_KEY));
    StaticCredentialsProvider gsrCredentialsProvider = StaticCredentialsProvider.create(AwsBasicCredentials.create(ACCESS_KEY, SECRET_KEY));
    Properties properties = KINESALITE.getContainerProperties();
    kinesisClient = new GSRKinesisPubsubClient(properties, gsrCredentialsProvider);
    kinesisClient.createStream(INPUT_STREAM, 2, properties);
    kinesisClient.createStream(OUTPUT_STREAM, 2, properties);
    System.setProperty(SdkSystemSetting.CBOR_ENABLED.property(), "false");
}
Also used : StaticCredentialsProvider(software.amazon.awssdk.auth.credentials.StaticCredentialsProvider) Properties(java.util.Properties) Before(org.junit.Before)

Aggregations

StaticCredentialsProvider (software.amazon.awssdk.auth.credentials.StaticCredentialsProvider)5 Test (org.junit.Test)3 Properties (java.util.Properties)2 Read (org.apache.beam.sdk.io.aws2.kinesis.KinesisIO.Read)2 Before (org.junit.Before)2 AwsBasicCredentials (software.amazon.awssdk.auth.credentials.AwsBasicCredentials)2 Region (software.amazon.awssdk.regions.Region)2 AwsCredentials (software.amazon.awssdk.auth.credentials.AwsCredentials)1 AwsCredentialsProvider (software.amazon.awssdk.auth.credentials.AwsCredentialsProvider)1