From 0ed9a6c8a28433dd281a920d8bafe53ada0526bf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Crocquesel?=
<88554524+scrocquesel@users.noreply.github.com>
Date: Wed, 29 Nov 2023 00:23:28 +0100
Subject: [PATCH] Revamp AWS Quickstarts with DevServices
---
amazon-dynamodb-quickstart/README.md | 199 +++++++++-----
amazon-dynamodb-quickstart/pom.xml | 2 +-
.../src/main/resources/application.properties | 6 -
.../org/acme/dynamodb/DynamodbResource.java | 72 -----
.../acme/dynamodb/DynamodbResourcesTest.java | 2 -
.../src/test/resources/application.properties | 2 +
.../localstack-init/01_create_table.sh | 6 +
.../resources/localstack-init/99_completed.sh | 2 +
amazon-kms-quickstart/README.md | 204 ++++++++++----
amazon-kms-quickstart/pom.xml | 20 +-
.../src/main/resources/application.properties | 9 +-
.../test/java/org/acme/kms/KmsResource.java | 73 -----
.../java/org/acme/kms/KmsResourcesTest.java | 2 -
.../src/test/resources/application.properties | 2 +
.../localstack-init/01_create_key.sh | 5 +
.../resources/localstack-init/99_completed.sh | 2 +
amazon-s3-quickstart/README.md | 173 ++++++++----
amazon-s3-quickstart/pom.xml | 2 +-
amazon-ses-quickstart/README.md | 180 ++++++++++--
amazon-ses-quickstart/pom.xml | 20 +-
.../src/main/resources/application.properties | 6 -
.../test/java/org/acme/ses/SesResource.java | 72 -----
.../java/org/acme/ses/SesResourcesTest.java | 7 +-
.../src/test/resources/application.properties | 2 +
.../localstack-init/01_verify_email.sh | 2 +
.../resources/localstack-init/99_completed.sh | 2 +
amazon-sns-quickstart/README.md | 258 +++++++++++++-----
amazon-sns-quickstart/pom.xml | 20 +-
.../src/main/resources/application.properties | 9 +-
.../test/java/org/acme/sns/SnsResource.java | 72 -----
.../java/org/acme/sns/SnsResourcesTest.java | 2 -
.../src/test/resources/application.properties | 2 +
.../localstack-init/01_create_topic.sh | 2 +
.../resources/localstack-init/99_completed.sh | 2 +
amazon-sqs-quickstart/README.md | 185 +++++++++----
amazon-sqs-quickstart/pom.xml | 20 +-
.../src/main/docker/docker-compose.yml | 17 --
.../src/main/resources/application.properties | 10 +-
.../test/java/org/acme/sqs/SqsResource.java | 72 -----
.../java/org/acme/sqs/SqsResourcesTest.java | 2 -
amazon-ssm-quickstart/README.md | 163 ++++++++---
amazon-ssm-quickstart/pom.xml | 20 +-
.../src/main/resources/application.properties | 7 -
.../test/java/org/acme/ssm/SsmResource.java | 51 ----
.../java/org/acme/ssm/SsmResourcesTest.java | 2 -
45 files changed, 1036 insertions(+), 954 deletions(-)
delete mode 100644 amazon-dynamodb-quickstart/src/test/java/org/acme/dynamodb/DynamodbResource.java
create mode 100644 amazon-dynamodb-quickstart/src/test/resources/application.properties
create mode 100755 amazon-dynamodb-quickstart/src/test/resources/localstack-init/01_create_table.sh
create mode 100755 amazon-dynamodb-quickstart/src/test/resources/localstack-init/99_completed.sh
delete mode 100644 amazon-kms-quickstart/src/test/java/org/acme/kms/KmsResource.java
create mode 100644 amazon-kms-quickstart/src/test/resources/application.properties
create mode 100755 amazon-kms-quickstart/src/test/resources/localstack-init/01_create_key.sh
create mode 100755 amazon-kms-quickstart/src/test/resources/localstack-init/99_completed.sh
delete mode 100644 amazon-ses-quickstart/src/test/java/org/acme/ses/SesResource.java
create mode 100644 amazon-ses-quickstart/src/test/resources/application.properties
create mode 100755 amazon-ses-quickstart/src/test/resources/localstack-init/01_verify_email.sh
create mode 100755 amazon-ses-quickstart/src/test/resources/localstack-init/99_completed.sh
delete mode 100644 amazon-sns-quickstart/src/test/java/org/acme/sns/SnsResource.java
create mode 100644 amazon-sns-quickstart/src/test/resources/application.properties
create mode 100755 amazon-sns-quickstart/src/test/resources/localstack-init/01_create_topic.sh
create mode 100755 amazon-sns-quickstart/src/test/resources/localstack-init/99_completed.sh
delete mode 100644 amazon-sqs-quickstart/src/main/docker/docker-compose.yml
delete mode 100644 amazon-sqs-quickstart/src/test/java/org/acme/sqs/SqsResource.java
delete mode 100644 amazon-ssm-quickstart/src/test/java/org/acme/ssm/SsmResource.java
diff --git a/amazon-dynamodb-quickstart/README.md b/amazon-dynamodb-quickstart/README.md
index 8b487771b2..391d68a69a 100644
--- a/amazon-dynamodb-quickstart/README.md
+++ b/amazon-dynamodb-quickstart/README.md
@@ -1,127 +1,180 @@
-# Quarkus demo: DynamoDB Client
+# Quarkus demo: Amazon DynamoDB Client
-This example showcases how to use the AWS DynamoDB client with Quarkus. As a prerequisite install Install [AWS Command line interface](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html).
+This example showcases how to use the AWS DynamoDB client with Quarkus.
-# DynamoDB local instance
+## Run the Demo in Dev Mode
-Just run it as follows:
-`docker run --rm --name local-dynamo -p 8000:4569 -e SERVICES=dynamodb -e START_WEB=0 -d localstack/localstack`
+- Run `./mvnw clean quarkus:dev`
-DynamoDB listens on `localhost:8000` for REST endpoints.
+Go to [`http://localhost:8080/fruits.html`](http://localhost:8080/fruits.html), it should show a simple App to manage a list of Fruits.
+You can add fruits to the list via the form.
+
+Alternatively, go to [`http://localhost:8080/async-fruits.html`](http://localhost:8080/async-fruits.html) with the simple App communicating with Async resources.
+
+# Using LocalStack
+
+As a prerequisite, install the [AWS Command Line Interface](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html).
+
+Start LocalStack:
+
+ ```sh
+ docker run \
+ --rm \
+ --name local-dynamodb \
+ -p 4566:4566 \
+ locals
+
+DynamoDB listens on `localhost:4566` for REST endpoints.
Create an AWS profile for your local instance using AWS CLI:
+```sh
+aws configure --profile localstack
```
-$ aws configure --profile localstack
+
+```plain
AWS Access Key ID [None]: test-key
AWS Secret Access Key [None]: test-secret
Default region name [None]: us-east-1
Default output format [None]:
```
-## Create table
+## Create a DynamoDB table
Create a DynamoDB table using AWS CLI and the localstack profile.
-```
-aws dynamodb create-table --table-name QuarkusFruits \
- --attribute-definitions AttributeName=fruitName,AttributeType=S \
- --key-schema AttributeName=fruitName,KeyType=HASH \
- --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1 \
- --profile localstack --endpoint-url=http://localhost:8000
+
+```sh
+aws dynamodb create-table \
+ --table-name QuarkusFruits \
+ --attribute-definitions AttributeName=fruitName,AttributeType=S \
+ --key-schema AttributeName=fruitName,KeyType=HASH \
+ --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1 \
+ --profile localstack --endpoint-url=http://localhost:4566`
```
-# Run the demo on dev mode
+## Run the demo
-- Run `./mvnw clean package` and then `java -jar ./target/quarkus-app/quarkus-run.jar`
-- In dev mode `./mvnw clean quarkus:dev`
+You can compile the application and run it with:
-Go to [`http://localhost:8080/fruits.html`](http://localhost:8080/fruits.html), it should show a simple App to manage a list of Fruits.
-You can add fruits to the list via the form.
+```sh
+./mvnw install
+AWS_PROFILE=localstack java -Dquarkus.dynamodb.endpoint-override=http://localhost:4566 -jar ./target/quarkus-app/quarkus-run.jar
+```
-Alternatively, go to [`http://localhost:8080/async-fruits.html`](http://localhost:8080/async-fruits.html) with the simple App communicating with Async resources.
+Go to [`http://localhost:8080/fruits.html`](http://localhost:8080/fruits.html) or [`http://localhost:8080/async-fruits.html`](http://localhost:8080/async-fruits.html), to test the application.
-# Running in native
+## Running in native
You can compile the application into a native executable using:
-`./mvnw clean install -Pnative`
-
-and run with:
+```sh
+./mvnw install -Dnative
+```
-`./target/amazon-dynamodb-quickstart-1.0.0-SNAPSHOT-runner`
+And run it with:
+```sh
+AWS_PROFILE=localstack ./target/amazon-dynamodb-quickstart-1.0.0-SNAPSHOT-runner -Dquarkus.dynamodb.endpoint-override=http://localhost:4566
+```
# Running native in container
-Build a native image in container by running:
+Build a native image in a container by running:
-`./mvnw package -Pnative -Dnative-image.docker-build=true`
+```sh
+./mvnw install -Dnative -DskipTests -Dquarkus.native.container-build=true
+```
-Build a docker image:
-`docker build -f src/main/docker/Dockerfile.native -t quarkus/amazon-dynamodb-quickstart .`
+Build a Docker image:
-Create a network that connects your container with localstack
-`docker network create localstack`
+```sh
+docker build -f src/main/docker/Dockerfile.native -t quarkus/amazon-dynamodb-quickstart .
+```
-Stop your localstack container you started at the beginning
-`docker stop local-dynamo`
+Create a network that connects your container with LocalStack:
-Start localstack and connect to the network
-`docker run --rm --network=localstack --name localstack -p 8000:4569 -e SERVICES=dynamodb -e START_WEB=0 -d localstack/localstack`
+```sh
+docker network create localstack
+```
-Create Dynamo table
+Stop your LocalStack container you started at the beginning:
+
+```sh
+docker stop local-dynamodb
```
-aws dynamodb create-table --table-name QuarkusFruits \
- --attribute-definitions AttributeName=fruitName,AttributeType=S \
- --key-schema AttributeName=fruitName,KeyType=HASH \
- --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1 \
- --profile localstack --endpoint-url=http://localhost:8000
+
+Start LocalStack and connect to the network:
+
+```sh
+docker run \
+ --rm \
+ --name local-dynamodb \
+ --network=localstack \
+ -p 4566:4566 \
+ localstack/localstack
```
-Run quickstart container connected to that network (note that we're using internal port of the localstack)
-`docker run -i --rm --network=localstack -p 8080:8080 quarkus/amazon-dynamodb-quickstart -Dquarkus.dynamodb.endpoint-override=http://localstack:4569`
+Create a DynamoDB table using AWS CLI and the localstack profile.
-Go to [`http://localhost:8080/fruits.html`](http://localhost:8080/fruits.html) or [`http://localhost:8080/async-fruits.html`](http://localhost:8080/async-fruits.html)
+```sh
+aws dynamodb create-table \
+ --table-name QuarkusFruits \
+ --attribute-definitions AttributeName=fruitName,AttributeType=S \
+ --key-schema AttributeName=fruitName,KeyType=HASH \
+ --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1 \
+ --profile localstack --endpoint-url=http://localhost:4566`
+```
-# Using AWS account
+Run the Quickstart container connected to that network (note that we're using the internal port of the LocalStack container):
+
+```sh
+docker run -i --rm --network=localstack \
+ -p 8080:8080 \
+ -e QUARKUS_DYNAMODB_ENDPOINT_OVERRIDE="http://local-dynamodb:4566" \
+ -e QUARKUS_DYNAMODB_AWS_REGION="us-east-1" \
+ -e QUARKUS_DYNAMODB_AWS_CREDENTIALS_TYPE="static" \
+ -e QUARKUS_DYNAMODB_AWS_CREDENTIALS_STATIC_PROVIDER_ACCESS_KEY_ID="test-key" \
+ -e QUARKUS_DYNAMODB_AWS_CREDENTIALS_STATIC_PROVIDER_SECRET_ACCESS_KEY="test-secret" \
+ quarkus/amazon-dynamodb-quickstart
+```
-Before you can use the AWS SDKs with DynamoDB, you must get an AWS access key ID and secret access key.
-For more information, see [Setting Up DynamoDB (Web Service)](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/SettingUp.DynamoWebService.html).
+Go to `http://localhost:8080/dynamodb.html` or `http://localhost:8080/async-dynamodb.html`, to test the application.
-Create a DynamoDB table using AWS CLI and your default AWS profile:
+Clean up your environment:
-```
-aws dynamodb create-table --table-name QuarkusFruits \
- --attribute-definitions AttributeName=fruitName,AttributeType=S \
- --key-schema AttributeName=fruitName,KeyType=HASH \
- --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1
+```sh
+docker stop local-dynamodb
+docker network rm localstack
```
-## Run demo
+# Using AWS account
-You can run the demo the same way as for a local instance, but you need to change the `application.properties`.
+Before you can use the AWS SDKs with DynamoDB, you must get an AWS access key ID and secret access key.
+For more information, see:
+ - [Sign up for AWS and Create an IAM User](https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/signup-create-iam-user.html)
+ - [Set Up AWS Credentials and Region for Development](https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/setup-credentials.html)
-- remove or comment out `quarkus.dynamodb.endpoint-override` - as you are going to communicate with the AWS service now
-- remove or comment out `quarkus.dynamodb.aws.region` - region is going to be retrieved via the default providers chain in the following order:
- - `aws.region` system property
- - `region` property from the profile file
-- remove or comment out `quarkus.dynamodb.aws.credentials.type` - if not configured the client uses `default` credentials provider chain that looks for credentials in this order:
- - Java System Properties - `aws.accessKeyId` and `aws.secretKey`
- - Environment Variables - `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`
- - Credential profiles file at the default location (`~/.aws/credentials`) shared by all AWS SDKs and the AWS CLI
-
-Build the application
+Create a DynamoDB table using AWS CLI and the localstack profile.
-`./mvnw clean package`
-
-And then run it
+```sh
+aws dynamodb create-table \
+ --table-name QuarkusFruits \
+ --attribute-definitions AttributeName=fruitName,AttributeType=S \
+ --key-schema AttributeName=fruitName,KeyType=HASH \
+ --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1
+```
+## Run demo
-`java -jar ./target/quarkus-app/quarkus-run.jar`
+You can run the demo the same way as for a local instance, but you don't need to override the endpoint as you are going to communicate with the AWS service with the default AWS profile.
-Or, build as native executable
+Run it:
-`./mvnw clean package -Pnative`
+```sh
+java -Dbucket.name=quarkus.dynamodb.12.345.99 -jar ./target/quarkus-app/quarkus-run.jar
+```
-And then run it
+Or, run it natively:
-`./target/amazon-dynamodb-quickstart-1.0.0-SNAPSHOT-runner`
+```sh
+./target/amazon-dynamodb-quickstart-1.0.0-SNAPSHOT-runner -Dbucket.name=quarkus.dynamodb.12.345.99
+```
diff --git a/amazon-dynamodb-quickstart/pom.xml b/amazon-dynamodb-quickstart/pom.xml
index d048f4f84a..6bc02ef416 100644
--- a/amazon-dynamodb-quickstart/pom.xml
+++ b/amazon-dynamodb-quickstart/pom.xml
@@ -16,7 +16,7 @@
UTF-8
11
11
- 2.5.3
+ 2.7.2
1.12.57
diff --git a/amazon-dynamodb-quickstart/src/main/resources/application.properties b/amazon-dynamodb-quickstart/src/main/resources/application.properties
index 82ef18b68e..e69de29bb2 100644
--- a/amazon-dynamodb-quickstart/src/main/resources/application.properties
+++ b/amazon-dynamodb-quickstart/src/main/resources/application.properties
@@ -1,6 +0,0 @@
-quarkus.dynamodb.endpoint-override=http://localhost:8000
-
-quarkus.dynamodb.aws.region=eu-central-1
-quarkus.dynamodb.aws.credentials.type=static
-quarkus.dynamodb.aws.credentials.static-provider.access-key-id=test-key
-quarkus.dynamodb.aws.credentials.static-provider.secret-access-key=test-secret
diff --git a/amazon-dynamodb-quickstart/src/test/java/org/acme/dynamodb/DynamodbResource.java b/amazon-dynamodb-quickstart/src/test/java/org/acme/dynamodb/DynamodbResource.java
deleted file mode 100644
index 3bbba2da27..0000000000
--- a/amazon-dynamodb-quickstart/src/test/java/org/acme/dynamodb/DynamodbResource.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.acme.dynamodb;
-
-import java.net.URI;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.testcontainers.DockerClientFactory;
-import org.testcontainers.containers.localstack.LocalStackContainer;
-import org.testcontainers.containers.localstack.LocalStackContainer.EnabledService;
-import org.testcontainers.containers.localstack.LocalStackContainer.Service;
-import org.testcontainers.utility.DockerImageName;
-
-import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
-import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
-import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
-import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
-import software.amazon.awssdk.regions.Region;
-import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
-import software.amazon.awssdk.services.dynamodb.model.KeyType;
-import software.amazon.awssdk.services.dynamodb.model.ScalarAttributeType;
-
-public class DynamodbResource implements QuarkusTestResourceLifecycleManager {
-
- public final static String TABLE_NAME = "QuarkusFruits";
-
- private static final DockerImageName LOCALSTACK_IMAGE_NAME = DockerImageName.parse("localstack/localstack")
- .withTag("0.12.17");
-
- private LocalStackContainer container;
- private DynamoDbClient client;
-
- @Override
- public Map start() {
- DockerClientFactory.instance().client();
- try {
- container = new LocalStackContainer(LOCALSTACK_IMAGE_NAME).withServices(Service.DYNAMODB);
- container.start();
-
- URI endpointOverride = container.getEndpointOverride(EnabledService.named(Service.DYNAMODB.getName()));
-
- client = DynamoDbClient.builder()
- .endpointOverride(endpointOverride)
- .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("accesskey", "secretKey")))
- .httpClientBuilder(UrlConnectionHttpClient.builder())
- .region(Region.US_EAST_1).build();
-
- client.createTable(tableRequest ->
- tableRequest.tableName(TABLE_NAME)
- .keySchema(keySchema -> keySchema.attributeName("fruitName").keyType(KeyType.HASH))
- .attributeDefinitions(attrDef -> attrDef.attributeName("fruitName").attributeType(ScalarAttributeType.S))
- .provisionedThroughput(throughput -> throughput.writeCapacityUnits(1L).readCapacityUnits(1L)));
-
- Map properties = new HashMap<>();
- properties.put("quarkus.dynamodb.endpoint-override", endpointOverride.toString());
- properties.put("quarkus.dynamodb.aws.region", "us-east-1");
- properties.put("quarkus.dynamodb.aws.credentials.type", "static");
- properties.put("quarkus.dynamodb.aws.credentials.static-provider.access-key-id", "accessKey");
- properties.put("quarkus.dynamodb.aws.credentials.static-provider.secret-access-key", "secretKey");
-
- return properties;
- } catch (Exception e) {
- throw new RuntimeException("Could not start Dynamodb localstack server", e);
- }
- }
-
- @Override
- public void stop() {
- if (container != null) {
- container.close();
- }
- }
-}
diff --git a/amazon-dynamodb-quickstart/src/test/java/org/acme/dynamodb/DynamodbResourcesTest.java b/amazon-dynamodb-quickstart/src/test/java/org/acme/dynamodb/DynamodbResourcesTest.java
index 04caf2f3ec..1c1ec3499d 100644
--- a/amazon-dynamodb-quickstart/src/test/java/org/acme/dynamodb/DynamodbResourcesTest.java
+++ b/amazon-dynamodb-quickstart/src/test/java/org/acme/dynamodb/DynamodbResourcesTest.java
@@ -3,7 +3,6 @@
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
-import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
import java.util.Arrays;
import java.util.List;
@@ -15,7 +14,6 @@
import org.junit.jupiter.params.provider.ValueSource;
@QuarkusTest
-@QuarkusTestResource(DynamodbResource.class)
public class DynamodbResourcesTest {
private static final BiFunction FRUIT = (name, description) -> String
diff --git a/amazon-dynamodb-quickstart/src/test/resources/application.properties b/amazon-dynamodb-quickstart/src/test/resources/application.properties
new file mode 100644
index 0000000000..02c4c8c133
--- /dev/null
+++ b/amazon-dynamodb-quickstart/src/test/resources/application.properties
@@ -0,0 +1,2 @@
+quarkus.aws.devservices.localstack.init-scripts-classpath=localstack-init
+quarkus.aws.devservices.localstack.init-completion-msg=#### Tests init completed
\ No newline at end of file
diff --git a/amazon-dynamodb-quickstart/src/test/resources/localstack-init/01_create_table.sh b/amazon-dynamodb-quickstart/src/test/resources/localstack-init/01_create_table.sh
new file mode 100755
index 0000000000..f940d3d1dd
--- /dev/null
+++ b/amazon-dynamodb-quickstart/src/test/resources/localstack-init/01_create_table.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+awslocal dynamodb create-table \
+ --table-name QuarkusFruits \
+ --attribute-definitions AttributeName=fruitName,AttributeType=S \
+ --key-schema AttributeName=fruitName,KeyType=HASH \
+ --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1
diff --git a/amazon-dynamodb-quickstart/src/test/resources/localstack-init/99_completed.sh b/amazon-dynamodb-quickstart/src/test/resources/localstack-init/99_completed.sh
new file mode 100755
index 0000000000..bc887a888f
--- /dev/null
+++ b/amazon-dynamodb-quickstart/src/test/resources/localstack-init/99_completed.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+echo "#### Tests init completed"
diff --git a/amazon-kms-quickstart/README.md b/amazon-kms-quickstart/README.md
index 5623872217..d6e5723f19 100644
--- a/amazon-kms-quickstart/README.md
+++ b/amazon-kms-quickstart/README.md
@@ -1,17 +1,66 @@
# Quarkus demo: Amazon KMS Client
-This example showcases how to use the AWS KMS client with Quarkus. As a prerequisite install Install [AWS Command line interface](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html).
+This example showcases how to use the AWS KMS client with Quarkus.
-# AWS KMS local instance
+## Run the Demo in Dev Mode
-Just run it as follows in order to start KMS locally:
-`docker run --rm --name local-kms -p 8011:4599 -e SERVICES=kms -e START_WEB=0 -d localstack/localstack:0.11.1`
-KMS listens on `localhost:8011` for REST endpoints.
+- Run `./mvnw clean quarkus:dev`
+
+## Encrypt your text
+
+```sh
+curl -XPOST -H"Content-type: text/plain" http://localhost:8080/sync/encrypt -d'Quarkus is awsome'
+```
+
+And the result similar to this output:
+
+```plain
+S2Fybjphd3M6a21zOnVzLWVhc3QtMTowMDAwMDAwMDAwMDA6a2V5LzZmYzAwOWZhLWYwMDUtNGI4My04ZDc1LTk4OGVhZTk4ZTM1NwAAAAAfC2HyHrHBXLNFomHLdH9PlMKWQKofyhJjbY2TUovEaBuc4Hj+Lb2BSoYTa/c=
+```
+
+## Decrypt your message
+
+You can now decrypt a message you previously encrypted
+
+```sh
+curl -XPOST -H"Content-type: text/plain" http://localhost:8080/sync/decrypt -d ''
+```
+
+Repeat the same using async endpoints. Encrypt
+
+```sh
+curl -XPOST -H"Content-type: text/plain" http://localhost:8080/async/encrypt -d 'Quarkus is awsome'
+```
+
+And then decrypt
+
+```sh
+curl -XPOST -H"Content-type: text/plain" http://localhost:8080/async/decrypt -d ''
+```
+
+# Using LocalStack
+
+As a prerequisite, install the [AWS Command Line Interface](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html).
+
+Start LocalStack:
+
+ ```sh
+ docker run \
+ --rm \
+ --name local-kms \
+ -p 4566:4566 \
+ localstack/localstack
+```
+
+KMS listens on `localhost:4566` for REST endpoints.
Create an AWS profile for your local instance using AWS CLI:
+```sh
+aws configure --profile localstack
```
-$ aws configure --profile localstack
+
+```plain
AWS Access Key ID [None]: test-key
AWS Secret Access Key [None]: test-secret
Default region name [None]: us-east-1
@@ -20,79 +69,130 @@ Default output format [None]:
## Create KMS master key
-Create a master key and store the ARN in the `MASTER_KEY_ARN` environment variable
-```
-$> MASTER_KEY_ARN=`aws kms create-key --profile localstack --endpoint-url=http://localhost:8011 | cut -f3`
-```
-Generate key data as 256-bit symmetric key (AES_256)
-```
-$> aws kms generate-data-key --key-id $MASTER_KEY_ARN --key-spec AES_256 --profile localstack --endpoint-url=http://localhost:8011
+Create a master key with an alias for simplier configuration.
+
+```sh
+key_id=$(aws kms create-key --query KeyMetadata.KeyId --output text --profile localstack --endpoint-url=http://localhost:4566)
+aws kms create-alias --alias-name "alias/quarkus" --target-key-id $key_id --profile localstack --endpoint-url=http://localhost:4566
```
-# Run the demo on dev mode
+## Run the demo
-- Run `./mvnw clean package` and then `java -Dkey.arn=$MASTER_KEY_ARN -jar ./target/quarkus-app/quarkus-run.jar`
-- In dev mode `./mvnw clean quarkus:dev -Dkey.arn=$MASTER_KEY_ARN`
+You can compile the application and run it with:
-## Encrypt your text
-```
-curl -XPOST -H"Content-type: text/plain" http://localhost:8080/sync/encrypt -d'Quarkus is awsome'
+```sh
+./mvnw install
+AWS_PROFILE=localstack java -Dquarkus.kms.endpoint-override=http://localhost:4566 -jar ./target/quarkus-app/quarkus-run.jar
```
-And the result similar to this output:
+
+You can now replay the `curl` commands above.
+
+## Running in native
+
+You can compile the application into a native executable using:
+
+```sh
+./mvnw install -Dnative
```
-S2Fybjphd3M6a21zOnVzLWVhc3QtMTowMDAwMDAwMDAwMDA6a2V5LzZmYzAwOWZhLWYwMDUtNGI4My04ZDc1LTk4OGVhZTk4ZTM1NwAAAAAfC2HyHrHBXLNFomHLdH9PlMKWQKofyhJjbY2TUovEaBuc4Hj+Lb2BSoYTa/c=
+
+And run it with:
+
+```sh
+AWS_PROFILE=localstack ./target/amazon-kms-quickstart-1.0.0-SNAPSHOT-runner -Dquarkus.kms.endpoint-override=http://localhost:4566
```
-## Decrypt your message
-You can now decrypt a message you previously encrypted
+# Running native in container
+
+Build a native image in a container by running:
+
+```sh
+./mvnw install -Dnative -DskipTests -Dquarkus.native.container-build=true
```
-curl -XPOST -H"Content-type: text/plain" http://localhost:8080/sync/decrypt -d ''
+
+Build a Docker image:
+
+```sh
+docker build -f src/main/docker/Dockerfile.native -t quarkus/amazon-kms-quickstart .
```
-Repeat the same using async endpoints. Encrypt
+Create a network that connects your container with LocalStack:
+
+```sh
+docker network create localstack
```
-curl -XPOST -H"Content-type: text/plain" http://localhost:8080/async/encrypt -d 'Quarkus is awsome'
+
+Stop your LocalStack container you started at the beginning:
+
+```sh
+docker stop local-kms
```
-And then decrypt
+
+Start LocalStack and connect to the network:
+
+```sh
+docker run \
+ --rm \
+ --name local-kms \
+ --network=localstack \
+ -p 4566:4566 \
+ localstack/localstack
```
-curl -XPOST -H"Content-type: text/plain" http://localhost:8080/async/decrypt -d ''
+
+Create a master key with an alias for simplier configuration.
+
+```sh
+key_id=$(aws kms create-key --query KeyMetadata.KeyId --output text --profile localstack --endpoint-url=http://localhost:4566)
+aws kms create-alias --alias-name "alias/quarkus" --target-key-id $key_id --profile localstack --endpoint-url=http://localhost:4566
```
-# Running in native
+Run the Quickstart container connected to that network (note that we're using the internal port of the LocalStack container):
-You can compile the application into a native binary using:
+```sh
+docker run -i --rm --network=localstack \
+ -p 8080:8080 \
+ -e QUARKUS_KMS_ENDPOINT_OVERRIDE="http://local-kms:4566" \
+ -e QUARKUS_KMS_AWS_REGION="us-east-1" \
+ -e QUARKUS_KMS_AWS_CREDENTIALS_TYPE="static" \
+ -e QUARKUS_KMS_AWS_CREDENTIALS_STATIC_PROVIDER_ACCESS_KEY_ID="test-key" \
+ -e QUARKUS_KMS_AWS_CREDENTIALS_STATIC_PROVIDER_SECRET_ACCESS_KEY="test-secret" \
+ quarkus/amazon-kms-quickstart
+```
-`./mvnw clean install -Pnative`
+Replay `curl` commands from above:
-and run with:
+Clean up your environment:
-`./target/amazon-kms-quickstart-1.0.0-SNAPSHOT-runner -Dkey.arn=$MASTER_KEY_ARN`
+```sh
+docker stop local-kms
+docker network rm localstack
+```
+# Using AWS account
-# Running native in container
+Before you can use the AWS SDKs with KMS, you must get an AWS access key ID and secret access key.
+For more information, see:
+ - [Sign up for AWS and Create an IAM User](https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/signup-create-iam-user.html)
+ - [Set Up AWS Credentials and Region for Development](https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/setup-credentials.html)
-Build a native image in container by running:
-`./mvnw package -Pnative -Dnative-image.docker-build=true`
+Create a master key with an alias for simplier configuration.
-Build a docker image:
-`docker build -f src/main/docker/Dockerfile.native -t quarkus/amazon-kms-quickstart .`
+```sh
+key_id=$(aws kms create-key --query KeyMetadata.KeyId --output text)
+aws kms create-alias --alias-name "alias/quarkus" --target-key-id $key_id
+```
-Create a network that connect your container with localstack
-`docker network create localstack`
+## Run demo
-Stop your localstack container you started at the beginning
-`docker stop local-kms`
+You can run the demo the same way as for a local instance, but you don't need to override the endpoint as you are going to communicate with the AWS service with the default AWS profile.
-Start localstack and connect to the network
-`docker run --rm --network=localstack --name localstack -p 8011:4599 -e SERVICES=kms -e START_WEB=0 -d localstack/localstack:0.11.1`
+Run it:
-Create a master key and store the ARN in the `CMK_ARN` environment variable
+```sh
+java -jar ./target/quarkus-app/quarkus-run.jar
```
-$> MASTER_KEY_ARN=`aws kms create-key --profile localstack --endpoint-url=http://localhost:8011 | cut -f3`
-```
-Generate key data as 256-bit symmetric key (AES_256)
-```
-$> aws kms generate-data-key --key-id $MASTER_KEY_ARN --key-spec AES_256 --profile localstack --endpoint-url=http://localhost:8011
+
+Or, run it natively:
+
+```sh
+./target/amazon-kms-quickstart-1.0.0-SNAPSHOT-runner
```
-Run quickstart container connected to that network (note that we're using internal port of the localstack)
-`docker run -i --rm --network=localstack -p 8080:8080 quarkus/amazon-kms-quickstart -Dquarkus.kms.endpoint-override=http://localstack:4599`
diff --git a/amazon-kms-quickstart/pom.xml b/amazon-kms-quickstart/pom.xml
index 52845dade7..4a9bfb5dfa 100644
--- a/amazon-kms-quickstart/pom.xml
+++ b/amazon-kms-quickstart/pom.xml
@@ -16,8 +16,7 @@
UTF-8
11
11
- 2.5.3
- 1.12.57
+ 2.7.2
@@ -71,23 +70,6 @@
rest-assured
test
-
- org.testcontainers
- localstack
- test
-
-
- org.testcontainers
- junit-jupiter
- test
-
-
-
- com.amazonaws
- aws-java-sdk-core
- ${awssdk.testcontainers.version}
- test
-
diff --git a/amazon-kms-quickstart/src/main/resources/application.properties b/amazon-kms-quickstart/src/main/resources/application.properties
index ecf6827577..355ed288be 100644
--- a/amazon-kms-quickstart/src/main/resources/application.properties
+++ b/amazon-kms-quickstart/src/main/resources/application.properties
@@ -1,8 +1 @@
-quarkus.kms.endpoint-override=http://localhost:8011
-
-quarkus.kms.aws.region=us-east-1
-quarkus.kms.aws.credentials.type=static
-quarkus.kms.aws.credentials.static-provider.access-key-id=test-key
-quarkus.kms.aws.credentials.static-provider.secret-access-key=test-secret
-
-key.arn=
\ No newline at end of file
+key.arn=alias/quarkus
\ No newline at end of file
diff --git a/amazon-kms-quickstart/src/test/java/org/acme/kms/KmsResource.java b/amazon-kms-quickstart/src/test/java/org/acme/kms/KmsResource.java
deleted file mode 100644
index d31d026248..0000000000
--- a/amazon-kms-quickstart/src/test/java/org/acme/kms/KmsResource.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package org.acme.kms;
-
-import java.net.URI;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.testcontainers.DockerClientFactory;
-import org.testcontainers.containers.localstack.LocalStackContainer;
-import org.testcontainers.containers.localstack.LocalStackContainer.EnabledService;
-import org.testcontainers.containers.localstack.LocalStackContainer.Service;
-import org.testcontainers.utility.DockerImageName;
-
-import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
-import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
-import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
-import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
-import software.amazon.awssdk.regions.Region;
-import software.amazon.awssdk.services.kms.KmsClient;
-import software.amazon.awssdk.services.kms.model.DataKeySpec;
-
-public class KmsResource implements QuarkusTestResourceLifecycleManager {
-
- private static final DockerImageName LOCALSTACK_IMAGE_NAME = DockerImageName.parse("localstack/localstack")
- .withTag("0.12.17");
-
- private LocalStackContainer container;
- private KmsClient client;
-
- @Override
- public Map start() {
- DockerClientFactory.instance().client();
- String masterKeyId;
- try {
- container = new LocalStackContainer(LOCALSTACK_IMAGE_NAME).withServices(Service.KMS);
- container.start();
-
- URI endpointOverride = container.getEndpointOverride(EnabledService.named(Service.KMS.getName()));
-
- StaticCredentialsProvider staticCredentials = StaticCredentialsProvider
- .create(AwsBasicCredentials.create("accesskey", "secretKey"));
-
- client = KmsClient.builder()
- .endpointOverride(endpointOverride)
- .credentialsProvider(staticCredentials)
- .httpClientBuilder(UrlConnectionHttpClient.builder())
- .region(Region.US_EAST_1).build();
-
- masterKeyId = client.createKey().keyMetadata().keyId();
- client.generateDataKey(r -> r.keyId(masterKeyId).keySpec(DataKeySpec.AES_256));
-
-
- Map properties = new HashMap<>();
- properties.put("quarkus.kms.endpoint-override", endpointOverride.toString());
- properties.put("quarkus.kms.aws.region", "us-east-1");
- properties.put("quarkus.kms.aws.credentials.type", "static");
- properties.put("quarkus.kms.aws.credentials.static-provider.access-key-id", "accessKey");
- properties.put("quarkus.kms.aws.credentials.static-provider.secret-access-key", "secretKey");
- properties.put("key.arn", masterKeyId);
-
- return properties;
- } catch (Exception e) {
- e.printStackTrace();
- throw new RuntimeException("Could not start KMS server", e);
- }
- }
-
- @Override
- public void stop() {
- if (container != null) {
- container.close();
- }
- }
-}
diff --git a/amazon-kms-quickstart/src/test/java/org/acme/kms/KmsResourcesTest.java b/amazon-kms-quickstart/src/test/java/org/acme/kms/KmsResourcesTest.java
index 09cba8bcfa..7b0bc560a7 100644
--- a/amazon-kms-quickstart/src/test/java/org/acme/kms/KmsResourcesTest.java
+++ b/amazon-kms-quickstart/src/test/java/org/acme/kms/KmsResourcesTest.java
@@ -5,7 +5,6 @@
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.notNullValue;
-import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
import jakarta.ws.rs.core.HttpHeaders;
import jakarta.ws.rs.core.MediaType;
@@ -14,7 +13,6 @@
import org.junit.jupiter.params.provider.ValueSource;
@QuarkusTest
-@QuarkusTestResource(KmsResource.class)
public class KmsResourcesTest {
private final static String TEST_TEXT = "Quarkus is awsome";
diff --git a/amazon-kms-quickstart/src/test/resources/application.properties b/amazon-kms-quickstart/src/test/resources/application.properties
new file mode 100644
index 0000000000..02c4c8c133
--- /dev/null
+++ b/amazon-kms-quickstart/src/test/resources/application.properties
@@ -0,0 +1,2 @@
+quarkus.aws.devservices.localstack.init-scripts-classpath=localstack-init
+quarkus.aws.devservices.localstack.init-completion-msg=#### Tests init completed
\ No newline at end of file
diff --git a/amazon-kms-quickstart/src/test/resources/localstack-init/01_create_key.sh b/amazon-kms-quickstart/src/test/resources/localstack-init/01_create_key.sh
new file mode 100755
index 0000000000..b3ff87e0c4
--- /dev/null
+++ b/amazon-kms-quickstart/src/test/resources/localstack-init/01_create_key.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+# Generate a KMS key
+key_id=$(awslocal kms create-key --query KeyMetadata.KeyId --output text)
+# Set an alias for the KMS key
+awslocal kms create-alias --alias-name "alias/quarkus" --target-key-id $key_id
diff --git a/amazon-kms-quickstart/src/test/resources/localstack-init/99_completed.sh b/amazon-kms-quickstart/src/test/resources/localstack-init/99_completed.sh
new file mode 100755
index 0000000000..bc887a888f
--- /dev/null
+++ b/amazon-kms-quickstart/src/test/resources/localstack-init/99_completed.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+echo "#### Tests init completed"
diff --git a/amazon-s3-quickstart/README.md b/amazon-s3-quickstart/README.md
index 8d39b48b6c..ed3c78d23c 100644
--- a/amazon-s3-quickstart/README.md
+++ b/amazon-s3-quickstart/README.md
@@ -1,30 +1,38 @@
-# Quarkus demo: AWS S3 Client
+# Quarkus demo: Amazon S3 Client
-This example showcases how to use the AWS S3 client with Quarkus. As a prerequisite install [AWS Command line interface](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html).
+This example showcases how to use the AWS S3 client with Quarkus.
-# Run the demo in dev mode
+## Run the Demo in Dev Mode
-- Run `./mvnw clean package` and then `java -jar ./target/quarkus-app/quarkus-run.jar`
-- In dev mode `./mvnw clean quarkus:dev`
+- Run `./mvnw clean quarkus:dev`
Go to `http://localhost:8080/s3.html`, it should show a simple App to manage files on your Bucket.
You can upload files to the bucket via the form.
Alternatively, go to `http://localhost:8080/async-s3.html` with the simple App communicating with Async resources.
-# Running in native (using localstack)
+# Using LocalStack
-## S3 local instance
+As a prerequisite, install the [AWS Command Line Interface](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html).
-Start localstack:
-`docker run --rm --name local-s3 -p 8008:4566 -e SERVICES=s3 -e EAGER_SERVICE_LOADING=1 -e START_WEB=0 -d localstack/localstack`
+Start LocalStack:
-S3 listens on `localhost:8008` for REST endpoints.
+ ```sh
+ docker run \
+ --rm \
+ --name local-s3 \
+ -p 4566:4566 \
+ locals
+
+S3 listens on `localhost:4566` for REST endpoints.
Create an AWS profile for your local instance using AWS CLI:
+```sh
+aws configure --profile localstack
```
-$ aws configure --profile localstack
+
+```plain
AWS Access Key ID [None]: test-key
AWS Secret Access Key [None]: test-secret
Default region name [None]: us-east-1
@@ -34,84 +42,131 @@ Default output format [None]:
## Create bucket
Create a S3 bucket using AWS CLI and the localstack profile.
-`aws s3 mb s3://quarkus.s3.quickstart --profile localstack --endpoint-url=http://localhost:8008`
+
+```sh
+aws s3 mb s3://quarkus.s3.quickstart --profile localstack --endpoint-url=http://localhost:4566`
+```
+
+## Run the demo
+
+You can compile the application and run it with:
+
+```sh
+./mvnw install
+AWS_PROFILE=localstack java -Dquarkus.s3.endpoint-override=http://localhost:4566 -jar ./target/quarkus-app/quarkus-run.jar
+```
+
+Go to `http://localhost:8080/s3.html` or `http://localhost:8080/async-s3.html`, to test the application.
+
+## Running in native
You can compile the application into a native executable using:
-`./mvnw clean package -Pnative`
+```sh
+./mvnw install -Dnative
+```
-and run with:
+And run it with:
-AWS_PROFILE=localstack `./target/amazon-s3-quickstart-1.0.0-SNAPSHOT-runner` -Dquarkus.s3.endpoint-override=http://localhost:8008 -Dquarkus.s3.path-style-access=true
+```sh
+AWS_PROFILE=localstack ./target/amazon-s3-quickstart-1.0.0-SNAPSHOT-runner -Dquarkus.s3.endpoint-override=http://localhost:4566
+```
-# Running native in container (using localstack)
+# Running native in container
-Build a native image in container by running:
-`./mvnw package -Pnative -Dnative-image.docker-build=true`
+Build a native image in a container by running:
-Build a docker image:
-`docker build -f src/main/docker/Dockerfile.native -t quarkus/amazon-s3-quickstart .`
+```sh
+./mvnw install -Dnative -DskipTests -Dquarkus.native.container-build=true
+```
-Create a network that connects your container with localstack
-`docker network create localstack`
+Build a Docker image:
-Stop your localstack container you started at the beginning
-`docker stop local-s3`
+```sh
+docker build -f src/main/docker/Dockerfile.native -t quarkus/amazon-s3-quickstart .
+```
-Start localstack and connect to the network
-`docker run --rm --network=localstack --name localstack -p 8008:4566 -e SERVICES=s3 -e EAGER_SERVICE_LOADING=1 -e START_WEB=0 -d localstack/localstack`
+Create a network that connects your container with LocalStack:
+
+```sh
+docker network create localstack
+```
+
+Stop your LocalStack container you started at the beginning:
+
+```sh
+docker stop local-s3
+```
+
+Start LocalStack and connect to the network:
+
+```sh
+docker run \
+ --rm \
+ --name local-s3 \
+ --network=localstack \
+ -p 4566:4566 \
+ localstack/localstack
+```
Create a S3 bucket using AWS CLI and the localstack profile.
-`aws s3 mb s3://quarkus.s3.quickstart --profile localstack --endpoint-url=http://localhost:8008`
-Run quickstart container connected to that network (note that we're using internal port of the S3 localstack)
-`docker run -i --rm --network=localstack -p 8080:8080 -e quarkus.s3.endpoint-override=http://localstack:4566 -e quarkus.s3.path-style-access=true -e quarkus.s3.aws.region=us-east-1 -e quarkus.s3.aws.credentials.type=static -e quarkus.s3.aws.credentials.static-provider.access-key-id=test-key -e quarkus.s3.aws.credentials.static-provider.secret-access-key=test-secret quarkus/amazon-s3-quickstart`
+```sh
+aws s3 mb s3://quarkus.s3.quickstart --profile localstack --endpoint-url=http://localhost:4566`
+```
-Go to `http://localhost:8080/s3.html` or `http://localhost:8080/async-s3.html`
+Run the Quickstart container connected to that network (note that we're using the internal port of the LocalStack container):
+
+```sh
+docker run -i --rm --network=localstack \
+ -p 8080:8080 \
+ -e QUARKUS_S3_ENDPOINT_OVERRIDE="http://local-s3:4566" \
+ -e QUARKUS_S3_AWS_REGION="us-east-1" \
+ -e QUARKUS_S3_AWS_CREDENTIALS_TYPE="static" \
+ -e QUARKUS_S3_AWS_CREDENTIALS_STATIC_PROVIDER_ACCESS_KEY_ID="test-key" \
+ -e QUARKUS_S3_AWS_CREDENTIALS_STATIC_PROVIDER_SECRET_ACCESS_KEY="test-secret" \
+ -e QUARKUS_S3_PATH_STYLE_ACCESS="true" \
+ quarkus/amazon-s3-quickstart
+```
+
+Go to `http://localhost:8080/s3.html` or `http://localhost:8080/async-s3.html`, to test the application.
-Clean up your environment
-`docker stop localstack`
+Clean up your environment:
-`docker network rm localstack`
+```sh
+docker stop local-s3
+docker network rm localstack
+```
# Using AWS account
-Before you can use the AWS SDKs with S3, you must get an AWS access key ID and secret access key.
+Before you can use the AWS SDKs with S3, you must get an AWS access key ID and secret access key.
For more information, see:
- [Sign up for AWS and Create an IAM User](https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/signup-create-iam-user.html)
- [Set Up AWS Credentials and Region for Development](https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/setup-credentials.html)
-Create a S3 bucket using AWS CLI using your default AWS profile
-`aws s3 mb s3://quarkus.s3.quickstart.11.22.33`
-**NOTE: Please assure the bucket name you created is unique across AWS S3.
-See [Amazon S3 Bucket Naming Requirements](https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html#bucketnamingrules)**
-
-## Run demo
+Create a S3 bucket using AWS CLI and the localstack profile.
-You can run the demo the same way as for a local instance, but you need to change the `application.properties`.
+```sh
+aws s3 mb s3://quarkus.s3.12.345.99`
+```
-- remove or comment out `quarkus.s3.endpoint-override` - as you are going to communicate with the AWS service now
-- remove or comment out `quarkus.s3.aws.region` - region is going to be retrieved via the default providers chain in the following order:
- - `aws.region` system property
- - `region` property from the profile file
-- remove or comment out `quarkus.s3.aws.credentials.type` - if not configured the client uses `default` credentials provider chain that looks for credentials in this order:
- - Java System Properties - `aws.accessKeyId` and `aws.secretKey`
- - Environment Variables - `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`
- - Credential profiles file at the default location (`~/.aws/credentials`) shared by all AWS SDKs and the AWS CLI
-
-Build the application
+**NOTE: Please assure the bucket name you created is unique across AWS S3 and update .
+See [Amazon S3 Bucket Naming Requirements](https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html#bucketnamingrules)**
-`./mvnw clean package`
-
-And then run it
+## Run demo
-`java -jar ./target/quarkus-app/quarkus-run.jar -Dbucket.name=quarkus.s3.12.345.99`
+You can run the demo the same way as for a local instance, but you don't need to override the endpoint as you are going to communicate with the AWS service with the default AWS profile.
-Or, build as native executable
+Run it:
-`./mvnw clean package -Pnative`
+```sh
+java -Dbucket.name=quarkus.s3.12.345.99 -jar ./target/quarkus-app/quarkus-run.jar
+```
-And then run it
+Or, run it natively:
-`./target/amazon-s3-quickstart-1.0.0-SNAPSHOT-runner -Dbucket.name=quarkus.s3.12.345.99`
+```sh
+./target/amazon-s3-quickstart-1.0.0-SNAPSHOT-runner -Dbucket.name=quarkus.s3.12.345.99
+```
diff --git a/amazon-s3-quickstart/pom.xml b/amazon-s3-quickstart/pom.xml
index 9f5114ad23..b33cba7888 100644
--- a/amazon-s3-quickstart/pom.xml
+++ b/amazon-s3-quickstart/pom.xml
@@ -16,7 +16,7 @@
UTF-8
11
11
- 2.5.3
+ 2.7.2
diff --git a/amazon-ses-quickstart/README.md b/amazon-ses-quickstart/README.md
index f19fbe0abb..32c6083a7a 100644
--- a/amazon-ses-quickstart/README.md
+++ b/amazon-ses-quickstart/README.md
@@ -1,67 +1,187 @@
# Quarkus demo: Amazon SES Client
-This example showcases how to use the AWS SES client with Quarkus. As a prerequisite install [AWS Command line interface](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html).
-Despite the fact, this example uses local AWS SES for integration test purposes, we encourage you to use SES from the AWS account as it allows you to send emails.
+This example showcases how to use the AWS SES client with Quarkus.
+Despite the fact, this example uses local AWS SES for integration test purposes, we encourage you to use SES from the AWS account as it allows you to send emails.
Local instance of SES only mocks service APIs and doesn't send any emails.
-# AWS SES local instance
+## Run the Demo in Dev Mode
-Just run it as follows in order to start SES locally:
-`docker run --rm --name local-ses -p 8012:4579 -e SERVICES=ses -e START_WEB=0 -d localstack/localstack:0.11.1`
-SES listens on `localhost:8012` for REST endpoints.
+- Run `./mvnw clean quarkus:dev`
+
+## Send an email
+
+Using sync endpoint
+
+```sh
+curl -XPOST -H"Content-type: application/json" http://localhost:8080/sync/email -d'{"from": "from-quarkus@example.com", "to": "to-quarkus@example.com", "subject": "Hello from Quarkus", "body": "Quarkus is awsome"}'
+```
+
+Or async endpoint
+
+```sh
+curl -XPOST -H"Content-type: application/json" http://localhost:8080/async/email -d'{"from": "from-quarkus@example.com", "to": "to-quarkus@example.com", "subject": "Hello from Quarkus", "body": "Quarkus is awsome"}'
+```
+
+As a result, you will see the ID of the message as SES returned. E.g.:
+
+```plain
+010701724bec5607-e34882d5-a8ce-4f2b-a837-da75989e43c0-000000
+```
+
+# Using LocalStack
+
+As a prerequisite, install the [AWS Command Line Interface](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html).
+
+Start LocalStack:
+
+ ```sh
+ docker run \
+ --rm \
+ --name local-ses \
+ -p 4566:4566 \
+ localstack/localstack
+```
+
+SES listens on `localhost:4566` for REST endpoints.
Create an AWS profile for your local instance using AWS CLI:
+```sh
+aws configure --profile localstack
```
-$ aws configure --profile localstack
+
+```plain
AWS Access Key ID [None]: test-key
AWS Secret Access Key [None]: test-secret
Default region name [None]: us-east-1
Default output format [None]:
```
-## Setup AWS SES
+## Verify email addresses
+
+Verify the email addresses you're going to use when running the application.
-Verify the email addresses you're going to use when running the application. You need to verify both the sender and recipient email addresses.
+```sh
+aws ses verify-email-identity --email-address from-quarkus@example.com --profile localstack --endpoint-url=http://localhost:4566
```
-aws ses verify-email-identity --email-address --profile localstack --endpoint-url=http://localhost:8012
+
+## Run the demo
+
+You can compile the application and run it with:
+
+```sh
+./mvnw install
+AWS_PROFILE=localstack java -Dquarkus.ses.endpoint-override=http://localhost:4566 -jar ./target/quarkus-app/quarkus-run.jar
```
-If you're about to use your AWS account instead, verify all email addresses using your account profile.
+
+You can now replay the `curl` commands above.
+
+## Running in native
+
+You can compile the application into a native executable using:
+
+```sh
+./mvnw install -Dnative
```
-aws ses verify-email-identity --email-address
+
+And run it with:
+
+```sh
+AWS_PROFILE=localstack ./target/amazon-ses-quickstart-1.0.0-SNAPSHOT-runner -Dquarkus.ses.endpoint-override=http://localhost:4566
```
-You need to repeat that command for each email address you're going to use.
-# Run the demo on dev mode
+# Running native in container
-If you want to run the demo using your AWS account, comment out all the `quarkus.ses` properties, so your default profile AWS key and region will be used.
+Build a native image in a container by running:
-- Run `./mvnw clean package` and then `java -jar ./target/quarkus-app/quarkus-run.jar`
-- In dev mode `./mvnw clean quarkus:dev`
+```sh
+./mvnw install -Dnative -DskipTests -Dquarkus.native.container-build=true
+```
-## Send an email
-Using sync endpoint
+Build a Docker image:
+
+```sh
+docker build -f src/main/docker/Dockerfile.native -t quarkus/amazon-ses-quickstart .
```
-curl -XPOST -H"Content-type: application/json" http://localhost:8080/sync/email -d'{"from": "", "to": "", "subject": "Hello from Quarkus", "body": "Quarkus is awsome"}'
+
+Create a network that connects your container with LocalStack:
+
+```sh
+docker network create localstack
```
-Or async endpoint
+
+Stop your LocalStack container you started at the beginning:
+
+```sh
+docker stop local-ses
```
-curl -XPOST -H"Content-type: application/json" http://localhost:8080/async/email -d'{"from": "", "to": "", "subject": "Hello from Quarkus", "body": "Quarkus is awsome"}'
+
+Start LocalStack and connect to the network:
+
+```sh
+docker run \
+ --rm \
+ --name local-ses \
+ --network=localstack \
+ -p 4566:4566 \
+ localstack/localstack
```
-As a result, you will see the ID of the message as SES returned. E.g.:
+Verify the email addresses:
+
+```sh
+aws ses verify-email-identity --email-address from-quarkus@example.com --profile localstack --endpoint-url=http://localhost:4566
```
-010701724bec5607-e34882d5-a8ce-4f2b-a837-da75989e43c0-000000
+
+Run the Quickstart container connected to that network (note that we're using the internal port of the LocalStack container):
+
+```sh
+docker run -i --rm --network=localstack \
+ -p 8080:8080 \
+ -e QUARKUS_SES_ENDPOINT_OVERRIDE="http://local-ses:4566" \
+ -e QUARKUS_SES_AWS_REGION="us-east-1" \
+ -e QUARKUS_SES_AWS_CREDENTIALS_TYPE="static" \
+ -e QUARKUS_SES_AWS_CREDENTIALS_STATIC_PROVIDER_ACCESS_KEY_ID="test-key" \
+ -e QUARKUS_SES_AWS_CREDENTIALS_STATIC_PROVIDER_SECRET_ACCESS_KEY="test-secret" \
+ quarkus/amazon-ses-quickstart
+```
+
+Replay `curl` commands from above:
+
+Clean up your environment:
+
+```sh
+docker stop local-ses
+docker network rm localstack
+```
+
+# Using AWS account
+
+Before you can use the AWS SDKs with SES, you must get an AWS access key ID and secret access key.
+For more information, see:
+ - [Sign up for AWS and Create an IAM User](https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/signup-create-iam-user.html)
+ - [Set Up AWS Credentials and Region for Development](https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/setup-credentials.html)
+
+Verify the email addresses:
+
+```sh
+aws ses verify-email-identity --email-address from-quarkus@example.com
```
-Check inbox of the recipient email address for an email you just sent.
+On AWS, verifying email identities or domain identities require additional steps like changing DNS configuration or clicking verification links respectively. Use email address that you can verify.
-# Running in native
+## Run demo
-You can compile the application into a native binary using:
+You can run the demo the same way as for a local instance, but you don't need to override the endpoint as you are going to communicate with the AWS service with the default AWS profile.
-`./mvnw clean install -Pnative`
+Run it:
-and run with:
+```sh
+java -jar ./target/quarkus-app/quarkus-run.jar
+```
+
+Or, run it natively:
-`./target/amazon-ses-quickstart-1.0.0-SNAPSHOT-runner`
+```sh
+./target/amazon-ses-quickstart-1.0.0-SNAPSHOT-runner
+```
diff --git a/amazon-ses-quickstart/pom.xml b/amazon-ses-quickstart/pom.xml
index cc28676ffd..804a83e3c5 100644
--- a/amazon-ses-quickstart/pom.xml
+++ b/amazon-ses-quickstart/pom.xml
@@ -16,8 +16,7 @@
UTF-8
11
11
- 2.5.3
- 1.12.57
+ 2.7.2
@@ -71,23 +70,6 @@
rest-assured
test
-
- org.testcontainers
- localstack
- test
-
-
- org.testcontainers
- junit-jupiter
- test
-
-
-
- com.amazonaws
- aws-java-sdk-core
- ${awssdk.testcontainers.version}
- test
-
diff --git a/amazon-ses-quickstart/src/main/resources/application.properties b/amazon-ses-quickstart/src/main/resources/application.properties
index c4ed4ee5a4..e69de29bb2 100644
--- a/amazon-ses-quickstart/src/main/resources/application.properties
+++ b/amazon-ses-quickstart/src/main/resources/application.properties
@@ -1,6 +0,0 @@
-quarkus.ses.endpoint-override=http://localhost:8012
-
-quarkus.ses.aws.region=us-east-1
-quarkus.ses.aws.credentials.type=static
-quarkus.ses.aws.credentials.static-provider.access-key-id=test-key
-quarkus.ses.aws.credentials.static-provider.secret-access-key=test-secret
\ No newline at end of file
diff --git a/amazon-ses-quickstart/src/test/java/org/acme/ses/SesResource.java b/amazon-ses-quickstart/src/test/java/org/acme/ses/SesResource.java
deleted file mode 100644
index 35e4300284..0000000000
--- a/amazon-ses-quickstart/src/test/java/org/acme/ses/SesResource.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.acme.ses;
-
-import java.net.URI;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.testcontainers.DockerClientFactory;
-import org.testcontainers.containers.localstack.LocalStackContainer;
-import org.testcontainers.containers.localstack.LocalStackContainer.EnabledService;
-import org.testcontainers.containers.localstack.LocalStackContainer.Service;
-import org.testcontainers.utility.DockerImageName;
-
-import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
-import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
-import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
-import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
-import software.amazon.awssdk.regions.Region;
-import software.amazon.awssdk.services.ses.SesClient;
-
-public class SesResource implements QuarkusTestResourceLifecycleManager {
-
- private static final DockerImageName LOCALSTACK_IMAGE_NAME = DockerImageName.parse("localstack/localstack")
- .withTag("0.12.17");
-
- public final static String FROM_EMAIL = "from-quarkus@example.com";
- public final static String TO_EMAIL = "to-quarkus@example.com";
-
- private LocalStackContainer container;
- private SesClient client;
-
- @Override
- public Map start() {
- DockerClientFactory.instance().client();
- try {
- container = new LocalStackContainer(LOCALSTACK_IMAGE_NAME).withServices(Service.SES);
- container.start();
-
- URI endpointOverride = container.getEndpointOverride(EnabledService.named(Service.SES.getName()));
-
- StaticCredentialsProvider staticCredentials = StaticCredentialsProvider
- .create(AwsBasicCredentials.create("accesskey", "secretKey"));
-
- client = SesClient.builder()
- .endpointOverride(endpointOverride)
- .credentialsProvider(staticCredentials)
- .httpClientBuilder(UrlConnectionHttpClient.builder())
- .region(Region.US_EAST_1).build();
-
- client.verifyEmailIdentity(req -> req.emailAddress(FROM_EMAIL));
- client.verifyEmailIdentity(req -> req.emailAddress(TO_EMAIL));
-
- Map properties = new HashMap<>();
- properties.put("quarkus.ses.endpoint-override", endpointOverride.toString());
- properties.put("quarkus.ses.aws.region", "us-east-1");
- properties.put("quarkus.ses.aws.credentials.type", "static");
- properties.put("quarkus.ses.aws.credentials.static-provider.access-key-id", "accessKey");
- properties.put("quarkus.ses.aws.credentials.static-provider.secret-access-key", "secretKey");
-
- return properties;
- } catch (Exception e) {
- e.printStackTrace();
- throw new RuntimeException("Could not start localstack server", e);
- }
- }
-
- @Override
- public void stop() {
- if (container != null) {
- container.close();
- }
- }
-}
diff --git a/amazon-ses-quickstart/src/test/java/org/acme/ses/SesResourcesTest.java b/amazon-ses-quickstart/src/test/java/org/acme/ses/SesResourcesTest.java
index 8507ecce08..8caa582fcf 100644
--- a/amazon-ses-quickstart/src/test/java/org/acme/ses/SesResourcesTest.java
+++ b/amazon-ses-quickstart/src/test/java/org/acme/ses/SesResourcesTest.java
@@ -3,7 +3,6 @@
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.any;
-import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
import jakarta.ws.rs.core.HttpHeaders;
import jakarta.ws.rs.core.MediaType;
@@ -12,11 +11,13 @@
import org.junit.jupiter.params.provider.ValueSource;
@QuarkusTest
-@QuarkusTestResource(SesResource.class)
public class SesResourcesTest {
private static final String JSON = "{\"from\":\"%s\", \"to\":\"%s\", \"subject\":\"%s\", \"body\":\"%s\"}";
+ private final static String FROM_EMAIL = "from-quarkus@example.com";
+ private final static String TO_EMAIL = "to-quarkus@example.com";
+
@ParameterizedTest
@ValueSource(strings = {"sync", "async"})
void testResource(final String testedResource) {
@@ -25,7 +26,7 @@ void testResource(final String testedResource) {
given()
.pathParam("resource", testedResource)
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
- .body(String.format(JSON, SesResource.FROM_EMAIL, SesResource.TO_EMAIL, "Hello from Quarkus", "Quarkus is awsome"))
+ .body(String.format(JSON, FROM_EMAIL, TO_EMAIL, "Hello from Quarkus", "Quarkus is awsome"))
.when()
.post("/{resource}/email")
.then()
diff --git a/amazon-ses-quickstart/src/test/resources/application.properties b/amazon-ses-quickstart/src/test/resources/application.properties
new file mode 100644
index 0000000000..02c4c8c133
--- /dev/null
+++ b/amazon-ses-quickstart/src/test/resources/application.properties
@@ -0,0 +1,2 @@
+quarkus.aws.devservices.localstack.init-scripts-classpath=localstack-init
+quarkus.aws.devservices.localstack.init-completion-msg=#### Tests init completed
\ No newline at end of file
diff --git a/amazon-ses-quickstart/src/test/resources/localstack-init/01_verify_email.sh b/amazon-ses-quickstart/src/test/resources/localstack-init/01_verify_email.sh
new file mode 100755
index 0000000000..3180c92d85
--- /dev/null
+++ b/amazon-ses-quickstart/src/test/resources/localstack-init/01_verify_email.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+awslocal ses verify-email-identity --email from-quarkus@example.com
diff --git a/amazon-ses-quickstart/src/test/resources/localstack-init/99_completed.sh b/amazon-ses-quickstart/src/test/resources/localstack-init/99_completed.sh
new file mode 100755
index 0000000000..bc887a888f
--- /dev/null
+++ b/amazon-ses-quickstart/src/test/resources/localstack-init/99_completed.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+echo "#### Tests init completed"
diff --git a/amazon-sns-quickstart/README.md b/amazon-sns-quickstart/README.md
index d37a7c64ca..94f7adc72d 100644
--- a/amazon-sns-quickstart/README.md
+++ b/amazon-sns-quickstart/README.md
@@ -1,17 +1,88 @@
-# Quarkus demo: SNS Client
+# Quarkus demo: Amazon SNS Client
-This example showcases how to use the AWS SNS client with Quarkus. As a prerequisite install Install [AWS Command line interface](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html).
+This example showcases how to use the AWS SNS client with Quarkus.
-# AWS SNS local instance
+## Run the Demo in Dev Mode
- Just run it as follows in order to start SNS locally:
-`docker run --rm --name local-sns -p 8009:4575 -e SERVICES=sns -e START_WEB=0 -d localstack/localstack:0.11.1`
-SNS listens on `localhost:8009` for REST endpoints.
+- Run `./mvnw clean quarkus:dev`
+
+## Publish messages to the topic
+
+Shoot with a couple of quarks using sync endpoint
+
+```sh
+curl -XPOST -H'Content-type: application/json' http://localhost:8080/sync/cannon/shoot -d'{"flavor": "Charm", "spin": "1/2"}'
+curl -XPOST -H'Content-type: application/json' http://localhost:8080/sync/cannon/shoot -d'{"flavor": "Strange", "spin": "1/2"}'
+```
+
+And using async endpoint
+
+```sh
+curl -XPOST -H'Content-type: application/json' http://localhost:8080/async/cannon/shoot -d'{"flavor": "Upper", "spin": "1/2"}'
+curl -XPOST -H'Content-type: application/json' http://localhost:8080/async/cannon/shoot -d'{"flavor": "Down", "spin": "1/2"}'
+```
+
+And observe logs that both endpoints (sync & async) receives published messages
+
+```log
+2020-05-13 11:34:02,366 INFO [org.acm.sns.QuarksShieldSyncResource] (executor-thread-31) Quark[Charm, 1/2] collision with the shield.
+2020-05-13 11:34:02,378 INFO [org.acm.sns.QuarksShieldAsyncResource] (executor-thread-31) Quark[Charm, 1/2] collision with the shield.
+2020-05-13 11:34:02,383 INFO [org.acm.sns.QuarksCannonSyncResource] (executor-thread-32) Fired Quark[Charm, 1/2}]
+2020-05-13 11:34:18,852 INFO [org.acm.sns.QuarksShieldSyncResource] (executor-thread-31) Quark[Strange, 1/2] collision with the shield.
+2020-05-13 11:34:18,864 INFO [org.acm.sns.QuarksShieldAsyncResource] (executor-thread-31) Quark[Strange, 1/2] collision with the shield.
+2020-05-13 11:34:18,870 INFO [org.acm.sns.QuarksCannonSyncResource] (executor-thread-32) Fired Quark[Strange, 1/2}]
+2020-05-13 11:34:26,973 INFO [org.acm.sns.QuarksShieldSyncResource] (executor-thread-32) Quark[Upper, 1/2] collision with the shield.
+2020-05-13 11:34:26,984 INFO [org.acm.sns.QuarksShieldAsyncResource] (executor-thread-32) Quark[Upper, 1/2] collision with the shield.
+2020-05-13 11:34:26,992 INFO [org.acm.sns.QuarksCannonAsyncResource] (sdk-async-response-11-0) Fired Quark[Upper, 1/2}]
+2020-05-13 11:34:36,025 INFO [org.acm.sns.QuarksShieldSyncResource] (executor-thread-32) Quark[Down, 1/2] collision with the shield.
+2020-05-13 11:34:36,033 INFO [org.acm.sns.QuarksShieldAsyncResource] (executor-thread-32) Quark[Down, 1/2] collision with the shield.
+2020-05-13 11:34:36,038 INFO [org.acm.sns.QuarksCannonAsyncResource] (sdk-async-response-11-1) Fired Quark[Down, 1/2}]
+```
+
+## Unsubscribe endpoint from the topic
+
+Unsubscribe sync endpoint
+
+```sh
+curl -XPOST -H'Content-type: application/json' http://localhost:8080/sync/shield/unsubscribe
+```
+
+Unsubscribe async endpoint
+
+```sh
+curl -XPOST -H'Content-type: application/json' http://localhost:8080/async/shield/unsubscribe
+```
+
+And observe the logs to see that endpoint is unsubscribed and will stop receiving new messages from the topic.
+
+```log
+2020-05-13 11:39:21,744 INFO [org.acm.sns.QuarksShieldAsyncResource] (sdk-async-response-4-3) Unsubscribed quarks shield for id = arn:aws:sns:us-east-1:000000000000:QuarksCollider:e1a5c39d-d5fe-498a-b0bb-e2db14dc38b9
+2020-05-13 11:39:28,085 INFO [org.acm.sns.QuarksShieldSyncResource] (executor-thread-1) Unsubscribed quarks shield for id = arn:aws:sns:us-east-1:000000000000:QuarksCollider:90576a46-46d9-4f1a-a8d0-53aa015fffc6
+```
+
+# Using LocalStack
+
+As a prerequisite, install the [AWS Command Line Interface](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html).
+
+Start LocalStack:
+
+ ```sh
+ docker run \
+ --rm \
+ --name local-sns \
+ -p 4566:4566 \
+ localstack/localstack
+```
+
+SNS listens on `localhost:4566` for REST endpoints.
Create an AWS profile for your local instance using AWS CLI:
+```sh
+aws configure --profile localstack
```
-$ aws configure --profile localstack
+
+```plain
AWS Access Key ID [None]: test-key
AWS Secret Access Key [None]: test-secret
Default region name [None]: us-east-1
@@ -19,99 +90,154 @@ Default output format [None]:
```
## Create topic
-Create a topic using AWS CLI with the localstack profile and store the generated ARN in the environment variable
-```
-$> TOPIC_ARN=`aws sns create-topic --name=QuarksCollider --profile localstack --endpoint-url=http://localhost:8009`
+
+Create a topic using AWS CLI with the localstack profile
+
+```sh
+aws sns create-topic --name=quarkus --profile localstack --endpoint-url=http://localhost:4566
```
-# Run the demo on dev mode
-- Run `./mvnw clean package` and then `java -Dtopic.arn=$TOPIC_ARN -jar ./target/quarkus-app/quarkus-run.jar`
-- In dev mode `./mvnw clean quarkus:dev -Dtopic.arn=$TOPIC_ARN`
+## Run the demo
+
+You can compile the application and run it with:
+
+```sh
+./mvnw install
+AWS_PROFILE=localstack java -Dquarkus.sns.endpoint-override=http://localhost:4566 -jar ./target/quarkus-app/quarkus-run.jar
+```
## Subscribe endpoint for topic notifications
+
Subscribe sync endpoint
-`curl -XPOST -H'Content-type: application/json' http://localhost:8080/sync/shield/subscribe`
+
+```sh
+curl -XPOST -H'Content-type: application/json' http://localhost:8080/sync/shield/subscribe
+```
+
Subscribe async endpoint
-`curl -XPOST -H'Content-type: application/json' http://localhost:8080/async/shield/subscribe`
-See the Quarkus logs for messages similar to below
+```sh
+curl -XPOST -H'Content-type: application/json' http://localhost:8080/async/shield/subscribe
```
+
+See the Quarkus logs for messages similar to below
+
+```log
2020-05-13 11:31:52,415 INFO [org.acm.sns.QuarksShieldSyncResource] (executor-thread-2) Subscription confirmed. Ready for quarks collisions.
2020-05-13 11:31:52,434 INFO [org.acm.sns.QuarksShieldSyncResource] (executor-thread-1) Subscribed Quarks shield : arn:aws:sns:us-east-1:000000000000:QuarksCollider:b4121fa3-76e1-4b45-983d-b808561e7700
2020-05-13 11:31:58,847 INFO [org.acm.sns.QuarksShieldAsyncResource] (sdk-async-response-5-0) Subscription confirmed. Ready for quarks collisions.
2020-05-13 11:31:58,855 INFO [org.acm.sns.QuarksShieldAsyncResource] (sdk-async-response-5-1) Subscribed Quarks shield with id = arn:aws:sns:us-east-1:000000000000:QuarksCollider:30c06833-a53b-4132-92cf-15017b076a9e
```
-## Publish messages to the topic
-Shoot with a couple of quarks using sync endpoint
+## Running in native
+
+You can compile the application into a native executable using:
+
+```sh
+./mvnw install -Dnative
```
-curl -XPOST -H'Content-type: application/json' http://localhost:8080/sync/cannon/shoot -d'{"flavor": "Charm", "spin": "1/2"}'
-curl -XPOST -H'Content-type: application/json' http://localhost:8080/sync/cannon/shoot -d'{"flavor": "Strange", "spin": "1/2"}'
+
+And run it with:
+
+```sh
+AWS_PROFILE=localstack ./target/amazon-sns-quickstart-1.0.0-SNAPSHOT-runner -Dquarkus.sns.endpoint-override=http://localhost:4566
```
-And using async endpoint
+
+# Running native in container
+
+Build a native image in a container by running:
+
+```sh
+./mvnw install -Dnative -DskipTests -Dquarkus.native.container-build=true
```
-curl -XPOST -H'Content-type: application/json' http://localhost:8080/async/cannon/shoot -d'{"flavor": "Upper", "spin": "1/2"}'
-curl -XPOST -H'Content-type: application/json' http://localhost:8080/async/cannon/shoot -d'{"flavor": "Down", "spin": "1/2"}'
+
+Build a Docker image:
+
+```sh
+docker build -f src/main/docker/Dockerfile.native -t quarkus/amazon-sns-quickstart .
```
-And observe logs that both endpoints (sync & async) receives published messages
+Create a network that connects your container with LocalStack:
+
+```sh
+docker network create localstack
```
-2020-05-13 11:34:02,366 INFO [org.acm.sns.QuarksShieldSyncResource] (executor-thread-31) Quark[Charm, 1/2] collision with the shield.
-2020-05-13 11:34:02,378 INFO [org.acm.sns.QuarksShieldAsyncResource] (executor-thread-31) Quark[Charm, 1/2] collision with the shield.
-2020-05-13 11:34:02,383 INFO [org.acm.sns.QuarksCannonSyncResource] (executor-thread-32) Fired Quark[Charm, 1/2}]
-2020-05-13 11:34:18,852 INFO [org.acm.sns.QuarksShieldSyncResource] (executor-thread-31) Quark[Strange, 1/2] collision with the shield.
-2020-05-13 11:34:18,864 INFO [org.acm.sns.QuarksShieldAsyncResource] (executor-thread-31) Quark[Strange, 1/2] collision with the shield.
-2020-05-13 11:34:18,870 INFO [org.acm.sns.QuarksCannonSyncResource] (executor-thread-32) Fired Quark[Strange, 1/2}]
-2020-05-13 11:34:26,973 INFO [org.acm.sns.QuarksShieldSyncResource] (executor-thread-32) Quark[Upper, 1/2] collision with the shield.
-2020-05-13 11:34:26,984 INFO [org.acm.sns.QuarksShieldAsyncResource] (executor-thread-32) Quark[Upper, 1/2] collision with the shield.
-2020-05-13 11:34:26,992 INFO [org.acm.sns.QuarksCannonAsyncResource] (sdk-async-response-11-0) Fired Quark[Upper, 1/2}]
-2020-05-13 11:34:36,025 INFO [org.acm.sns.QuarksShieldSyncResource] (executor-thread-32) Quark[Down, 1/2] collision with the shield.
-2020-05-13 11:34:36,033 INFO [org.acm.sns.QuarksShieldAsyncResource] (executor-thread-32) Quark[Down, 1/2] collision with the shield.
-2020-05-13 11:34:36,038 INFO [org.acm.sns.QuarksCannonAsyncResource] (sdk-async-response-11-1) Fired Quark[Down, 1/2}]
+Stop your LocalStack container you started at the beginning:
+
+```sh
+docker stop local-sns
```
-## Unsubscribe endpoint from the topic
-Unsubscribe sync endpoint
-`curl -XPOST -H'Content-type: application/json' http://localhost:8080/sync/shield/unsubscribe`
-Unsubscribe async endpoint
-`curl -XPOST -H'Content-type: application/json' http://localhost:8080/async/shield/unsubscribe`
+Start LocalStack and connect to the network:
-And observe the logs to see that endpoint is unsubscribed and will stop receiving new messages from the topic.
+```sh
+docker run \
+ --rm \
+ --name local-sns \
+ --network=localstack \
+ -p 4566:4566 \
+ localstack/localstack
```
-2020-05-13 11:39:21,744 INFO [org.acm.sns.QuarksShieldAsyncResource] (sdk-async-response-4-3) Unsubscribed quarks shield for id = arn:aws:sns:us-east-1:000000000000:QuarksCollider:e1a5c39d-d5fe-498a-b0bb-e2db14dc38b9
-2020-05-13 11:39:28,085 INFO [org.acm.sns.QuarksShieldSyncResource] (executor-thread-1) Unsubscribed quarks shield for id = arn:aws:sns:us-east-1:000000000000:QuarksCollider:90576a46-46d9-4f1a-a8d0-53aa015fffc6
+
+Create a queue:
+
+```sh
+aws sns create-topic --name=quarkus --profile localstack --endpoint-url=http://localhost:4566
```
-# Running in native
-You can compile the application into a native binary using:
-`./mvnw clean install -Pnative`
-and run with:
-`./target/amazon-sns-quickstart-1.0.0-SNAPSHOT-runner`
+Run the Quickstart container connected to that network (note that we're using the internal port of the LocalStack container):
+
+```sh
+docker run -i --rm --network=localstack \
+ -p 8080:8080 \
+ -e QUARKUS_SNS_ENDPOINT_OVERRIDE="http://local-sns:4566" \
+ -e QUARKUS_SNS_AWS_REGION="us-east-1" \
+ -e QUARKUS_SNS_AWS_CREDENTIALS_TYPE="static" \
+ -e QUARKUS_SNS_AWS_CREDENTIALS_STATIC_PROVIDER_ACCESS_KEY_ID="test-key" \
+ -e QUARKUS_SNS_AWS_CREDENTIALS_STATIC_PROVIDER_SECRET_ACCESS_KEY="test-secret" \
+ quarkus/amazon-sns-quickstart
+```
-# Running native in container
+Replay some `curl` commands from above:
+
+```sh
+curl -XPOST -H'Content-type: application/json' http://localhost:8080/sync/shield/subscribe
+curl -XPOST -H'Content-type: application/json' http://localhost:8080/sync/cannon/shoot -d'{"flavor": "Charm", "spin": "1/2"}'
+```
-Build a native image in container by running:
-`./mvnw package -Pnative -Dnative-image.docker-build=true`
+Clean up your environment:
-Build a docker image:
-`docker build -f src/main/docker/Dockerfile.native -t quarkus/amazon-sns-quickstart .`
+```sh
+docker stop local-sns
+docker network rm localstack
+```
+
+# Using AWS account
-Create a network that connect your container with localstack
-`docker network create localstack`
+Before you can use the AWS SDKs with SNS, you must get an AWS access key ID and secret access key.
+For more information, see:
+ - [Sign up for AWS and Create an IAM User](https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/signup-create-iam-user.html)
+ - [Set Up AWS Credentials and Region for Development](https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/setup-credentials.html)
-Start localstack and connect to the network
-`docker run --rm --network=localstack --name localstack -p 8009:4575 -e SERVICES=sns -e START_WEB=0 -d localstack/localstack:0.11.1`
+Create a topic using AWS CLI and store the generated ARN in an environment variable as we will need to provide it to the our app:
-Stop your localstack container you started at the beginning
-`docker stop local-sns`
+```sh
+TOPIC_ARN=`aws sns create-topic --name=QuarksCollider`
+```
-Run quickstart container connected to `localstack` network (note that we're using internal port of the localstack here)
-`docker run -i --rm --network=localstack -p 8080:8080 quarkus/amazon-sns-quickstart -Dquarkus.sns.endpoint-override=http://localstack:4575`
+## Run demo
-Subscribe an endpoint
-`curl -XPOST -H'Content-type: application/json' http://localhost:8080/sync/shield/subscribe`
+You can run the demo the same way as for a local instance, but you don't need to override the endpoint as you are going to communicate with the AWS service with the default AWS profile.
-Publish a message
-`curl -XPOST -H'Content-type: application/json' http://localhost:8080/sync/cannon/shoot -d'{"flavor": "Charm", "spin": "1/2"}'`
+Run it:
+```sh
+java -Dtopic.arn=$TOPIC_ARN -jar ./target/quarkus-app/quarkus-run.jar
+```
+
+Or, run it natively:
+
+```sh
+./target/amazon-sns-quickstart-1.0.0-SNAPSHOT-runner -Dtopic.arn=$TOPIC_ARN
+```
diff --git a/amazon-sns-quickstart/pom.xml b/amazon-sns-quickstart/pom.xml
index 36fd68465d..b9b8d2560c 100644
--- a/amazon-sns-quickstart/pom.xml
+++ b/amazon-sns-quickstart/pom.xml
@@ -16,8 +16,7 @@
UTF-8
11
11
- 2.5.3
- 1.12.57
+ 2.7.2
@@ -71,23 +70,6 @@
rest-assured
test
-
- org.testcontainers
- localstack
- test
-
-
- org.testcontainers
- junit-jupiter
- test
-
-
-
- com.amazonaws
- aws-java-sdk-core
- ${awssdk.testcontainers.version}
- test
-
diff --git a/amazon-sns-quickstart/src/main/resources/application.properties b/amazon-sns-quickstart/src/main/resources/application.properties
index 2f93f2b8ae..234d421c4f 100644
--- a/amazon-sns-quickstart/src/main/resources/application.properties
+++ b/amazon-sns-quickstart/src/main/resources/application.properties
@@ -1,9 +1,2 @@
-quarkus.sns.endpoint-override=http://localhost:8009
-
-quarkus.sns.aws.region=us-east-1
-quarkus.sns.aws.credentials.type=static
-quarkus.sns.aws.credentials.static-provider.access-key-id=test-key
-quarkus.sns.aws.credentials.static-provider.secret-access-key=test-secret
-
-topic.arn=
+topic.arn=arn:aws:sns:us-east-1:000000000000:quarkus
quarks.shield.base.url=http://host.docker.internal:${quarkus.http.port}
\ No newline at end of file
diff --git a/amazon-sns-quickstart/src/test/java/org/acme/sns/SnsResource.java b/amazon-sns-quickstart/src/test/java/org/acme/sns/SnsResource.java
deleted file mode 100644
index 6ee4495c5f..0000000000
--- a/amazon-sns-quickstart/src/test/java/org/acme/sns/SnsResource.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.acme.sns;
-
-import java.net.URI;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.testcontainers.DockerClientFactory;
-import org.testcontainers.containers.localstack.LocalStackContainer;
-import org.testcontainers.containers.localstack.LocalStackContainer.EnabledService;
-import org.testcontainers.containers.localstack.LocalStackContainer.Service;
-import org.testcontainers.utility.DockerImageName;
-
-import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
-import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
-import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
-import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
-import software.amazon.awssdk.regions.Region;
-import software.amazon.awssdk.services.sns.SnsClient;
-
-public class SnsResource implements QuarkusTestResourceLifecycleManager {
-
- private static final DockerImageName LOCALSTACK_IMAGE_NAME = DockerImageName.parse("localstack/localstack")
- .withTag("0.12.17");
-
- public final static String TOPIC_NAME = "Quarkus";
-
- private LocalStackContainer container;
- private SnsClient client;
-
- @Override
- public Map start() {
- DockerClientFactory.instance().client();
- String topicArn;
- try {
- container = new LocalStackContainer(LOCALSTACK_IMAGE_NAME).withServices(Service.SNS);
- container.start();
-
- URI endpointOverride = container.getEndpointOverride(EnabledService.named(Service.SNS.getName()));
-
- StaticCredentialsProvider staticCredentials = StaticCredentialsProvider
- .create(AwsBasicCredentials.create("accesskey", "secretKey"));
-
- client = SnsClient.builder()
- .endpointOverride(endpointOverride)
- .credentialsProvider(staticCredentials)
- .httpClientBuilder(UrlConnectionHttpClient.builder())
- .region(Region.US_EAST_1).build();
-
- topicArn = client.createTopic(t -> t.name(TOPIC_NAME)).topicArn();
-
- Map properties = new HashMap<>();
- properties.put("quarkus.sns.endpoint-override", endpointOverride.toString());
- properties.put("quarkus.sns.aws.region", "us-east-1");
- properties.put("quarkus.sns.aws.credentials.type", "static");
- properties.put("quarkus.sns.aws.credentials.static-provider.access-key-id", "accessKey");
- properties.put("quarkus.sns.aws.credentials.static-provider.secret-access-key", "secretKey");
- properties.put("topic.arn", topicArn);
-
- return properties;
- } catch (Exception e) {
- e.printStackTrace();
- throw new RuntimeException("Could not start ocalstack server", e);
- }
- }
-
- @Override
- public void stop() {
- if (container != null) {
- container.close();
- }
- }
-}
diff --git a/amazon-sns-quickstart/src/test/java/org/acme/sns/SnsResourcesTest.java b/amazon-sns-quickstart/src/test/java/org/acme/sns/SnsResourcesTest.java
index f484b7c400..2be61dd3e0 100644
--- a/amazon-sns-quickstart/src/test/java/org/acme/sns/SnsResourcesTest.java
+++ b/amazon-sns-quickstart/src/test/java/org/acme/sns/SnsResourcesTest.java
@@ -3,7 +3,6 @@
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.any;
-import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
import jakarta.ws.rs.core.HttpHeaders;
import jakarta.ws.rs.core.MediaType;
@@ -12,7 +11,6 @@
import org.junit.jupiter.params.provider.ValueSource;
@QuarkusTest
-@QuarkusTestResource(SnsResource.class)
public class SnsResourcesTest {
@ParameterizedTest
diff --git a/amazon-sns-quickstart/src/test/resources/application.properties b/amazon-sns-quickstart/src/test/resources/application.properties
new file mode 100644
index 0000000000..02c4c8c133
--- /dev/null
+++ b/amazon-sns-quickstart/src/test/resources/application.properties
@@ -0,0 +1,2 @@
+quarkus.aws.devservices.localstack.init-scripts-classpath=localstack-init
+quarkus.aws.devservices.localstack.init-completion-msg=#### Tests init completed
\ No newline at end of file
diff --git a/amazon-sns-quickstart/src/test/resources/localstack-init/01_create_topic.sh b/amazon-sns-quickstart/src/test/resources/localstack-init/01_create_topic.sh
new file mode 100755
index 0000000000..97730d6f09
--- /dev/null
+++ b/amazon-sns-quickstart/src/test/resources/localstack-init/01_create_topic.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+awslocal sns create-topic --name quarkus
diff --git a/amazon-sns-quickstart/src/test/resources/localstack-init/99_completed.sh b/amazon-sns-quickstart/src/test/resources/localstack-init/99_completed.sh
new file mode 100755
index 0000000000..bc887a888f
--- /dev/null
+++ b/amazon-sns-quickstart/src/test/resources/localstack-init/99_completed.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+echo "#### Tests init completed"
diff --git a/amazon-sqs-quickstart/README.md b/amazon-sqs-quickstart/README.md
index 5882ffb05d..d35f7dfa82 100644
--- a/amazon-sqs-quickstart/README.md
+++ b/amazon-sqs-quickstart/README.md
@@ -1,17 +1,53 @@
-# Quarkus demo: SQS Client
+# Quarkus Demo: Amazon SQS Client
-This example showcases how to use the AWS SQS client with Quarkus. As a prerequisite install Install [AWS Command line interface](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html).
+This example showcases how to use the AWS SQS client with Quarkus.
-# AWS SQS local instance
+## Run the Demo in Dev Mode
-Just run it as follows in order to start SQS locally:
-`docker run --rm --name local-sqs -p 8010:4566 -e SERVICES=sqs -e START_WEB=0 -d localstack/localstack:1.4.0`
-SQS listens on `localhost:8010` for REST endpoints.
+- Run `./mvnw clean quarkus:dev`
+
+## Send messages to the queue
+
+Shoot with a couple of quarks:
+
+```sh
+curl -XPOST -H "Content-type: application/json" http://localhost:8080/sync/cannon/shoot -d '{"flavor": "Charm", "spin": "1/2"}'
+curl -XPOST -H "Content-type: application/json" http://localhost:8080/sync/cannon/shoot -d '{"flavor": "Strange", "spin": "1/2"}'
+```
+
+And receive them from the queue:
+
+```sh
+curl http://localhost:8080/sync/shield
+```
+
+## Test the async endpoints
+
+Replace `sync` with `async` in the examples above to test the asynchronous endpoints.
+
+# Using LocalStack
+
+As a prerequisite, install the [AWS Command Line Interface](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html).
+
+Start LocalStack:
+
+ ```sh
+ docker run \
+ --rm \
+ --name local-sqs \
+ -p 4566:4566 \
+ localstack/localstack
+```
+
+SQS listens on `localhost:4566` for REST endpoints.
Create an AWS profile for your local instance using AWS CLI:
+```sh
+aws configure --profile localstack
```
-$ aws configure --profile localstack
+
+```plain
AWS Access Key ID [None]: test-key
AWS Secret Access Key [None]: test-secret
Default region name [None]: us-east-1
@@ -20,78 +56,125 @@ Default output format [None]:
## Create SQS queue
-Create a SQS queue and store Queue url in environment variable as we will need to provide it to the our app
+Create a SQS queue:
+
+```sh
+aws sqs create-queue --queue-name=Quarkus --profile localstack --endpoint-url=http://localhost:4566
```
-$> QUEUE_URL=`aws sqs create-queue --queue-name=ColliderQueue --profile localstack --endpoint-url=http://localhost:8010`
+
+## Run the demo
+
+You can compile the application and run it with:
+
+```sh
+./mvnw install
+AWS_PROFILE=localstack java -Dquarkus.sqs.endpoint-override=http://localhost:4566 -jar ./target/quarkus-app/quarkus-run.jar
```
-# Run the demo on dev mode
+## Running in native
-- Run `./mvnw clean package` and then `java -Dqueue.url=$QUEUE_URL -jar ./target/quarkus-app/quarkus-run.jar`
-- In dev mode `./mvnw clean quarkus:dev -Dqueue.url=$QUEUE_URL`
+You can compile the application into a native executable using:
-## Send messages to the queue
-Shoot with a couple of quarks
+```sh
+./mvnw install -Dnative
```
-curl -XPOST -H"Content-type: application/json" http://localhost:8080/sync/cannon/shoot -d'{"flavor": "Charm", "spin": "1/2"}'
-curl -XPOST -H"Content-type: application/json" http://localhost:8080/sync/cannon/shoot -d'{"flavor": "Strange", "spin": "1/2"}'
+
+And run it with:
+
+```sh
+AWS_PROFILE=localstack ./target/amazon-sqs-quickstart-1.0.0-SNAPSHOT-runner -Dquarkus.sqs.endpoint-override=http://localhost:4566
```
-And receive it from the queue
+
+# Running native in container
+
+Build a native image in a container by running:
+
+```sh
+./mvnw install -Dnative -DskipTests -Dquarkus.native.container-build=true
```
-curl http://localhost:8080/sync/cannon/shoot
+
+Build a Docker image:
+
+```sh
+docker build -f src/main/docker/Dockerfile.native -t quarkus/amazon-sqs-quickstart .
```
-Repeat the same using async endpoints
+Create a network that connects your container with LocalStack:
+
+```sh
+docker network create localstack
```
-curl -XPOST -H"Content-type: application/json" http://localhost:8080/async/cannon/shoot -d'{"flavor": "Charm", "spin": "1/2"}'
-curl -XPOST -H"Content-type: application/json" http://localhost:8080/async/cannon/shoot -d'{"flavor": "Strange", "spin": "1/2"}'
+
+Stop your LocalStack container you started at the beginning:
+
+```sh
+docker stop local-sqs
```
-And receive it from the queue
+
+Start LocalStack and connect to the network:
+
+```sh
+docker run \
+ --rm \
+ --name local-sqs \
+ --network=localstack \
+ -p 4566:4566 \
+ localstack/localstack
```
-curl http://localhost:8080/async/cannon/shoot
+
+Create a queue:
+
+```sh
+aws sqs create-queue --queue-name=Quarkus --profile localstack --endpoint-url=http://localhost:4566
```
-# Running in native
+Run the Quickstart container connected to that network (note that we're using the internal port of the LocalStack container):
-You can compile the application into a native binary using:
+```sh
+docker run -i --rm --network=localstack \
+ -p 8080:8080 \
+ -e QUARKUS_SQS_ENDPOINT_OVERRIDE="http://local-sqs:4566" \
+ -e QUARKUS_SQS_AWS_REGION="us-east-1" \
+ -e QUARKUS_SQS_AWS_CREDENTIALS_TYPE="static" \
+ -e QUARKUS_SQS_AWS_CREDENTIALS_STATIC_PROVIDER_ACCESS_KEY_ID="test-key" \
+ -e QUARKUS_SQS_AWS_CREDENTIALS_STATIC_PROVIDER_SECRET_ACCESS_KEY="test-secret" \
+ quarkus/amazon-sqs-quickstart
+```
-`./mvnw clean install -Pnative`
+You can now replay the `curl` commands above.
-and run with:
+Clean up your environment:
-`./target/amazon-sqs-quickstart-1.0.0-SNAPSHOT-runner`
+```sh
+docker stop local-sqs
+docker network rm localstack
+```
+# Using AWS account
-# Running native in container
+Before you can use the AWS SDKs with SQS, you must get an AWS access key ID and secret access key.
+For more information, see:
+ - [Sign up for AWS and Create an IAM User](https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/signup-create-iam-user.html)
+ - [Set Up AWS Credentials and Region for Development](https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/setup-credentials.html)
-Build a native image in container by running:
-`./mvnw package -Pnative -Dnative-image.docker-build=true`
+Create a SQS queue and store the queue url in an environment variable as we will need to provide it to the our app:
-Build a docker image:
-`docker build -f src/main/docker/Dockerfile.native -t quarkus/amazon-sqs-quickstart .`
+```sh
+QUEUE_URL=`aws sqs create-queue --queue-name=ColliderQueue`
+```
-Create a network that connect your container with localstack
-`docker network create localstack`
+## Run demo
-Stop your localstack container you started at the beginning
-`docker stop local-sqs`
+You can run the demo the same way as for a local instance, but you don't need to override the endpoint as you are going to communicate with the AWS service with the default AWS profile.
-Start localstack and connect to the network
-`docker run --rm --network=localstack --name localstack -p 8010:4566 -e SERVICES=sqs -e START_WEB=0 -d localstack/localstack:1.4.0`
+Run it:
-Create queue
-```
-$> QUEUE_URL=`aws sqs create-queue --queue-name=ColliderQueue --profile localstack --endpoint-url=http://localhost:8010`
+```sh
+java -Dqueue.url=$QUEUE_URL -jar ./target/quarkus-app/quarkus-run.jar
```
-Run quickstart container connected to that network (note that we're using internal port of the localstack)
-`docker run -i --rm --network=localstack -p 8080:8080 quarkus/amazon-sqs-quickstart -Dquarkus.sqs.endpoint-override=http://localstack:4566`
-Send messsage
-```
-curl -XPOST -H"Content-type: application/json" http://localhost:8080/sync/cannon/shoot -d'{"flavor": "Charm", "spin": "1/2"}'
-```
+Or, run it natively:
-Receive message
-```
-curl http://localhost:8080/sync/cannon/shoot
+```sh
+./target/amazon-sqs-quickstart-1.0.0-SNAPSHOT-runner -Dqueue.url=$QUEUE_URL
```
diff --git a/amazon-sqs-quickstart/pom.xml b/amazon-sqs-quickstart/pom.xml
index e8aea651fc..772a1dc7d8 100644
--- a/amazon-sqs-quickstart/pom.xml
+++ b/amazon-sqs-quickstart/pom.xml
@@ -16,8 +16,7 @@
UTF-8
11
11
- 2.5.3
- 1.12.57
+ 2.7.2
@@ -71,23 +70,6 @@
rest-assured
test
-
- org.testcontainers
- localstack
- test
-
-
- org.testcontainers
- junit-jupiter
- test
-
-
-
- com.amazonaws
- aws-java-sdk-core
- ${awssdk.testcontainers.version}
- test
-
diff --git a/amazon-sqs-quickstart/src/main/docker/docker-compose.yml b/amazon-sqs-quickstart/src/main/docker/docker-compose.yml
deleted file mode 100644
index 95c11c6ca5..0000000000
--- a/amazon-sqs-quickstart/src/main/docker/docker-compose.yml
+++ /dev/null
@@ -1,17 +0,0 @@
-version: '2.1'
-
-services:
- local-sqs:
- image: localstack/localstack:1.4.0
- ports:
- - "8010:4566"
- environment:
- - SERVICES=sqs
- - START_WEB=0
- app:
- image: quarkus/amazon-sqs-quickstart
- ports:
- - "8080:8080"
- environment:
- - QUARKUS_SQS_ENDPOINT_OVERRIDE=http://local-sqs:4566
- - QUEUE_URL=${QUEUE_URL}
diff --git a/amazon-sqs-quickstart/src/main/resources/application.properties b/amazon-sqs-quickstart/src/main/resources/application.properties
index d9fe6d42cc..5c41fbdf51 100644
--- a/amazon-sqs-quickstart/src/main/resources/application.properties
+++ b/amazon-sqs-quickstart/src/main/resources/application.properties
@@ -1,8 +1,2 @@
-quarkus.sqs.endpoint-override=http://localhost:8010
-
-quarkus.sqs.aws.region=us-east-1
-quarkus.sqs.aws.credentials.type=static
-quarkus.sqs.aws.credentials.static-provider.access-key-id=test-key
-quarkus.sqs.aws.credentials.static-provider.secret-access-key=test-secret
-
-queue.url=
\ No newline at end of file
+quarkus.sqs.devservices.queues=Quarkus
+queue.url=Quarkus
\ No newline at end of file
diff --git a/amazon-sqs-quickstart/src/test/java/org/acme/sqs/SqsResource.java b/amazon-sqs-quickstart/src/test/java/org/acme/sqs/SqsResource.java
deleted file mode 100644
index 104e3c1582..0000000000
--- a/amazon-sqs-quickstart/src/test/java/org/acme/sqs/SqsResource.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.acme.sqs;
-
-import java.net.URI;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.testcontainers.DockerClientFactory;
-import org.testcontainers.containers.localstack.LocalStackContainer;
-import org.testcontainers.containers.localstack.LocalStackContainer.EnabledService;
-import org.testcontainers.containers.localstack.LocalStackContainer.Service;
-import org.testcontainers.utility.DockerImageName;
-
-import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
-import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
-import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
-import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
-import software.amazon.awssdk.regions.Region;
-import software.amazon.awssdk.services.sqs.SqsClient;
-
-public class SqsResource implements QuarkusTestResourceLifecycleManager {
-
- private static final DockerImageName LOCALSTACK_IMAGE_NAME = DockerImageName.parse("localstack/localstack")
- .withTag("0.12.17");
-
- public final static String QUEUE_NAME = "Quarkus";
-
- private LocalStackContainer container;
- private SqsClient client;
-
- @Override
- public Map start() {
- DockerClientFactory.instance().client();
- String queueUrl;
- try {
- container = new LocalStackContainer(LOCALSTACK_IMAGE_NAME).withServices(Service.SQS);
- container.start();
-
- URI endpointOverride = container.getEndpointOverride(EnabledService.named(Service.SQS.getName()));
-
- StaticCredentialsProvider staticCredentials = StaticCredentialsProvider
- .create(AwsBasicCredentials.create("accesskey", "secretKey"));
-
- client = SqsClient.builder()
- .endpointOverride(endpointOverride)
- .credentialsProvider(staticCredentials)
- .httpClientBuilder(UrlConnectionHttpClient.builder())
- .region(Region.US_EAST_1).build();
-
- queueUrl = client.createQueue(q -> q.queueName(QUEUE_NAME)).queueUrl();
-
- Map properties = new HashMap<>();
- properties.put("quarkus.sqs.endpoint-override", endpointOverride.toString());
- properties.put("quarkus.sqs.aws.region", "us-east-1");
- properties.put("quarkus.sqs.aws.credentials.type", "static");
- properties.put("quarkus.sqs.aws.credentials.static-provider.access-key-id", "accessKey");
- properties.put("quarkus.sqs.aws.credentials.static-provider.secret-access-key", "secretKey");
- properties.put("queue.url", queueUrl);
-
- return properties;
- } catch (Exception e) {
- e.printStackTrace();
- throw new RuntimeException("Could not start localstack server", e);
- }
- }
-
- @Override
- public void stop() {
- if (container != null) {
- container.close();
- }
- }
-}
diff --git a/amazon-sqs-quickstart/src/test/java/org/acme/sqs/SqsResourcesTest.java b/amazon-sqs-quickstart/src/test/java/org/acme/sqs/SqsResourcesTest.java
index 50b53f8d62..5cfae4d69c 100644
--- a/amazon-sqs-quickstart/src/test/java/org/acme/sqs/SqsResourcesTest.java
+++ b/amazon-sqs-quickstart/src/test/java/org/acme/sqs/SqsResourcesTest.java
@@ -4,7 +4,6 @@
import static org.hamcrest.Matchers.any;
import static org.hamcrest.Matchers.containsString;
-import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
import java.util.Arrays;
import java.util.List;
@@ -16,7 +15,6 @@
import org.junit.jupiter.params.provider.ValueSource;
@QuarkusTest
-@QuarkusTestResource(SqsResource.class)
public class SqsResourcesTest {
private static final BiFunction QUARK = (flavor, spin) -> String
diff --git a/amazon-ssm-quickstart/README.md b/amazon-ssm-quickstart/README.md
index b17f5bff7b..343ff6b8a9 100644
--- a/amazon-ssm-quickstart/README.md
+++ b/amazon-ssm-quickstart/README.md
@@ -1,87 +1,168 @@
# Quarkus demo: Amazon SSM Client
-This example showcases how to use the AWS SSM client with Quarkus. As a prerequisite install [AWS Command line interface](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html).
+This example showcases how to use the AWS SSM client with Quarkus.
-# AWS SSM local instance
+# Run the demo on dev mode
+
+- Run `./mvnw clean quarkus:dev`
+
+## Set some parameters
-Just run it as follows in order to start SSM locally:
+First, add as many paramters as you like using the following patterns for secure and plain parameters:
-`docker run --rm --name local-ssn -p 8014:4583 -e SERVICES=ssm -e START_WEB=0 -d localstack/localstack:0.11.1`
+```sh
+curl -XPUT -H"Content-type: text/plain" "http://localhost:8080/sync/secure?secure=true" -d"stored as cipher text"
+curl -XPUT -H"Content-type: text/plain" "http://localhost:8080/sync/plain" -d"stored as plain text"
+```
+
+## List all parameters
+
+You can now list the parameters you added:
+
+```sh
+curl http://localhost:8080/sync
+```
+
+You should see output like this:
+
+```plain
+{"plain":"stored as plain text","secure":"stored as cipher text"}
+```
+
+## Test the async endpoints
+
+Replace `sync` with `async` in the examples above to test the asynchronous endpoints.
+
+# Using LocalStack
+
+As a prerequisite, install the [AWS Command Line Interface](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html).
+
+Start LocalStack:
+
+ ```sh
+ docker run \
+ --rm \
+ --name local-ssm \
+ -p 4566:4566 \
+ localstack/localstack
+```
-SSM listens on `localhost:8014` for REST endpoints.
+SSM listens on `localhost:4566` for REST endpoints.
Create an AWS profile for your local instance using AWS CLI:
+```sh
+aws configure --profile localstack
```
-$ aws configure --profile localstack
+
+```plain
AWS Access Key ID [None]: test-key
AWS Secret Access Key [None]: test-secret
Default region name [None]: us-east-1
Default output format [None]:
```
-# Run the demo on dev mode
+## Run the demo
-- Run `./mvnw clean package` and then `java -Dparameters.path=/quarkus/is/awesome/ -jar ./target/quarkus-app/quarkus-run.jar`
-- In dev mode `./mvnw clean quarkus:dev -Dparameters.path=/quarkus/is/awesome/`
+You can compile the application and run it with:
-## Set some parameters
-First, add as many paramters as you like using the following patterns for secure and plain parameters:
-
-```
-curl -XPUT -H"Content-type: text/plain" "http://localhost:8080/sync/secure?secure=true" -d"stored as cipher text"
-curl -XPUT -H"Content-type: text/plain" "http://localhost:8080/sync/plain" -d"stored as plain text"
+```sh
+./mvnw install
+AWS_PROFILE=localstack java -Dquarkus.ssm.endpoint-override=http://localhost:4566 -jar ./target/quarkus-app/quarkus-run.jar
```
-## List all parameters
-You can now list the parameters you added:
+## Running in native
-```
-curl http://localhost:8080/sync
+You can compile the application into a native executable using:
+
+```sh
+./mvnw install -Dnative
```
-You should see output like this:
+And run it with:
+```sh
+AWS_PROFILE=localstack ./target/amazon-ssm-quickstart-1.0.0-SNAPSHOT-runner -Dquarkus.ssm.endpoint-override=http://localhost:4566
```
-{"plain":"stored as plain text","secure":"stored as cipher text"}
+
+## Running native in container
+
+Build a native image in a container by running:
+
+```sh
+./mvnw install -Dnative -DskipTests -Dquarkus.native.container-build=true
```
-## Test the async endpoints
-Replace `sync` with `async` in the examples above to test the asynchronous endpoints.
+Build a Docker image:
-# Running in native
+```sh
+docker build -f src/main/docker/Dockerfile.native -t quarkus/amazon-ssm-quickstart .
+```
-You can compile the application into a native binary using:
+Create a network that connects your container with LocalStack:
-`./mvnw clean install -Pnative`
+```sh
+docker network create localstack
+```
-and run with:
+Stop your LocalStack container you started at the beginning:
-`./target/amazon-ssm-quickstart-1.0.0-SNAPSHOT-runner -Dparameters.path=/quarkus/is/awesome/`
+```sh
+docker stop local-ssm
+```
+Start LocalStack and connect to the network:
-# Running native in container
+```sh
+docker run \
+ --rm \
+ --name local-ssm \
+ --network=localstack \
+ -p 4566:4566 \
+ localstack/localstack
+```
-Build a native image in container by running:
+Run the Quickstart container connected to that network (note that we're using the internal port of the LocalStack container):
+
+```sh
+docker run -i --rm --network=localstack \
+ -p 8080:8080 \
+ -e QUARKUS_SSM_ENDPOINT_OVERRIDE="http://local-ssm:4566" \
+ -e QUARKUS_SSM_AWS_REGION="us-east-1" \
+ -e QUARKUS_SSM_AWS_CREDENTIALS_TYPE="static" \
+ -e QUARKUS_SSM_AWS_CREDENTIALS_STATIC_PROVIDER_ACCESS_KEY_ID="test-key" \
+ -e QUARKUS_SSM_AWS_CREDENTIALS_STATIC_PROVIDER_SECRET_ACCESS_KEY="test-secret" \
+ quarkus/amazon-ssm-quickstart
+```
-`./mvnw clean package -Pnative -Dnative-image.docker-build=true`
+You can now replay the `curl` commands above.
-Build a docker image:
+Clean up your environment:
-`docker build -f src/main/docker/Dockerfile.native -t quarkus/amazon-ssm-quickstart .`
+```sh
+docker stop local-ssm
+docker network rm localstack
+```
-Create a network that connect your container with localstack:
+# Using AWS account
-`docker network create localstack`
+Before you can use the AWS SDKs with SSM, you must get an AWS access key ID and secret access key.
+For more information, see:
+ - [Sign up for AWS and Create an IAM User](https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/signup-create-iam-user.html)
+ - [Set Up AWS Credentials and Region for Development](https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/setup-credentials.html)
-Stop your localstack container you started at the beginning:
+## Run demo
-`docker stop local-ssm`
+You can run the demo the same way as for a local instance, but you don't need to override the endpoint as you are going to communicate with the AWS service with the default AWS profile.
-Start localstack and connect to the network:
+Run it:
-`docker run --rm --network=localstack --name localstack -p 8014:4583 -e SERVICES=ssm -e START_WEB=0 -d localstack/localstack:0.11.1`
+```sh
+java -jar ./target/quarkus-app/quarkus-run.jar
+```
-Run quickstart container connected to that network (note that we're using internal port of the localstack):
+Or, run it natively:
-`docker run -i --rm --network=localstack -p 8080:8080 -e QUARKUS_SSM_ENDPOINT_OVERRIDE="http://localstack:4583" -e PARAMETERS_PATH="/quarkus/is/awesome/" quarkus/amazon-ssm-quickstart`
+```sh
+./target/amazon-ssm-quickstart-1.0.0-SNAPSHOT-runner
+```
diff --git a/amazon-ssm-quickstart/pom.xml b/amazon-ssm-quickstart/pom.xml
index 203513b7e7..c89bbd8537 100644
--- a/amazon-ssm-quickstart/pom.xml
+++ b/amazon-ssm-quickstart/pom.xml
@@ -16,8 +16,7 @@
UTF-8
11
11
- 2.5.3
- 1.12.57
+ 2.7.2
@@ -71,23 +70,6 @@
rest-assured
test
-
- org.testcontainers
- localstack
- test
-
-
- org.testcontainers
- junit-jupiter
- test
-
-
-
- com.amazonaws
- aws-java-sdk-core
- ${awssdk.testcontainers.version}
- test
-
diff --git a/amazon-ssm-quickstart/src/main/resources/application.properties b/amazon-ssm-quickstart/src/main/resources/application.properties
index 3443f5a519..3204b3a588 100644
--- a/amazon-ssm-quickstart/src/main/resources/application.properties
+++ b/amazon-ssm-quickstart/src/main/resources/application.properties
@@ -1,8 +1 @@
-quarkus.ssm.endpoint-override=http://localhost:8014
-
-quarkus.ssm.aws.region=us-east-1
-quarkus.ssm.aws.credentials.type=static
-quarkus.ssm.aws.credentials.static-provider.access-key-id=test-key
-quarkus.ssm.aws.credentials.static-provider.secret-access-key=test-secret
-
parameters.path=/quarkus/is/awesome/
\ No newline at end of file
diff --git a/amazon-ssm-quickstart/src/test/java/org/acme/ssm/SsmResource.java b/amazon-ssm-quickstart/src/test/java/org/acme/ssm/SsmResource.java
deleted file mode 100644
index 56ef235d0a..0000000000
--- a/amazon-ssm-quickstart/src/test/java/org/acme/ssm/SsmResource.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package org.acme.ssm;
-
-import java.net.URI;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.testcontainers.DockerClientFactory;
-import org.testcontainers.containers.localstack.LocalStackContainer;
-import org.testcontainers.containers.localstack.LocalStackContainer.EnabledService;
-import org.testcontainers.containers.localstack.LocalStackContainer.Service;
-import org.testcontainers.utility.DockerImageName;
-
-import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
-
-public class SsmResource implements QuarkusTestResourceLifecycleManager {
-
- private static final DockerImageName LOCALSTACK_IMAGE_NAME = DockerImageName.parse("localstack/localstack")
- .withTag("0.12.17");
-
- private LocalStackContainer container;
-
- @Override
- public Map start() {
- DockerClientFactory.instance().client();
- try {
- container = new LocalStackContainer(LOCALSTACK_IMAGE_NAME).withServices(Service.SSM);
- container.start();
-
- URI endpointOverride = container.getEndpointOverride(EnabledService.named(Service.SSM.getName()));
-
- Map properties = new HashMap<>();
- properties.put("quarkus.ssm.endpoint-override", endpointOverride.toString());
- properties.put("quarkus.ssm.aws.region", "us-east-1");
- properties.put("quarkus.ssm.aws.credentials.type", "static");
- properties.put("quarkus.ssm.aws.credentials.static-provider.access-key-id", "accessKey");
- properties.put("quarkus.ssm.aws.credentials.static-provider.secret-access-key", "secretKey");
- properties.put("parameeters.path", "/quarkus/is/awesome/");
-
- return properties;
- } catch (Exception e) {
- throw new RuntimeException("Could not start localstack server", e);
- }
- }
-
- @Override
- public void stop() {
- if (container != null) {
- container.close();
- }
- }
-}
diff --git a/amazon-ssm-quickstart/src/test/java/org/acme/ssm/SsmResourcesTest.java b/amazon-ssm-quickstart/src/test/java/org/acme/ssm/SsmResourcesTest.java
index 404c7d77d5..b59b5b98f7 100644
--- a/amazon-ssm-quickstart/src/test/java/org/acme/ssm/SsmResourcesTest.java
+++ b/amazon-ssm-quickstart/src/test/java/org/acme/ssm/SsmResourcesTest.java
@@ -13,11 +13,9 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
-import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
@QuarkusTest
-@QuarkusTestResource(SsmResource.class)
public class SsmResourcesTest {
@ParameterizedTest