Skip to content

Commit

Permalink
feat: add acm extension (#1476)
Browse files Browse the repository at this point in the history
* add new extension for ACM

* add documentation for ACM extension

* add ACM to list of services in README

* use requestCertificate to simplify tests and examples
  • Loading branch information
emattheis authored Nov 13, 2024
1 parent b70fb93 commit 59456bb
Show file tree
Hide file tree
Showing 25 changed files with 4,500 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

This set of extensions allows you to interact with some of the AWS Services namely:

* ACM
* Api Gateway Management Api
* CloudWatch
* CloudWatch Logs
Expand Down
87 changes: 87 additions & 0 deletions acm/deployment/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.quarkiverse.amazonservices</groupId>
<artifactId>quarkus-amazon-acm-parent</artifactId>
<version>999-SNAPSHOT</version>
</parent>

<artifactId>quarkus-amazon-acm-deployment</artifactId>
<name>Quarkus - Amazon Services - ACM - Deployment</name>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-core-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.amazonservices</groupId>
<artifactId>quarkus-amazon-common-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.amazonservices</groupId>
<artifactId>quarkus-amazon-acm</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.amazonservices</groupId>
<artifactId>quarkus-amazon-devservices-acm</artifactId>
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-internal</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>netty-nio-client</artifactId>
<scope>test</scope>
</dependency>
<!-- Imported manually because conditional dependencies
are not automatically added to test scope -->
<dependency>
<groupId>io.quarkiverse.amazonservices</groupId>
<artifactId>quarkus-amazon-netty-client-internal-deployment</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>aws-crt-client</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>url-connection-client</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${quarkus.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
package io.quarkiverse.amazon.acm.deployment;

import java.util.List;

import org.jboss.jandex.DotName;

import io.quarkiverse.amazon.acm.runtime.AcmBuildTimeConfig;
import io.quarkiverse.amazon.acm.runtime.AcmRecorder;
import io.quarkiverse.amazon.common.deployment.AbstractAmazonServiceProcessor;
import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncResultBuildItem;
import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncTransportBuildItem;
import io.quarkiverse.amazon.common.deployment.AmazonClientInterceptorsPathBuildItem;
import io.quarkiverse.amazon.common.deployment.AmazonClientSyncResultBuildItem;
import io.quarkiverse.amazon.common.deployment.AmazonClientSyncTransportBuildItem;
import io.quarkiverse.amazon.common.deployment.AmazonHttpClients;
import io.quarkiverse.amazon.common.deployment.RequireAmazonClientBuildItem;
import io.quarkiverse.amazon.common.deployment.RequireAmazonClientInjectionBuildItem;
import io.quarkiverse.amazon.common.deployment.RequireAmazonClientTransportBuilderBuildItem;
import io.quarkiverse.amazon.common.deployment.RequireAmazonTelemetryBuildItem;
import io.quarkiverse.amazon.common.deployment.spi.EventLoopGroupBuildItem;
import io.quarkiverse.amazon.common.runtime.AmazonClientApacheTransportRecorder;
import io.quarkiverse.amazon.common.runtime.AmazonClientAwsCrtTransportRecorder;
import io.quarkiverse.amazon.common.runtime.AmazonClientCommonRecorder;
import io.quarkiverse.amazon.common.runtime.AmazonClientNettyTransportRecorder;
import io.quarkiverse.amazon.common.runtime.AmazonClientOpenTelemetryRecorder;
import io.quarkiverse.amazon.common.runtime.AmazonClientUrlConnectionTransportRecorder;
import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem;
import io.quarkus.arc.deployment.SyntheticBeanBuildItem;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.ExecutionTime;
import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.ExecutorBuildItem;
import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.builditem.LaunchModeBuildItem;
import software.amazon.awssdk.services.acm.AcmAsyncClient;
import software.amazon.awssdk.services.acm.AcmAsyncClientBuilder;
import software.amazon.awssdk.services.acm.AcmClient;
import software.amazon.awssdk.services.acm.AcmClientBuilder;

public class AcmProcessor extends AbstractAmazonServiceProcessor {

private static final String AMAZON_CLIENT_NAME = "amazon-sdk-acm";

AcmBuildTimeConfig buildTimeConfig;

@Override
protected String amazonServiceClientName() {
return AMAZON_CLIENT_NAME;
}

@Override
protected String configName() {
return "acm";
}

@Override
protected DotName syncClientName() {
return DotName.createSimple(AcmClient.class.getName());
}

@Override
protected DotName asyncClientName() {
return DotName.createSimple(AcmAsyncClient.class.getName());
}

@Override
protected String builtinInterceptorsPath() {
return "software/amazon/awssdk/services/acm/execution.interceptors";
}

@BuildStep
void setup(
BuildProducer<ExtensionSslNativeSupportBuildItem> extensionSslNativeSupport,
BuildProducer<FeatureBuildItem> feature,
BuildProducer<AmazonClientInterceptorsPathBuildItem> interceptors) {

setupExtension(extensionSslNativeSupport, feature, interceptors);
}

@BuildStep
void discoverClientInjectionPoints(BeanRegistrationPhaseBuildItem beanRegistrationPhase,
BuildProducer<RequireAmazonClientInjectionBuildItem> requireClientInjectionProducer) {

discoverClientInjectionPointsInternal(beanRegistrationPhase, requireClientInjectionProducer);
}

@BuildStep
void discover(
List<RequireAmazonClientInjectionBuildItem> amazonClientInjectionPoints,
BuildProducer<RequireAmazonClientBuildItem> requireClientProducer) {

discoverClient(amazonClientInjectionPoints, requireClientProducer);
}

@BuildStep
void discoverTelemetry(BuildProducer<RequireAmazonTelemetryBuildItem> telemetryProducer) {

discoverTelemetry(telemetryProducer, buildTimeConfig.sdk());
}

@BuildStep
void setupClient(List<RequireAmazonClientBuildItem> clientRequirements,
BuildProducer<RequireAmazonClientTransportBuilderBuildItem> clientProducer) {

setupClient(clientRequirements, clientProducer, buildTimeConfig.sdk(), buildTimeConfig.syncClient(),
buildTimeConfig.asyncClient());
}

@BuildStep(onlyIf = AmazonHttpClients.IsAmazonApacheHttpServicePresent.class)
@Record(ExecutionTime.RUNTIME_INIT)
void setupApacheSyncTransport(List<RequireAmazonClientTransportBuilderBuildItem> amazonClients, AcmRecorder recorder,
AmazonClientApacheTransportRecorder transportRecorder,
BuildProducer<AmazonClientSyncTransportBuildItem> syncTransports) {

createApacheSyncTransportBuilder(amazonClients,
transportRecorder,
buildTimeConfig.syncClient(),
recorder.getSyncConfig(),
syncTransports);
}

@BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class)
@Record(ExecutionTime.RUNTIME_INIT)
void setupAwsCrtSyncTransport(List<RequireAmazonClientTransportBuilderBuildItem> amazonClients, AcmRecorder recorder,
AmazonClientAwsCrtTransportRecorder transportRecorder,
BuildProducer<AmazonClientSyncTransportBuildItem> syncTransports) {

createAwsCrtSyncTransportBuilder(amazonClients,
transportRecorder,
buildTimeConfig.syncClient(),
recorder.getSyncConfig(),
syncTransports);
}

@BuildStep(onlyIf = AmazonHttpClients.IsAmazonUrlConnectionHttpServicePresent.class)
@Record(ExecutionTime.RUNTIME_INIT)
void setupUrlConnectionSyncTransport(List<RequireAmazonClientTransportBuilderBuildItem> amazonClients, AcmRecorder recorder,
AmazonClientUrlConnectionTransportRecorder transportRecorder,
BuildProducer<AmazonClientSyncTransportBuildItem> syncTransports) {

createUrlConnectionSyncTransportBuilder(amazonClients,
transportRecorder,
buildTimeConfig.syncClient(),
recorder.getSyncConfig(),
syncTransports);
}

@BuildStep(onlyIf = AmazonHttpClients.IsAmazonNettyHttpServicePresent.class)
@Record(ExecutionTime.RUNTIME_INIT)
void setupNettyAsyncTransport(List<RequireAmazonClientTransportBuilderBuildItem> amazonClients, AcmRecorder recorder,
AmazonClientNettyTransportRecorder transportRecorder,
BuildProducer<AmazonClientAsyncTransportBuildItem> asyncTransports,
EventLoopGroupBuildItem eventLoopSupplier) {

createNettyAsyncTransportBuilder(amazonClients,
transportRecorder,
buildTimeConfig.asyncClient(),
recorder.getAsyncConfig(),
asyncTransports, eventLoopSupplier.getMainEventLoopGroup());
}

@BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class)
@Record(ExecutionTime.RUNTIME_INIT)
void setupAwsCrtAsyncTransport(List<RequireAmazonClientTransportBuilderBuildItem> amazonClients, AcmRecorder recorder,
AmazonClientAwsCrtTransportRecorder transportRecorder,
BuildProducer<AmazonClientAsyncTransportBuildItem> asyncTransports) {

createAwsCrtAsyncTransportBuilder(amazonClients,
transportRecorder,
buildTimeConfig.asyncClient(),
recorder.getAsyncConfig(),
asyncTransports);
}

@BuildStep
@Record(ExecutionTime.RUNTIME_INIT)
void createClientBuilders(AcmRecorder recorder,
AmazonClientCommonRecorder commonRecorder,
AmazonClientOpenTelemetryRecorder otelRecorder,
List<RequireAmazonClientInjectionBuildItem> amazonClientInjections,
List<RequireAmazonTelemetryBuildItem> amazonRequireTelemtryClients,
List<AmazonClientSyncTransportBuildItem> syncTransports,
List<AmazonClientAsyncTransportBuildItem> asyncTransports,
BuildProducer<SyntheticBeanBuildItem> syntheticBeans,
BuildProducer<AmazonClientSyncResultBuildItem> clientSync,
BuildProducer<AmazonClientAsyncResultBuildItem> clientAsync,
LaunchModeBuildItem launchModeBuildItem,
ExecutorBuildItem executorBuildItem) {

createClientBuilders(
recorder,
commonRecorder,
otelRecorder,
buildTimeConfig,
amazonClientInjections,
amazonRequireTelemtryClients,
syncTransports,
asyncTransports,
AcmClientBuilder.class,
AcmAsyncClientBuilder.class,
null,
syntheticBeans,
clientSync,
clientAsync,
launchModeBuildItem,
executorBuildItem);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package io.quarkiverse.amazon.acm.deployment;

import jakarta.inject.Inject;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.test.QuarkusUnitTest;
import software.amazon.awssdk.services.acm.AcmAsyncClient;
import software.amazon.awssdk.services.acm.AcmClient;

public class AcmSyncClientFullConfigTest {

@Inject
AcmClient client;

@Inject
AcmAsyncClient async;

@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.withApplicationRoot((jar) -> jar
.addAsResource("sync-urlconn-full-config.properties", "application.properties"));

@Test
public void test() {
// should finish with success
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
quarkus.acm.endpoint-override=http://localhost:9090

quarkus.acm.aws.region=us-east-1
quarkus.acm.aws.credentials.type=static
quarkus.acm.aws.credentials.static-provider.access-key-id=test-key
quarkus.acm.aws.credentials.static-provider.secret-access-key=test-secret

quarkus.acm.sync-client.type = url
quarkus.acm.sync-client.connection-timeout = 0.100S
quarkus.acm.sync-client.socket-timeout = 0.100S
21 changes: 21 additions & 0 deletions acm/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.quarkiverse.amazonservices</groupId>
<artifactId>quarkus-amazon-services-build-parent</artifactId>
<version>999-SNAPSHOT</version>
<relativePath>../build-parent/pom.xml</relativePath>
</parent>

<artifactId>quarkus-amazon-acm-parent</artifactId>
<name>Quarkus - Amazon Services - ACM</name>
<packaging>pom</packaging>

<modules>
<module>runtime</module>
<module>deployment</module>
</modules>

</project>
Loading

0 comments on commit 59456bb

Please sign in to comment.