Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion archetypes/archetype-app-quickstart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ mvn archetype:generate \
### Parameters

Parameter Name | Default Value | Description
---|---|---
---|-----|---
`service` (required) | n/a | Specifies the service client to be used in the application, eg: s3, dynamodb. Only one service should be provided. You can find available services [here][java-sdk-v2-services].
`groupId`(required) | n/a | Specifies the group ID of the project
`artifactId`(required) | n/a | Specifies the artifact ID of the project
`nativeImage`(required) | n/a | Specifies whether GraalVM Native Image configuration should be included
`httpClient`(required) | n/a | 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]
`ssooidc` (required) | n/a | Specify if the sso and ssoidc dependency should be included in the project. Include them to enable the use of [IAM Identity center](https://aws.amazon.com/iam/identity-center/) for credentials.
Copy link
Contributor

@joviegas joviegas Feb 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we mention the sso and ssoidc or mention someting which is easier for user to undersatnd
"Specify Credential Providers used, this will autimatically add the required dependencies in pom.xml " (something like this)

I guess this request is very specifc to SSO Token Provider.
Note : If we User wants only SSO Credential provider than we donot need sso-oidc dependency , we can clarify this with the requester of this feature.

On other note we can make it generic so that we can add future dependencies related to Credentials providers like STS for example.

Example something like "Press following option to auto add the depencires related to Credentials Providers 1 for SSO Credentials 2. SSO Token Providers 3. STS Credentials providers"

when 1 we just add SSO
when 2 we add SSO + SSO-OIDC
when 3 we add STS (for future not required in this PR)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about -DcredentialProvider=(default|identity-center) for now, with identity-center adding both sso and ssooidc dependency

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future we'll need to widen the terminology to reference identity providers, but for now this should be fine. I think the refactoring of the SDK with regards to new modules will eventually change the setup scripts quite a lot.

`javaSdkVersion` | Same version as the archetype version | Specifies the version of the AWS Java SDK 2.x to be used
`version` | 1.0-SNAPSHOT | Specifies the version of the project
`package` | ${groupId} | Specifies the package name for the classes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@
<requiredProperty key="nativeImage">
<validationRegex>(true|false)</validationRegex>
</requiredProperty>
<requiredProperty key="ssooidc">
<validationRegex>(true|false)</validationRegex>
</requiredProperty>
</requiredProperties>
</archetype-descriptor>
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@
</exclusions>
</dependency>

#if( $ssooidc == 'true')
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>sso</artifactId>
</dependency>

<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>ssooidc</artifactId>
</dependency>

#end
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>${httpClient}</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ package=software.amazonaws.test
service=s3
httpClient=apache-client
javaSdkVersion=2.11.0
nativeImage=true
nativeImage=true
ssooidc=false
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ package=software.amazonaws.test
service=s3
httpClient=apache-client
javaSdkVersion=2.11.0
nativeImage=false
nativeImage=false
ssooidc=false
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ package=software.amazonaws.test
service=s3
httpClient=netty-nio-client
javaSdkVersion=2.11.0
nativeImage=true
nativeImage=true
ssooidc=false
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
groupId=software.amazonaws.test
artifactId=test-apache-artifact
version=1.0-SNAPSHOT
package=software.amazonaws.test
service=s3
httpClient=apache-client
javaSdkVersion=2.11.0
nativeImage=true
ssooidc=true
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
verify
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# App

This project contains a maven application with [AWS Java SDK 2.x](https://github.com/aws/aws-sdk-java-v2) dependencies.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we say that it's using SSO/SSOOIDC or are the other projects also generic?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't specify which individual dependencies that are included for other property of the archetype, so I think we should leave it as-is


## Prerequisites
- Java 1.8+
- Apache Maven
- GraalVM Native Image (optional)

## Development

Below is the structure of the generated project.

```
├── src
│   ├── main
│   │   ├── java
│   │   │   └── package
│   │   │   ├── App.java
│   │   │   ├── DependencyFactory.java
│   │   │   └── Handler.java
│   │   └── resources
│   │   └── simplelogger.properties
│   └── test
│   └── java
│   └── package
│   └── HandlerTest.java
```

- `App.java`: main entry of the application
- `DependencyFactory.java`: creates the SDK client
- `Handler.java`: you can invoke the api calls using the SDK client here.

#### Building the project
```
mvn clean package
```

#### Building the native image

Note that it requires `native-image` installed in your environment

```
mvn clean package -P native-image
```
After it finishes, you can find the generated native image in the `target
` folder.

You can run the following command to execute it.

```
target/test-apache-artifact
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>software.amazonaws.test</groupId>
<artifactId>test-apache-artifact</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.shade.plugin.version>3.2.1</maven.shade.plugin.version>
<maven.compiler.plugin.version>3.6.1</maven.compiler.plugin.version>
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
<aws.java.sdk.version>2.11.0</aws.java.sdk.version>
<slf4j.version>1.7.28</slf4j.version>
<graalvm.native.maven.plugin.version>0.9.6</graalvm.native.maven.plugin.version>
<junit5.version>5.8.1</junit5.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>${aws.java.sdk.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>s3</artifactId>
<exclusions>
<exclusion>
<groupId>software.amazon.awssdk</groupId>
<artifactId>netty-nio-client</artifactId>
</exclusion>
<exclusion>
<groupId>software.amazon.awssdk</groupId>
<artifactId>apache-client</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>sso</artifactId>
</dependency>

<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>ssooidc</artifactId>
</dependency>

<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>apache-client</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4j.version}</version>
</dependency>

<!-- Needed to adapt Apache Commons Logging used by Apache HTTP Client to Slf4j to avoid
ClassNotFoundException: org.apache.commons.logging.impl.LogFactoryImpl during runtime -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>

<!-- Test Dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit5.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin.version}</version>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>native-image</id>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>${graalvm.native.maven.plugin.version}</version>
<executions>
<execution>
<id>build-native</id>
<goals>
<goal>build</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
<configuration>
<imageName>test-apache-artifact</imageName>
<mainClass>software.amazonaws.test.App</mainClass>
<buildArgs combine.children="append">
<buildArgs>
--verbose
--no-fallback
--initialize-at-build-time=org.slf4j
</buildArgs>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package software.amazonaws.test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class App {
private static final Logger logger = LoggerFactory.getLogger(App.class);

public static void main(String... args) {
logger.info("Application starts");

Handler handler = new Handler();
handler.sendRequest();

logger.info("Application ends");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

package software.amazonaws.test;

import software.amazon.awssdk.http.apache.ApacheHttpClient;
import software.amazon.awssdk.services.s3.S3Client;

/**
* The module containing all dependencies required by the {@link Handler}.
*/
public class DependencyFactory {

private DependencyFactory() {}

/**
* @return an instance of S3Client
*/
public static S3Client s3Client() {
return S3Client.builder()
.httpClientBuilder(ApacheHttpClient.builder())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package software.amazonaws.test;

import software.amazon.awssdk.services.s3.S3Client;


public class Handler {
private final S3Client s3Client;

public Handler() {
s3Client = DependencyFactory.s3Client();
}

public void sendRequest() {
// TODO: invoking the api calls using s3Client.
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SLF4J's SimpleLogger configuration file
# Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err.

# Default logging detail level for all instances of SimpleLogger.
# Must be one of ("trace", "debug", "info", "warn", or "error").
# If not specified, defaults to "info".
org.slf4j.simpleLogger.defaultLogLevel=info

# Log SDK requests
org.slf4j.simpleLogger.log.software.amazon.awssdk.request=debug
org.slf4j.simpleLogger.showDateTime=true
org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS Z

# Set to true if you want to output the current thread name.
# Defaults to true.
org.slf4j.simpleLogger.showThreadName=true

# Set to true if you want the Logger instance name to be included in output messages.
# Defaults to true.
#org.slf4j.simpleLogger.showLogName=true

# Set to true if you want the last component of the name to be included in output messages.
# Defaults to false.
org.slf4j.simpleLogger.showShortLogName=false
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package software.amazonaws.test;

import org.junit.jupiter.api.Test;

public class HandlerTest {
//TODO add tests here
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ package=software.amazonaws.test
service=dynamodb
httpClient=url-connection-client
javaSdkVersion=2.11.0
nativeImage=true
nativeImage=true
ssooidc=false
Loading