Skip to content

Commit 31a5b3a

Browse files
committed
Add tests, improve docs and other changes
1 parent 4762b88 commit 31a5b3a

File tree

18 files changed

+124
-58
lines changed

18 files changed

+124
-58
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ artifact source.
1616
* [Sample Code](#sample-code)
1717
* [API Docs][docs-api]
1818
* [Developer Guide][docs-guide] ([source][docs-guide-source])
19+
* [Maven Archetypes](archetypes/README.md)
1920
* [Issues][sdk-issues]
2021
* [SDK Blog][blog]
2122
* [Giving Feedback](#giving-feedback)

archetypes/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Maven Archetypes for AWS SDK for Java 2.x
2+
3+
## Description
4+
This module contains maven archetypes for AWS Java SDK 2.x.
5+
6+
## Archetypes
7+
8+
- [archetype-lambda](archetype-lambda/README.md) - a lambda function template using AWS Java SDK 2.x
9+

archetypes/archetype-lambda/README.md

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,60 @@ has the optimized configurations and follows the best practices to reduce start
66

77
## Usage
88

9-
You can use the following command to generate a project:
9+
You can use `mvn archetype:generate` to generate a project using this archetype. See [maven archetype usage guidance][maven-archetype-usage] for more information.
10+
11+
- Interactive mode
1012

1113
```
1214
mvn archetype:generate \
1315
-DarchetypeGroupId=software.amazon.awssdk \
14-
-DarchetypeArtifactId=lambda-archetypes \
16+
-DarchetypeArtifactId=archetype-lambda \
1517
-DarchetypeVersion=2.x\
1618
```
1719

18-
To deploy the function, you can use [SAM CLI][sam-cli].
20+
- Batch mode
1921

2022
```
21-
sam deploy --guided
23+
mvn archetype:generate \
24+
-DarchetypeGroupId=software.amazon.awssdk \
25+
-DarchetypeArtifactId=archetype-lambda \
26+
-DarchetypeVersion=2.x\
27+
-DgroupId=com.test \
28+
-DartifactId=sample-project \
29+
-Dservice=s3 \
30+
-Dregion=us-west-2 \
31+
-DinteractiveMode=false \
2232
```
23-
Please refer to [deploying lambda apps][deploying-lambda-apps] for more info.
2433

25-
## Parameters
34+
### Parameters
2635
2736
Parameter Name | Default Value | Description
2837
---|---|---
29-
`service` (required) | n/a | Specifies service client to be used in the lambda function. You can find the eg: s3, dynamodb
30-
`region` (required) | n/a | Specifies region to be set for the SDK client in the application
38+
`service` (required) | n/a | Specifies the service client to be used in the lambda function, eg: s3, dynamodb. You can find available services [here][java-sdk-v2-services].
39+
`region` (required) | n/a | Specifies the region to be set for the SDK client in the application
3140
`groupId`(required) | n/a | Specifies the group ID of the project
3241
`artifactId`(required) | n/a | Specifies the artifact ID of the project
33-
`httpClient` | url-connection-client | Specifies which http client to be used by the SDK client, available options are `url-connection-client`, `apache-client`, `netty-nio-client`
34-
`handlerClassName` | `"App"`| Specifies the class name of the handler, which will be used as the lambda function name. It should use camel case.
42+
`httpClient` | url-connection-client | Specifies the http client to be used by the SDK client. Available options are `url-connection-client` (sync), `apache-client` (sync), `netty-nio-client` (async). See [http clients][sdk-http-clients]
43+
`handlerClassName` | `"App"`| Specifies the class name of the handler, which will be used as the lambda function name. It should be camel case.
44+
`javaSdkVersion` | Same version as the archetype version | Specifies the version of the AWS Java SDK 2.x to be used
3545
`version` | 1.0-SNAPSHOT | Specifies the version of the project
3646
`package` | ${groupId} | Specifies the package name for the classes
3747

48+
### Deployment
49+
50+
To deploy the lambda function, you can use [SAM CLI][sam-cli]. The generated project contains a default [SAM template][sam-template] file `template.yaml` where you can
51+
configure different properties of your lambda function such as memory size and timeout.
52+
53+
```
54+
sam deploy --guided
55+
```
56+
57+
Please refer to [deploying lambda apps][deploying-lambda-apps] for more info.
3858

3959
[aws-java-sdk-v2]: https://github.com/aws/aws-sdk-java-v2
60+
[java-sdk-v2-services]: https://github.com/aws/aws-sdk-java-v2/tree/master/services
61+
[sdk-http-clients]: https://github.com/aws/aws-sdk-java-v2/tree/master/http-clients
4062
[deploying-lambda-apps]: https://docs.aws.amazon.com/lambda/latest/dg/deploying-lambda-apps.html
4163
[sam-cli]:https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-getting-started.html
42-
43-
## References
44-
Maven archetype: https://maven.apache.org/archetype/maven-archetype-plugin/usage.html
64+
[maven-archetype-usage]: https://maven.apache.org/archetype/maven-archetype-plugin/usage.html
65+
[sam-template]: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html

archetypes/archetype-lambda/pom.xml

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,67 @@
2020
<parent>
2121
<artifactId>archetypes</artifactId>
2222
<groupId>software.amazon.awssdk</groupId>
23-
<version>2.10.71-SNAPSHOT</version>
23+
<version>2.11.2-SNAPSHOT</version>
2424
</parent>
2525
<modelVersion>4.0.0</modelVersion>
2626
<artifactId>archetype-lambda</artifactId>
2727
<packaging>maven-archetype</packaging>
2828
<name>AWS Java SDK :: Archetype Lambda</name>
2929
<description>
30-
The AWS SDK for Java - Maven archetype for Java lambda function using AWS Java SDK v2
30+
The AWS SDK for Java - Maven archetype for Java lambda function using AWS Java SDK 2.x
3131
</description>
3232

33+
<properties>
34+
<maven.archetype.version>3.1.2</maven.archetype.version>
35+
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
36+
</properties>
37+
38+
<build>
39+
<!-- Filtering the resource properties to get ${project.version} from archetype metadata.
40+
See https://stackoverflow.com/a/22300149 -->
41+
<resources>
42+
<resource>
43+
<directory>src/main/resources</directory>
44+
<filtering>true</filtering>
45+
<includes>
46+
<include>META-INF/maven/archetype-metadata.xml</include>
47+
</includes>
48+
</resource>
49+
<resource>
50+
<directory>src/main/resources</directory>
51+
<filtering>false</filtering>
52+
<excludes>
53+
<exclude>META-INF/maven/archetype-metadata.xml</exclude>
54+
</excludes>
55+
</resource>
56+
</resources>
57+
<extensions>
58+
<extension>
59+
<groupId>org.apache.maven.archetype</groupId>
60+
<artifactId>archetype-packaging</artifactId>
61+
<version>${maven.archetype.version}</version>
62+
</extension>
63+
</extensions>
64+
65+
<plugins>
66+
<plugin>
67+
<artifactId>maven-archetype-plugin</artifactId>
68+
<version>${maven.archetype.version}</version>
69+
<configuration>
70+
<noLog>true</noLog>
71+
<ignoreEOLStyle>true</ignoreEOLStyle>
72+
<skip>${skip.unit.tests}</skip>
73+
</configuration>
74+
<executions>
75+
<execution>
76+
<id>integration-test</id>
77+
<phase>verify</phase>
78+
<goals>
79+
<goal>integration-test</goal>
80+
</goals>
81+
</execution>
82+
</executions>
83+
</plugin>
84+
</plugins>
85+
</build>
3386
</project>

archetypes/archetype-lambda/src/main/resources/META-INF/maven/archetype-metadata.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
<requiredProperty key="handlerClassName">
2828
<defaultValue>App</defaultValue>
2929
</requiredProperty>
30+
<requiredProperty key="javaSdkVersion">
31+
<defaultValue>${project.version}</defaultValue>
32+
<validationRegex>\d+\.\d+.\d+</validationRegex>
33+
</requiredProperty>
3034
<requiredProperty key="service">
3135
</requiredProperty>
3236
<requiredProperty key="httpClient">

archetypes/archetype-lambda/src/main/resources/archetype-resources/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<maven.shade.plugin.version>3.1.1</maven.shade.plugin.version>
2929
<maven.compiler.plugin.version>3.6.1</maven.compiler.plugin.version>
3030
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
31-
<aws.java.sdk.version>2.10.66</aws.java.sdk.version>
31+
<aws.java.sdk.version>${javaSdkVersion}</aws.java.sdk.version>
3232
<aws.lambda.java.version>1.2.0</aws.lambda.java.version>
3333
<junit5.version>5.4.2</junit5.version>
3434
</properties>

archetypes/archetype-lambda/src/main/resources/archetype-resources/template.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
AWSTemplateFormatVersion: '2010-09-09'
22
Transform: AWS::Serverless-2016-10-31
33
Resources:
4+
# See https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html
5+
# for more info to see how to tune the lambda function configs based on your use case.
46
${handlerClassName}Function:
57
Type: AWS::Serverless::Function
68
Properties:

archetypes/archetype-lambda/src/main/resources/global.vm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
#set( $symbol_pound = '#' )
33
#set( $symbol_dollar = '$' )
44
#set( $symbol_escape = '\' )
5-
## TODO: find a better way to handle this
5+
## TODO: there is no easy way to map service module artifactId to the client name derived the service name
6+
## As a workaround: mapping the common service here
67
#if( $service == 'dynamodb')
78
#set ( $service = 'dynamoDb')
89
#end
910
#set ( $servicePackage = $service.toLowerCase())
1011
#set( $serviceClientPrefix = $service.substring(0,1).toUpperCase() + $service.substring(1))
1112
#set( $regionEnum = $region.replace("-", "_").toUpperCase() )
13+
## map the client module name to the client class name and pacakge name
1214
#if( $httpClient == 'url-connection-client')
1315
#set ($httpClientClassName = 'UrlConnectionHttpClient')
1416
#set ($httpClientPackageName = 'urlconnection.' + $httpClientClassName)
@@ -22,5 +24,6 @@
2224
#set ($httpClientPackageName = 'nio.netty.' + $httpClientClassName)
2325
#set ($serviceClientClassName = $serviceClientPrefix + 'AsyncClient')
2426
#end
27+
## map the serviceId to service package and service client class name
2528
#set( $servicePackage = $service.toLowerCase())
2629
#set( $serviceClientPrefix = $service.substring(0,1).toUpperCase() + $service.substring(1))

archetypes/archetype-lambda/src/test/resources/projects/apachehttpclient/archetype.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ service=dynamodb
66
httpClient=apache-client
77
handlerClassName=MyApacheFunction
88
region=ap-southeast-1
9-
9+
javaSdkVersion=2.11.0

archetypes/archetype-lambda/src/test/resources/projects/apachehttpclient/reference/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<maven.shade.plugin.version>3.1.1</maven.shade.plugin.version>
2929
<maven.compiler.plugin.version>3.6.1</maven.compiler.plugin.version>
3030
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
31-
<aws.java.sdk.version>2.10.66</aws.java.sdk.version>
31+
<aws.java.sdk.version>2.11.0</aws.java.sdk.version>
3232
<aws.lambda.java.version>1.2.0</aws.lambda.java.version>
3333
<junit5.version>5.4.2</junit5.version>
3434
</properties>

archetypes/archetype-lambda/src/test/resources/projects/apachehttpclient/reference/template.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
AWSTemplateFormatVersion: '2010-09-09'
22
Transform: AWS::Serverless-2016-10-31
33
Resources:
4+
# See https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html
5+
# for more info to see how to tune the lambda function configs based on your use case.
46
MyApacheFunctionFunction:
57
Type: AWS::Serverless::Function
68
Properties:

archetypes/archetype-lambda/src/test/resources/projects/nettyclient/archetype.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ service=kinesis
66
httpClient=netty-nio-client
77
handlerClassName=MyNettyFunction
88
region=us-east-1
9+
javaSdkVersion=2.11.0
910

archetypes/archetype-lambda/src/test/resources/projects/nettyclient/reference/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<maven.shade.plugin.version>3.1.1</maven.shade.plugin.version>
2929
<maven.compiler.plugin.version>3.6.1</maven.compiler.plugin.version>
3030
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
31-
<aws.java.sdk.version>2.10.66</aws.java.sdk.version>
31+
<aws.java.sdk.version>2.11.0</aws.java.sdk.version>
3232
<aws.lambda.java.version>1.2.0</aws.lambda.java.version>
3333
<junit5.version>5.4.2</junit5.version>
3434
</properties>

archetypes/archetype-lambda/src/test/resources/projects/nettyclient/reference/template.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
AWSTemplateFormatVersion: '2010-09-09'
22
Transform: AWS::Serverless-2016-10-31
33
Resources:
4+
# See https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html
5+
# for more info to see how to tune the lambda function configs based on your use case.
46
MyNettyFunctionFunction:
57
Type: AWS::Serverless::Function
68
Properties:

archetypes/archetype-lambda/src/test/resources/projects/urlhttpclient/archetype.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ package=software.amazonaws.test
55
service=s3
66
httpClient=url-connection-client
77
handlerClassName=App
8-
region=us-west-2
8+
region=us-west-2
9+
javaSdkVersion=2.11.0

archetypes/archetype-lambda/src/test/resources/projects/urlhttpclient/reference/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<maven.shade.plugin.version>3.1.1</maven.shade.plugin.version>
2929
<maven.compiler.plugin.version>3.6.1</maven.compiler.plugin.version>
3030
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
31-
<aws.java.sdk.version>2.10.66</aws.java.sdk.version>
31+
<aws.java.sdk.version>2.11.0</aws.java.sdk.version>
3232
<aws.lambda.java.version>1.2.0</aws.lambda.java.version>
3333
<junit5.version>5.4.2</junit5.version>
3434
</properties>

archetypes/archetype-lambda/src/test/resources/projects/urlhttpclient/reference/template.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
AWSTemplateFormatVersion: '2010-09-09'
22
Transform: AWS::Serverless-2016-10-31
33
Resources:
4+
# See https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html
5+
# for more info to see how to tune the lambda function configs based on your use case.
46
AppFunction:
57
Type: AWS::Serverless::Function
68
Properties:

archetypes/pom.xml

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<parent>
2121
<artifactId>aws-sdk-java-pom</artifactId>
2222
<groupId>software.amazon.awssdk</groupId>
23-
<version>2.10.73-SNAPSHOT</version>
23+
<version>2.11.2-SNAPSHOT</version>
2424
</parent>
2525
<modelVersion>4.0.0</modelVersion>
2626
<artifactId>archetypes</artifactId>
@@ -32,39 +32,4 @@
3232
<description>
3333
Maven Archetypes for applications using Java SDK 2.x
3434
</description>
35-
36-
<properties>
37-
<maven.archetype.version>3.1.2</maven.archetype.version>
38-
</properties>
39-
40-
<build>
41-
<extensions>
42-
<extension>
43-
<groupId>org.apache.maven.archetype</groupId>
44-
<artifactId>archetype-packaging</artifactId>
45-
<version>${maven.archetype.version}</version>
46-
</extension>
47-
</extensions>
48-
49-
<plugins>
50-
<plugin>
51-
<artifactId>maven-archetype-plugin</artifactId>
52-
<version>${maven.archetype.version}</version>
53-
<executions>
54-
<execution>
55-
<id>integration-test</id>
56-
<phase>verify</phase>
57-
<configuration>
58-
<noLog>true</noLog>
59-
<ignoreEOLStyle>true</ignoreEOLStyle>
60-
<skip>true</skip>
61-
</configuration>
62-
<goals>
63-
<goal>integration-test</goal>
64-
</goals>
65-
</execution>
66-
</executions>
67-
</plugin>
68-
</plugins>
69-
</build>
7035
</project>

0 commit comments

Comments
 (0)