Skip to content

Commit a4d019a

Browse files
committed
Starting by splitting SSM provider out
1 parent 50e7b56 commit a4d019a

File tree

26 files changed

+258
-119
lines changed

26 files changed

+258
-119
lines changed

examples/powertools-examples-parameters/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</dependency>
2222
<dependency>
2323
<groupId>software.amazon.lambda</groupId>
24-
<artifactId>powertools-parameters</artifactId>
24+
<artifactId>powertools-parameters-ssm</artifactId>
2525
<version>${project.version}</version>
2626
</dependency>
2727
<dependency>

examples/powertools-examples-parameters/src/main/java/org/demo/parameters/ParametersFunction.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@
3232
import org.apache.logging.log4j.LogManager;
3333
import org.apache.logging.log4j.Logger;
3434
import software.amazon.lambda.powertools.parameters.ParamManager;
35-
import software.amazon.lambda.powertools.parameters.SSMProvider;
35+
import software.amazon.lambda.powertools.parameters.ssm.SSMProvider;
3636
import software.amazon.lambda.powertools.parameters.SecretsProvider;
3737

3838
public class ParametersFunction implements RequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> {
3939
private final static Logger log = LogManager.getLogger(ParametersFunction.class);
4040

41-
SSMProvider ssmProvider = ParamManager.getSsmProvider();
41+
SSMProvider ssmProvider = SSMProvider
42+
.builder()
43+
.build();
4244
SecretsProvider secretsProvider = ParamManager.getSecretsProvider();
4345

4446
String simpleValue = ssmProvider.defaultMaxAge(30, SECONDS).get("/powertools-java/sample/simplekey");

pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
<module>powertools-e2e-tests</module>
5555
<module>powertools-batch</module>
5656
<module>examples</module>
57+
<module>powertools-parameters/powertools-parameters-ssm</module>
58+
<module>powertools-parameters/powertools-parameters-tests</module>
5759
</modules>
5860

5961
<scm>

powertools-parameters/pom.xml

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@
2828

2929
<name>Powertools for AWS Lambda (Java) library Parameters</name>
3030

31-
<description>
32-
Set of utilities to retrieve parameters from Secrets Manager or SSM Parameter Store
33-
</description>
31+
<description>Set of utilities to retrieve parameters - common interface</description>
32+
3433
<url>https://aws.amazon.com/lambda/</url>
3534
<issueManagement>
3635
<system>GitHub Issues</system>
@@ -59,20 +58,6 @@
5958
<groupId>software.amazon.lambda</groupId>
6059
<artifactId>powertools-common</artifactId>
6160
</dependency>
62-
<dependency>
63-
<groupId>software.amazon.awssdk</groupId>
64-
<artifactId>ssm</artifactId>
65-
<exclusions>
66-
<exclusion>
67-
<groupId>software.amazon.awssdk</groupId>
68-
<artifactId>apache-client</artifactId>
69-
</exclusion>
70-
<exclusion>
71-
<groupId>software.amazon.awssdk</groupId>
72-
<artifactId>netty-nio-client</artifactId>
73-
</exclusion>
74-
</exclusions>
75-
</dependency>
7661
<dependency>
7762
<groupId>software.amazon.awssdk</groupId>
7863
<artifactId>secretsmanager</artifactId>
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
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-ssm</artifactId>
15+
<name>Powertools for AWS Lambda (Java) library Parameters - SSM</name>
16+
<description>SSM Parameter Store 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+
<!-- Test dependencies -->
48+
<dependency>
49+
<groupId>org.junit.jupiter</groupId>
50+
<artifactId>junit-jupiter-api</artifactId>
51+
<scope>test</scope>
52+
</dependency>
53+
<dependency>
54+
<groupId>org.junit.jupiter</groupId>
55+
<artifactId>junit-jupiter-engine</artifactId>
56+
<scope>test</scope>
57+
</dependency>
58+
<dependency>
59+
<groupId>org.mockito</groupId>
60+
<artifactId>mockito-core</artifactId>
61+
<scope>test</scope>
62+
</dependency>
63+
<dependency>
64+
<groupId>org.mockito</groupId>
65+
<artifactId>mockito-inline</artifactId>
66+
<scope>test</scope>
67+
</dependency>
68+
<dependency>
69+
<groupId>org.apache.commons</groupId>
70+
<artifactId>commons-lang3</artifactId>
71+
<scope>test</scope>
72+
</dependency>
73+
<dependency>
74+
<groupId>org.assertj</groupId>
75+
<artifactId>assertj-core</artifactId>
76+
<scope>test</scope>
77+
</dependency>
78+
<dependency>
79+
<groupId>org.aspectj</groupId>
80+
<artifactId>aspectjweaver</artifactId>
81+
<scope>test</scope>
82+
</dependency>
83+
<dependency>
84+
<groupId>software.amazon.awssdk</groupId>
85+
<artifactId>ssm</artifactId>
86+
<exclusions>
87+
<exclusion>
88+
<groupId>software.amazon.awssdk</groupId>
89+
<artifactId>apache-client</artifactId>
90+
</exclusion>
91+
<exclusion>
92+
<groupId>software.amazon.awssdk</groupId>
93+
<artifactId>netty-nio-client</artifactId>
94+
</exclusion>
95+
</exclusions>
96+
</dependency>
97+
</dependencies>
98+
99+
<build>
100+
<plugins>
101+
<plugin>
102+
<artifactId>maven-surefire-plugin</artifactId>
103+
<version>3.1.2</version>
104+
<configuration>
105+
<environmentVariables>
106+
<AWS_REGION>eu-central-1</AWS_REGION>
107+
</environmentVariables>
108+
</configuration>
109+
</plugin>
110+
<plugin>
111+
<groupId>org.apache.maven.plugins</groupId>
112+
<artifactId>maven-checkstyle-plugin</artifactId>
113+
</plugin>
114+
</plugins>
115+
</build>
116+
</project>

powertools-parameters/src/main/java/software/amazon/lambda/powertools/parameters/SSMProvider.java renamed to powertools-parameters/powertools-parameters-ssm/src/main/java/software/amazon/lambda/powertools/parameters/ssm/SSMProvider.java

Lines changed: 7 additions & 15 deletions
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.ssm;
1616

1717
import java.time.temporal.ChronoUnit;
1818
import java.util.HashMap;
@@ -28,6 +28,8 @@
2828
import software.amazon.awssdk.services.ssm.model.GetParametersByPathResponse;
2929
import software.amazon.awssdk.utils.StringUtils;
3030
import software.amazon.lambda.powertools.common.internal.UserAgentConfigurator;
31+
import software.amazon.lambda.powertools.parameters.BaseProvider;
32+
import software.amazon.lambda.powertools.parameters.ParamManager;
3133
import software.amazon.lambda.powertools.parameters.cache.CacheManager;
3234
import software.amazon.lambda.powertools.parameters.transform.TransformationManager;
3335
import software.amazon.lambda.powertools.parameters.transform.Transformer;
@@ -89,17 +91,6 @@ public class SSMProvider extends BaseProvider {
8991
this.client = client;
9092
}
9193

92-
/**
93-
* Constructor with only a CacheManager<br/>
94-
* <p>
95-
* Used in {@link ParamManager#createProvider(Class)}
96-
*
97-
* @param cacheManager handles the parameter caching
98-
*/
99-
SSMProvider(CacheManager cacheManager) {
100-
this(cacheManager, Builder.createClient());
101-
}
102-
10394
/**
10495
* Create a builder that can be used to configure and create a {@link SSMProvider}.
10596
*
@@ -242,7 +233,7 @@ SsmClient getClient() {
242233
return client;
243234
}
244235

245-
static class Builder {
236+
public static class Builder {
246237
private SsmClient client;
247238
private CacheManager cacheManager;
248239
private TransformationManager transformationManager;
@@ -253,7 +244,7 @@ private static SsmClient createClient() {
253244
.region(Region.of(System.getenv(SdkSystemSetting.AWS_REGION.environmentVariable())))
254245
.overrideConfiguration(ClientOverrideConfiguration.builder()
255246
.putAdvancedOption(SdkAdvancedClientOption.USER_AGENT_SUFFIX,
256-
UserAgentConfigurator.getUserAgent(PARAMETERS)).build())
247+
UserAgentConfigurator.getUserAgent(BaseProvider.PARAMETERS)).build())
257248
.build();
258249
}
259250

@@ -264,7 +255,8 @@ private static SsmClient createClient() {
264255
*/
265256
public SSMProvider build() {
266257
if (cacheManager == null) {
267-
throw new IllegalStateException("No CacheManager provided, please provide one");
258+
// TODO - do we want to share this somehow?
259+
cacheManager = new CacheManager();
268260
}
269261
SSMProvider provider;
270262
if (client == null) {

0 commit comments

Comments
 (0)