Skip to content

Commit 7dd85d2

Browse files
committed
Move DDB out
1 parent a357255 commit 7dd85d2

File tree

11 files changed

+132
-53
lines changed

11 files changed

+132
-53
lines changed

pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@
5555
<module>powertools-batch</module>
5656
<module>examples</module>
5757
<module>powertools-parameters/powertools-parameters-ssm</module>
58-
<module>powertools-parameters/powertools-parameters-tests</module>
5958
<module>powertools-parameters/powertools-parameters-secrets</module>
59+
<module>powertools-parameters/powertools-parameters-dynamodb</module>
60+
<module>powertools-parameters/powertools-parameters-tests</module>
6061
</modules>
6162

6263
<scm>

powertools-parameters/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@
6262
<groupId>software.amazon.awssdk</groupId>
6363
<artifactId>url-connection-client</artifactId>
6464
</dependency>
65-
<dependency>
66-
<groupId>software.amazon.awssdk</groupId>
67-
<artifactId>dynamodb</artifactId>
68-
</dependency>
6965
<dependency>
7066
<groupId>software.amazon.awssdk</groupId>
7167
<artifactId>appconfigdata</artifactId>
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>software.amazon.lambda</groupId>
9+
<artifactId>powertools-parent</artifactId>
10+
<version>2.0.0-SNAPSHOT</version>
11+
<relativePath>../../pom.xml</relativePath>
12+
</parent>
13+
14+
<artifactId>powertools-parameters-dynamodb</artifactId>
15+
<name>Powertools for AWS Lambda (Java) library Parameters - DynamoDB</name>
16+
<description>DynamoDB implementation for the Parameters module</description>
17+
18+
<issueManagement>
19+
<system>GitHub Issues</system>
20+
<url>https://github.com/aws-powertools/powertools-lambda-java/issues</url>
21+
</issueManagement>
22+
<scm>
23+
<url>https://github.com/aws-powertools/powertools-lambda-java.git</url>
24+
</scm>
25+
<developers>
26+
<developer>
27+
<name>Powertools for AWS Lambda team</name>
28+
<organization>Amazon Web Services</organization>
29+
<organizationUrl>https://aws.amazon.com/</organizationUrl>
30+
</developer>
31+
</developers>
32+
33+
<distributionManagement>
34+
<snapshotRepository>
35+
<id>ossrh</id>
36+
<url>https://aws.oss.sonatype.org/content/repositories/snapshots</url>
37+
</snapshotRepository>
38+
</distributionManagement>
39+
40+
<dependencies>
41+
<dependency>
42+
<groupId>software.amazon.lambda</groupId>
43+
<artifactId>powertools-parameters</artifactId>
44+
<version>${project.version}</version>
45+
</dependency>
46+
47+
<dependency>
48+
<groupId>software.amazon.awssdk</groupId>
49+
<artifactId>dynamodb</artifactId>
50+
<exclusions>
51+
<exclusion>
52+
<groupId>software.amazon.awssdk</groupId>
53+
<artifactId>apache-client</artifactId>
54+
</exclusion>
55+
<exclusion>
56+
<groupId>software.amazon.awssdk</groupId>
57+
<artifactId>netty-nio-client</artifactId>
58+
</exclusion>
59+
</exclusions>
60+
</dependency>
61+
62+
<!-- Test dependencies -->
63+
<dependency>
64+
<groupId>org.junit.jupiter</groupId>
65+
<artifactId>junit-jupiter-api</artifactId>
66+
<scope>test</scope>
67+
</dependency>
68+
<dependency>
69+
<groupId>org.junit.jupiter</groupId>
70+
<artifactId>junit-jupiter-engine</artifactId>
71+
<scope>test</scope>
72+
</dependency>
73+
<dependency>
74+
<groupId>org.mockito</groupId>
75+
<artifactId>mockito-core</artifactId>
76+
<scope>test</scope>
77+
</dependency>
78+
<dependency>
79+
<groupId>org.mockito</groupId>
80+
<artifactId>mockito-inline</artifactId>
81+
<scope>test</scope>
82+
</dependency>
83+
<dependency>
84+
<groupId>org.apache.commons</groupId>
85+
<artifactId>commons-lang3</artifactId>
86+
<scope>test</scope>
87+
</dependency>
88+
<dependency>
89+
<groupId>org.assertj</groupId>
90+
<artifactId>assertj-core</artifactId>
91+
<scope>test</scope>
92+
</dependency>
93+
<dependency>
94+
<groupId>org.aspectj</groupId>
95+
<artifactId>aspectjweaver</artifactId>
96+
<scope>test</scope>
97+
</dependency>
98+
</dependencies>
99+
100+
<build>
101+
<plugins>
102+
<plugin>
103+
<artifactId>maven-surefire-plugin</artifactId>
104+
<version>3.1.2</version>
105+
<configuration>
106+
<environmentVariables>
107+
<AWS_REGION>eu-central-1</AWS_REGION>
108+
</environmentVariables>
109+
</configuration>
110+
</plugin>
111+
<plugin>
112+
<groupId>org.apache.maven.plugins</groupId>
113+
<artifactId>maven-checkstyle-plugin</artifactId>
114+
</plugin>
115+
</plugins>
116+
</build>
117+
</project>

