From 97953534b96c9c10c4d6efc8ab02726e5f81e9c1 Mon Sep 17 00:00:00 2001 From: Alp Emre Elmas <62440706+alpemreelmas@users.noreply.github.com> Date: Sun, 24 Nov 2024 20:10:41 +0300 Subject: [PATCH] AYS-508 | Kinesis Integration & Removed DynamoDB Integration (#401) --- pom.xml | 8 +--- .../config/AysDynamoDBConfiguration.java | 48 ------------------- .../config/AysKinesisConfiguration.java | 34 +++++++++++++ src/main/resources/application-dynamodb.yml | 7 --- src/main/resources/application-kinesis.yml | 6 +++ 5 files changed, 41 insertions(+), 62 deletions(-) delete mode 100644 src/main/java/org/ays/common/config/AysDynamoDBConfiguration.java create mode 100644 src/main/java/org/ays/common/config/AysKinesisConfiguration.java delete mode 100644 src/main/resources/application-dynamodb.yml create mode 100644 src/main/resources/application-kinesis.yml diff --git a/pom.xml b/pom.xml index d3feb673..de2d08cc 100644 --- a/pom.xml +++ b/pom.xml @@ -204,13 +204,7 @@ software.amazon.awssdk - dynamodb - ${awsjavasdk.version} - - - - software.amazon.awssdk - dynamodb-enhanced + kinesis ${awsjavasdk.version} diff --git a/src/main/java/org/ays/common/config/AysDynamoDBConfiguration.java b/src/main/java/org/ays/common/config/AysDynamoDBConfiguration.java deleted file mode 100644 index bc96a656..00000000 --- a/src/main/java/org/ays/common/config/AysDynamoDBConfiguration.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.ays.common.config; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; -import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClient; -import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.dynamodb.DynamoDbClient; - -import java.net.URI; - -@Configuration -@Profile("dynamodb") -class AysDynamoDBConfiguration { - - @Value("${aws.dynamodb.region}") - private String region; - - @Value("${aws.dynamodb.endpoint}") - private String endpoint; - - @Value("${aws.credentials.access-key-id}") - private String accessKeyId; - - @Value("${aws.credentials.secret-access-key}") - private String secretAccessKey; - - @Bean - DynamoDbEnhancedClient dynamoDbEnhancedClient() { - - final AwsBasicCredentials credentials = AwsBasicCredentials - .create(this.accessKeyId, this.secretAccessKey); - - final DynamoDbClient dynamoDbClient = DynamoDbClient.builder() - .region(Region.of(this.region)) - .credentialsProvider(StaticCredentialsProvider.create(credentials)) - .endpointOverride(URI.create(this.endpoint)) - .build(); - - return DynamoDbEnhancedClient.builder() - .dynamoDbClient(dynamoDbClient) - .build(); - } - -} diff --git a/src/main/java/org/ays/common/config/AysKinesisConfiguration.java b/src/main/java/org/ays/common/config/AysKinesisConfiguration.java new file mode 100644 index 00000000..bc50343f --- /dev/null +++ b/src/main/java/org/ays/common/config/AysKinesisConfiguration.java @@ -0,0 +1,34 @@ +package org.ays.common.config; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; +import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; +import software.amazon.awssdk.regions.Region; +import software.amazon.awssdk.services.kinesis.KinesisClient; + +@Configuration +@Profile("kinesis") +public class AysKinesisConfiguration { + + @Value("${aws.credentials.access-key-id}") + private String accessKey; + + @Value("${aws.credentials.secret-access-key}") + private String secretKey; + + @Value("${aws.kinesis.region}") + private String region; + + @Bean + public KinesisClient kinesisClient() { + AwsBasicCredentials awsCredentials = AwsBasicCredentials.create(accessKey, secretKey); + + return KinesisClient.builder() + .credentialsProvider(StaticCredentialsProvider.create(awsCredentials)) + .region(Region.of(region)) + .build(); + } +} diff --git a/src/main/resources/application-dynamodb.yml b/src/main/resources/application-dynamodb.yml deleted file mode 100644 index b173e403..00000000 --- a/src/main/resources/application-dynamodb.yml +++ /dev/null @@ -1,7 +0,0 @@ -aws: - dynamodb: - region: ${AWS_DYNAMO_DB_REGION:} - endpoint: https://dynamodb.${AWS_DYNAMO_DB_REGION:}.amazonaws.com - credentials: - access-key-id: ${AWS_DYNAMO_DB_ACCESS_KEY_ID:} - secret-access-key: ${AWS_DYNAMO_DB_SECRET_ACCESS_KEY:} diff --git a/src/main/resources/application-kinesis.yml b/src/main/resources/application-kinesis.yml new file mode 100644 index 00000000..b6730580 --- /dev/null +++ b/src/main/resources/application-kinesis.yml @@ -0,0 +1,6 @@ +aws: + kinesis: + region: ${AWS_KINESIS_REGION:} + credentials: + access-key-id: ${AWS_KINESIS_ACCESS_KEY_ID:} + secret-access-key: ${AWS_KINESIS_SECRET_ACCESS_KEY:}