Skip to content

Commit 6b0fe5a

Browse files
authored
chore(v2): Split parameters module up by parameter provider (aws-powertools#1403)
1 parent 00d04c3 commit 6b0fe5a

File tree

69 files changed

+2363
-1765
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+2363
-1765
lines changed

docs/utilities/parameters.md

+366-327
Large diffs are not rendered by default.

examples/powertools-examples-parameters/pom.xml

+7-1
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@
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>
27+
<dependency>
28+
<groupId>software.amazon.lambda</groupId>
29+
<artifactId>powertools-parameters-secrets</artifactId>
30+
<version>${project.version}</version>
31+
</dependency>
32+
2733
<dependency>
2834
<groupId>com.amazonaws</groupId>
2935
<artifactId>aws-lambda-java-core</artifactId>

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

+19-6
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,30 @@
3131
import java.util.stream.Collectors;
3232
import org.apache.logging.log4j.LogManager;
3333
import org.apache.logging.log4j.Logger;
34-
import software.amazon.lambda.powertools.parameters.ParamManager;
35-
import software.amazon.lambda.powertools.parameters.SSMProvider;
36-
import software.amazon.lambda.powertools.parameters.SecretsProvider;
34+
import software.amazon.lambda.powertools.parameters.secrets.SecretsParam;
35+
import software.amazon.lambda.powertools.parameters.secrets.SecretsProvider;
36+
import software.amazon.lambda.powertools.parameters.ssm.SSMParam;
37+
import software.amazon.lambda.powertools.parameters.ssm.SSMProvider;
3738

3839
public class ParametersFunction implements RequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> {
3940
private final static Logger log = LogManager.getLogger(ParametersFunction.class);
4041

41-
SSMProvider ssmProvider = ParamManager.getSsmProvider();
42-
SecretsProvider secretsProvider = ParamManager.getSecretsProvider();
42+
// Annotation-style injection from secrets manager
43+
@SecretsParam(key = "/powertools-java/userpwd")
44+
String secretParamInjected;
4345

44-
String simpleValue = ssmProvider.defaultMaxAge(30, SECONDS).get("/powertools-java/sample/simplekey");
46+
// Annotation-style injection from Systems Manager
47+
@SSMParam(key = "/powertools-java/sample/simplekey")
48+
String ssmParamInjected;
49+
50+
SSMProvider ssmProvider = SSMProvider
51+
.builder()
52+
.build();
53+
SecretsProvider secretsProvider = SecretsProvider
54+
.builder()
55+
.build();
56+
57+
String simpleValue = ssmProvider.withMaxAge(30, SECONDS).get("/powertools-java/sample/simplekey");
4558
String listValue = ssmProvider.withMaxAge(60, SECONDS).get("/powertools-java/sample/keylist");
4659
MyObject jsonObj = ssmProvider.withTransformation(json).get("/powertools-java/sample/keyjson", MyObject.class);
4760
Map<String, String> allValues = ssmProvider.getMultiple("/powertools-java/sample");

mkdocs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ extra_javascript:
8585

8686
extra:
8787
powertools:
88-
version: 1.18.0 # to update after each release (we do not want snapshot version here)
88+
version: 2.0.0 # to update after each release (we do not want snapshot version here)
8989

9090
repo_url: https://github.com/aws-powertools/powertools-lambda-java
9191
edit_uri: edit/main/docs

pom.xml

+5-29
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@
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-secrets</module>
59+
<module>powertools-parameters/powertools-parameters-dynamodb</module>
60+
<module>powertools-parameters/powertools-parameters-appconfig</module>
61+
<module>powertools-parameters/powertools-parameters-tests</module>
5762
</modules>
5863

5964
<scm>
@@ -600,35 +605,6 @@
600605
</activation>
601606
<build>
602607
<plugins>
603-
<plugin>
604-
<!-- we run checkstyle only on Java 11, no need to run it for all JDK, it's just code style -->
605-
<groupId>org.apache.maven.plugins</groupId>
606-
<artifactId>maven-checkstyle-plugin</artifactId>
607-
<version>3.3.0</version>
608-
<configuration>
609-
<configLocation>checkstyle.xml</configLocation>
610-
<encoding>UTF-8</encoding>
611-
<consoleOutput>true</consoleOutput>
612-
<failsOnError>true</failsOnError>
613-
<linkXRef>false</linkXRef>
614-
</configuration>
615-
<!-- does not work without this dependency -->
616-
<!-- does not work with this dependency on Java 8 -->
617-
<dependencies>
618-
<dependency>
619-
<groupId>com.puppycrawl.tools</groupId>
620-
<artifactId>checkstyle</artifactId>
621-
<version>10.12.3</version>
622-
</dependency>
623-
</dependencies>
624-
<executions>
625-
<execution>
626-
<goals>
627-
<goal>check</goal>
628-
</goals>
629-
</execution>
630-
</executions>
631-
</plugin>
632608
</plugins>
633609
</build>
634610
</profile>

powertools-e2e-tests/handlers/batch/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>software.amazon.lambda</groupId>
77
<artifactId>e2e-test-handlers-parent</artifactId>
8-
<version>1.0.0</version>
8+
<version>2.0.0-SNAPSHOT</version>
99
</parent>
1010

1111
<artifactId>e2e-test-handler-batch</artifactId>

powertools-e2e-tests/handlers/idempotency/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>software.amazon.lambda</groupId>
77
<artifactId>e2e-test-handlers-parent</artifactId>
8-
<version>1.0.0</version>
8+
<version>2.0.0-SNAPSHOT</version>
99
</parent>
1010

1111
<artifactId>e2e-test-handler-idempotency</artifactId>

powertools-e2e-tests/handlers/largemessage/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>software.amazon.lambda</groupId>
77
<artifactId>e2e-test-handlers-parent</artifactId>
8-
<version>1.0.0</version>
8+
<version>2.0.0-SNAPSHOT</version>
99
</parent>
1010

1111
<artifactId>e2e-test-handler-largemessage</artifactId>

powertools-e2e-tests/handlers/largemessage_idempotent/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>software.amazon.lambda</groupId>
77
<artifactId>e2e-test-handlers-parent</artifactId>
8-
<version>1.0.0</version>
8+
<version>2.0.0-SNAPSHOT</version>
99
</parent>
1010

1111
<artifactId>e2e-test-handler-large-msg-idempotent</artifactId>

powertools-e2e-tests/handlers/logging/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>software.amazon.lambda</groupId>
77
<artifactId>e2e-test-handlers-parent</artifactId>
8-
<version>1.0.0</version>
8+
<version>2.0.0-SNAPSHOT</version>
99
</parent>
1010

1111
<artifactId>e2e-test-handler-logging</artifactId>

powertools-e2e-tests/handlers/metrics/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
<parent>
66
<groupId>software.amazon.lambda</groupId>
77
<artifactId>e2e-test-handlers-parent</artifactId>
8-
<version>1.0.0</version>
8+
<version>2.0.0-SNAPSHOT</version>
99
</parent>
1010

1111
<artifactId>e2e-test-handler-metrics</artifactId>
1212
<packaging>jar</packaging>
13-
<name>A Lambda function using Powertools for AWS Lambda (Java) Parameters</name>
13+
<name>A Lambda function using Powertools for AWS Lambda (Java) Metrics</name>
1414

1515
<dependencies>
1616
<dependency>

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
<parent>
66
<groupId>software.amazon.lambda</groupId>
77
<artifactId>e2e-test-handlers-parent</artifactId>
8-
<version>1.0.0</version>
8+
<version>2.0.0-SNAPSHOT</version>
99
</parent>
1010

1111
<artifactId>e2e-test-handler-parameters</artifactId>
1212
<packaging>jar</packaging>
13-
<name>A Lambda function using powertools logging</name>
13+
<name>A Lambda function using powertools parameters</name>
1414

1515
<dependencies>
1616
<dependency>
@@ -19,7 +19,7 @@
1919
</dependency>
2020
<dependency>
2121
<groupId>software.amazon.lambda</groupId>
22-
<artifactId>powertools-parameters</artifactId>
22+
<artifactId>powertools-parameters-appconfig</artifactId>
2323
</dependency>
2424
<dependency>
2525
<groupId>com.amazonaws</groupId>

powertools-e2e-tests/handlers/parameters/src/main/java/software/amazon/lambda/powertools/e2e/Function.java

+7-3
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@
1717
import com.amazonaws.services.lambda.runtime.Context;
1818
import com.amazonaws.services.lambda.runtime.RequestHandler;
1919
import software.amazon.lambda.powertools.logging.Logging;
20-
import software.amazon.lambda.powertools.parameters.AppConfigProvider;
21-
import software.amazon.lambda.powertools.parameters.ParamManager;
20+
import software.amazon.lambda.powertools.parameters.appconfig.AppConfigProvider;
2221

2322
public class Function implements RequestHandler<Input, String> {
2423

2524
@Logging
2625
public String handleRequest(Input input, Context context) {
27-
AppConfigProvider provider = ParamManager.getAppConfigProvider(input.getEnvironment(), input.getApp());
26+
AppConfigProvider provider = AppConfigProvider.builder()
27+
.withApplication(input.getApp())
28+
.withEnvironment(input.getEnvironment())
29+
.build();
30+
31+
//(input.getEnvironment(), input.getApp());
2832
return provider.get(input.getKey());
2933

3034
}

powertools-e2e-tests/handlers/pom.xml

+7-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>software.amazon.lambda</groupId>
66
<artifactId>e2e-test-handlers-parent</artifactId>
7-
<version>1.0.0</version>
7+
<version>2.0.0-SNAPSHOT</version>
88
<packaging>pom</packaging>
99
<name>Handlers for End-to-End tests</name>
1010
<description>Fake handlers that use Powertools for AWS Lambda (Java).</description>
@@ -27,12 +27,16 @@
2727
</properties>
2828

2929
<modules>
30+
<module>batch</module>
31+
<module>largemessage</module>
32+
<module>largemessage_idempotent</module>
3033
<module>logging</module>
3134
<module>tracing</module>
3235
<module>metrics</module>
3336
<module>idempotency</module>
3437
<module>parameters</module>
35-
<module>validation</module>
38+
<module>validation-alb-event</module>
39+
<module>validation-apigw-event</module>
3640
</modules>
3741

3842
<dependencyManagement>
@@ -71,7 +75,7 @@
7175
</dependency>
7276
<dependency>
7377
<groupId>software.amazon.lambda</groupId>
74-
<artifactId>powertools-parameters</artifactId>
78+
<artifactId>powertools-parameters-appconfig</artifactId>
7579
<version>${lambda.powertools.version}</version>
7680
</dependency>
7781
<dependency>

powertools-e2e-tests/handlers/tracing/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>software.amazon.lambda</groupId>
77
<artifactId>e2e-test-handlers-parent</artifactId>
8-
<version>1.0.0</version>
8+
<version>2.0.0-SNAPSHOT</version>
99
</parent>
1010

1111
<artifactId>e2e-test-handler-tracing</artifactId>

powertools-e2e-tests/handlers/validation-alb-event/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>software.amazon.lambda</groupId>
77
<artifactId>e2e-test-handlers-parent</artifactId>
8-
<version>1.0.0</version>
8+
<version>2.0.0-SNAPSHOT</version>
99
</parent>
1010

1111
<artifactId>e2e-test-handler-validation-alb-event</artifactId>

powertools-e2e-tests/handlers/validation-apigw-event/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>software.amazon.lambda</groupId>
77
<artifactId>e2e-test-handlers-parent</artifactId>
8-
<version>1.0.0</version>
8+
<version>2.0.0-SNAPSHOT</version>
99
</parent>
1010

1111
<artifactId>e2e-test-handler-validation-apigw-event</artifactId>

powertools-parameters/pom.xml

+1-61
Original file line numberDiff line numberDiff line change
@@ -28,77 +28,17 @@
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>
34-
<url>https://aws.amazon.com/lambda/</url>
35-
<issueManagement>
36-
<system>GitHub Issues</system>
37-
<url>https://github.com/aws-powertools/powertools-lambda-java/issues</url>
38-
</issueManagement>
39-
<scm>
40-
<url>https://github.com/aws-powertools/powertools-lambda-java.git</url>
41-
</scm>
42-
<developers>
43-
<developer>
44-
<name>Powertools for AWS Lambda team</name>
45-
<organization>Amazon Web Services</organization>
46-
<organizationUrl>https://aws.amazon.com/</organizationUrl>
47-
</developer>
48-
</developers>
49-
50-
<distributionManagement>
51-
<snapshotRepository>
52-
<id>ossrh</id>
53-
<url>https://aws.oss.sonatype.org/content/repositories/snapshots</url>
54-
</snapshotRepository>
55-
</distributionManagement>
31+
<description>Set of utilities to retrieve parameters - common interface</description>
5632

5733
<dependencies>
5834
<dependency>
5935
<groupId>software.amazon.lambda</groupId>
6036
<artifactId>powertools-common</artifactId>
6137
</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>
76-
<dependency>
77-
<groupId>software.amazon.awssdk</groupId>
78-
<artifactId>secretsmanager</artifactId>
79-
<exclusions>
80-
<exclusion>
81-
<groupId>software.amazon.awssdk</groupId>
82-
<artifactId>apache-client</artifactId>
83-
</exclusion>
84-
<exclusion>
85-
<groupId>software.amazon.awssdk</groupId>
86-
<artifactId>netty-nio-client</artifactId>
87-
</exclusion>
88-
</exclusions>
89-
</dependency>
9038
<dependency>
9139
<groupId>software.amazon.awssdk</groupId>
9240
<artifactId>url-connection-client</artifactId>
9341
</dependency>
94-
<dependency>
95-
<groupId>software.amazon.awssdk</groupId>
96-
<artifactId>dynamodb</artifactId>
97-
</dependency>
98-
<dependency>
99-
<groupId>software.amazon.awssdk</groupId>
100-
<artifactId>appconfigdata</artifactId>
101-
</dependency>
10242

10343
<dependency>
10444
<groupId>com.fasterxml.jackson.core</groupId>

0 commit comments

Comments
 (0)