powertools-parameters/src/main/java/software/amazon/lambda/powertools/parameters/DynamoDbProvider.java renamed to powertools-parameters/powertools-parameters-dynamodb/src/main/java/software/amazon/lambda/powertools/parameters/dynamodb/DynamoDbProvider.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
*/
1414

15-
package software.amazon.lambda.powertools.parameters;
15+
package software.amazon.lambda.powertools.parameters.dynamodb;
1616

1717
import java.util.Collections;
1818
import java.util.Map;
@@ -29,6 +29,8 @@
2929
import software.amazon.awssdk.services.dynamodb.model.QueryRequest;
3030
import software.amazon.awssdk.services.dynamodb.model.QueryResponse;
3131
import software.amazon.lambda.powertools.common.internal.UserAgentConfigurator;
32+
import software.amazon.lambda.powertools.parameters.BaseProvider;
33+
import software.amazon.lambda.powertools.parameters.ParamProvider;
3234
import software.amazon.lambda.powertools.parameters.cache.CacheManager;
3335
import software.amazon.lambda.powertools.parameters.exception.DynamoDbProviderSchemaException;
3436
import software.amazon.lambda.powertools.parameters.transform.TransformationManager;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
*/
1414

15-
package software.amazon.lambda.powertools.parameters;
15+
package software.amazon.lambda.powertools.parameters.dynamodb;
1616

1717
import static org.assertj.core.api.Assertions.assertThat;
1818

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
*/
1414

15-
package software.amazon.lambda.powertools.parameters;
15+
package software.amazon.lambda.powertools.parameters.dynamodb;
1616

1717
import static org.assertj.core.api.Assertions.assertThat;
1818
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;

powertools-parameters/powertools-parameters-tests/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
<artifactId>powertools-parameters-secrets</artifactId>
2929
<version>${project.version}</version>
3030
</dependency>
31+
<dependency>
32+
<groupId>software.amazon.lambda</groupId>
33+
<artifactId>powertools-parameters-dynamodb</artifactId>
34+
<version>${project.version}</version>
35+
</dependency>
3136

3237
<!-- Test dependencies -->
3338
<dependency>

powertools-parameters/powertools-parameters-tests/src/test/java/software/amazon/lambda/powertools/parameters/LambdaParametersAspectTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void init() {
6262
MockitoAnnotations.openMocks(this);
6363
}
6464

65-
@Test
65+
// @Test
6666
// TODO - no more defaults!
6767
// public void testDefault_ShouldUseSSMProvider() {
6868
// try (MockedStatic<ParamManager> mocked = Mockito.mockStatic(ParamManager.class)) {

powertools-parameters/powertools-parameters-tests/src/test/java/software/amazon/lambda/powertools/parameters/ParamManagerIntegrationTest.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,6 @@ public void secretsProvider_get() {
133133
verify(secretsManagerClient, times(1)).getSecretValue(any(GetSecretValueRequest.class));
134134
}
135135

136-
@Test
137-
public void getDynamoDbProvider() {
138-
139-
// Act
140-
DynamoDbProvider provider = ParamManager.getDynamoDbProvider(ddbClient, "test-table");
141-
142-
// Assert
143-
assertThat(provider).isNotNull();
144-
}
145-
146136
@Test
147137
public void getAppConfigProvider() {
148138

powertools-parameters/powertools-parameters-tests/src/test/java/software/amazon/lambda/powertools/parameters/ParamManagerTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.junit.jupiter.api.Test;
2323
import software.amazon.lambda.powertools.parameters.cache.CacheManager;
24+
import software.amazon.lambda.powertools.parameters.dynamodb.DynamoDbProvider;
2425
import software.amazon.lambda.powertools.parameters.internal.CustomProvider;
2526
import software.amazon.lambda.powertools.parameters.secrets.SecretsProvider;
2627
import software.amazon.lambda.powertools.parameters.transform.TransformationManager;

powertools-parameters/src/main/java/software/amazon/lambda/powertools/parameters/ParamManager.java

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
import java.lang.reflect.Constructor;
1818
import java.util.concurrent.ConcurrentHashMap;
1919
import software.amazon.awssdk.services.appconfigdata.AppConfigDataClient;
20-
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
21-
import software.amazon.awssdk.services.secretsmanager.SecretsManagerClient;
2220
import software.amazon.lambda.powertools.parameters.cache.CacheManager;
2321
import software.amazon.lambda.powertools.parameters.transform.TransformationManager;
2422

@@ -46,28 +44,13 @@ public static <T extends BaseProvider> T getProvider(Class<T> providerClass) {
4644
if (providerClass == null) {
4745
throw new IllegalStateException("providerClass cannot be null.");
4846
}
49-
if (providerClass == DynamoDbProvider.class || providerClass == AppConfigProvider.class) {
47+
if (providerClass == AppConfigProvider.class) {
5048
throw new IllegalArgumentException(
5149
providerClass + " cannot be instantiated like this, additional parameters are required");
5250
}
5351
return (T) providers.computeIfAbsent(providerClass, ParamManager::createProvider);
5452
}
5553

56-
/**
57-
* Get a {@link DynamoDbProvider} with default {@link DynamoDbClient} <br/>
58-
* If you need to customize the region, or other part of the client, use {@link ParamManager#getDynamoDbProvider(DynamoDbClient, String)}
59-
*/
60-
public static DynamoDbProvider getDynamoDbProvider(String tableName) {
61-
// Because we need a DDB table name to configure our client, we can't use
62-
// ParamManager#getProvider. This means that we need to make sure we do the same stuff -
63-
// set transformation manager and cache manager.
64-
return DynamoDbProvider.builder()
65-
.withCacheManager(cacheManager)
66-
.withTable(tableName)
67-
.withTransformationManager(transformationManager)
68-
.build();
69-
}
70-
7154
/**
7255
* Get a {@link AppConfigProvider} with default {@link AppConfigDataClient}.<br/>
7356
* If you need to customize the region, or other part of the client, use {@link ParamManager#getAppConfigProvider(AppConfigDataClient, String, String)} instead.
@@ -86,22 +69,6 @@ public static AppConfigProvider getAppConfigProvider(String environment, String
8669
.build();
8770
}
8871

89-
90-
/**
91-
* Get a {@link DynamoDbProvider} with your custom {@link DynamoDbClient}.<br/>
92-
* Use this to configure region or other part of the client. Use {@link ParamManager#getDynamoDbProvider(String)} )} if you don't need this customization.
93-
*
94-
* @return a {@link DynamoDbProvider}
95-
*/
96-
public static DynamoDbProvider getDynamoDbProvider(DynamoDbClient client, String table) {
97-
return (DynamoDbProvider) providers.computeIfAbsent(DynamoDbProvider.class, (k) -> DynamoDbProvider.builder()
98-
.withClient(client)
99-
.withTable(table)
100-
.withCacheManager(cacheManager)
101-
.withTransformationManager(transformationManager)
102-
.build());
103-
}
104-
10572
/**
10673
* Get a {@link AppConfigProvider} with your custom {@link AppConfigDataClient}.<br/>
10774
* Use this to configure region or other part of the client. Use {@link ParamManager#getAppConfigProvider(String, String)} if you don't need this customization.

0 commit comments

Comments
 (0)