Skip to content

Commit

Permalink
Full support of aws-secret-manager
Browse files Browse the repository at this point in the history
  • Loading branch information
JiriOndrusek committed Jan 30, 2025
1 parent 2171ca4 commit 410fb3b
Show file tree
Hide file tree
Showing 26 changed files with 293 additions and 120 deletions.
6 changes: 3 additions & 3 deletions docs/modules/ROOT/examples/components/aws-secrets-manager.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
cqArtifactId: camel-quarkus-aws-secrets-manager
cqArtifactIdBase: aws-secrets-manager
cqNativeSupported: false
cqStatus: Preview
cqNativeSupported: true
cqStatus: Stable
cqDeprecated: false
cqJvmSince: 2.0.0
cqNativeSince: n/a
cqNativeSince: 3.19.0
cqCamelPartName: aws-secrets-manager
cqCamelPartTitle: AWS Secrets Manager
cqCamelPartDescription: Manage secrets using AWS Secrets Manager.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
= AWS Secrets Manager
:linkattrs:
:cq-artifact-id: camel-quarkus-aws-secrets-manager
:cq-native-supported: false
:cq-status: Preview
:cq-status-deprecation: Preview
:cq-native-supported: true
:cq-status: Stable
:cq-status-deprecation: Stable
:cq-description: Manage AWS Secrets Manager services using AWS SDK version 2.x.
:cq-deprecated: false
:cq-jvm-since: 2.0.0
:cq-native-since: n/a
:cq-native-since: 3.19.0

ifeval::[{doc-show-badges} == true]
[.badges]
[.badge-key]##JVM since##[.badge-supported]##2.0.0## [.badge-key]##Native##[.badge-unsupported]##unsupported##
[.badge-key]##JVM since##[.badge-supported]##2.0.0## [.badge-key]##Native since##[.badge-supported]##3.19.0##
endif::[]

Manage AWS Secrets Manager services using AWS SDK version 2.x.
Expand All @@ -29,6 +29,10 @@ Please refer to the above link for usage and configuration details.
[id="extensions-aws-secrets-manager-maven-coordinates"]
== Maven coordinates

https://{link-quarkus-code-generator}/?extension-search=camel-quarkus-aws-secrets-manager[Create a new project with this extension on {link-quarkus-code-generator}, window="_blank"]

Or add the coordinates to your existing project:

[source,xml]
----
<dependency>
Expand All @@ -39,3 +43,10 @@ Please refer to the above link for usage and configuration details.
ifeval::[{doc-show-user-guide-link} == true]
Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
endif::[]

[id="extensions-aws-secrets-manager-ssl-in-native-mode"]
== SSL in native mode

This extension auto-enables SSL support in native mode. Hence you do not need to add
`quarkus.ssl.native=true` to your `application.properties` yourself. See also
https://quarkus.io/guides/native-and-ssl[Quarkus SSL guide].
1 change: 0 additions & 1 deletion extensions-jvm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
<!-- extensions a..z; do not remove this comment, it is important when sorting via mvn process-resources -Pformat -->
<module>asn1</module>
<module>asterisk</module>
<module>aws-secrets-manager</module>
<module>aws-xray</module>
<module>azure-cosmosdb</module>
<module>azure-servicebus</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-core-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-support-aws2-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-aws-secrets-manager</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
package org.apache.camel.quarkus.component.aws.secrets.manager.deployment;

import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.ExecutionTime;
import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild;
import org.apache.camel.quarkus.core.JvmOnlyRecorder;
import org.jboss.logging.Logger;

class AwsSecretsManagerProcessor {
Expand All @@ -33,14 +29,4 @@ class AwsSecretsManagerProcessor {
FeatureBuildItem feature() {
return new FeatureBuildItem(FEATURE);
}

/**
* Remove this once this extension starts supporting the native mode.
*/
@BuildStep(onlyIf = NativeOrNativeSourcesBuild.class)
@Record(value = ExecutionTime.RUNTIME_INIT)
void warnJvmInNative(JvmOnlyRecorder recorder) {
JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
recorder.warnJvmInNative(FEATURE); // warn at runtime
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-extensions-jvm</artifactId>
<artifactId>camel-quarkus-extensions</artifactId>
<version>3.19.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

<properties>
<camel.quarkus.jvmSince>2.0.0</camel.quarkus.jvmSince>
<camel.quarkus.nativeSince>3.19.0</camel.quarkus.nativeSince>
</properties>

<dependencies>
Expand All @@ -47,6 +48,10 @@
<groupId>org.jboss.logging</groupId>
<artifactId>commons-logging-jboss-logging</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-support-aws2</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ description: "Manage AWS Secrets Manager services using AWS SDK version 2.x"
metadata:
icon-url: "https://raw.githubusercontent.com/apache/camel-website/main/antora-ui-camel/src/img/logo-d.svg"
sponsor: "Apache Software Foundation"
unlisted: true
guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/aws-secrets-manager.html"
categories:
- "integration"
status:
- "preview"
- "stable"
1 change: 1 addition & 0 deletions extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<module>avro</module>
<!--<module>avro-rpc</module> https://github.com/apache/camel-quarkus/issues/4462 -->
<module>aws-bedrock</module>
<module>aws-secrets-manager</module>
<module>aws2-athena</module>
<module>aws2-cw</module>
<module>aws2-ddb</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-build-parent-it</artifactId>
<version>3.19.0-SNAPSHOT</version>
<relativePath>../../poms/build-parent-it/pom.xml</relativePath>
<relativePath>../../../poms/build-parent-it/pom.xml</relativePath>
</parent>

<artifactId>camel-quarkus-integration-test-aws-secrets-manager</artifactId>
Expand Down Expand Up @@ -72,6 +72,33 @@
</dependencies>

<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<properties>
<quarkus.native.enabled>true</quarkus.native.enabled>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>virtualDependencies</id>
<activation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.apache.camel.component.aws.secretsmanager.SecretsManagerConstants;
import org.apache.camel.component.aws.secretsmanager.SecretsManagerOperations;
import org.apache.camel.impl.event.CamelContextReloadedEvent;
import org.apache.camel.quarkus.test.support.aws2.BaseAws2Resource;
import org.apache.camel.spi.PeriodTaskResolver;
import org.apache.camel.support.PluginHelper;
import org.apache.camel.util.CollectionHelper;
Expand All @@ -57,7 +58,7 @@

@Path("/aws-secrets-manager")
@ApplicationScoped
public class AwsSecretsManagerResource {
public class AwsSecretsManagerResource extends BaseAws2Resource {

private static final Logger LOG = Logger.getLogger(AwsSecretsManagerResource.class);

Expand All @@ -69,6 +70,10 @@ public class AwsSecretsManagerResource {
@Inject
ProducerTemplate producerTemplate;

public AwsSecretsManagerResource() {
super(null, "camel.component.aws-secrets-manager");
}

static final AtomicBoolean contextReloaded = new AtomicBoolean(false);

void onReload(@Observes CamelContextReloadedEvent event) {
Expand All @@ -79,7 +84,10 @@ void onReload(@Observes CamelContextReloadedEvent event) {
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response post(@PathParam("operation") String operation, @QueryParam("body") String body, Map<String, Object> headers)
public Response post(@PathParam("operation") String operation,
@QueryParam("body") String body,
@QueryParam("useHeaders") boolean useHeaders,
Map<String, Object> headers)
throws Exception {

final Object resultBody;
Expand All @@ -95,7 +103,12 @@ public Response post(@PathParam("operation") String operation, @QueryParam("body

String region = headers.containsKey("region") ? String.format("region=%s&", headers.get("region")) : "";

Exchange ex = producerTemplate.send(String.format("aws-secrets-manager://test?%soperation=%s", region, operation),
String url = useHeaders ? String.format("aws-secrets-manager://test?%suseDefaultCredentialsProvider=%s",
region, isUseDefaultCredentials())
: String.format("aws-secrets-manager://test?%soperation=%s&useDefaultCredentialsProvider=%s",
region, operation, isUseDefaultCredentials());

Exchange ex = producerTemplate.send(url,
e -> {
e.getIn().setHeaders(headers);
e.getIn().setBody(resultBody);
Expand All @@ -114,10 +127,12 @@ public Response post(@PathParam("operation") String operation, @QueryParam("body
case describeSecret:
DescribeSecretResponse response = ex.getIn().getBody(DescribeSecretResponse.class);
result = CollectionHelper.mapOf("sdkHttpSuccessful", response.sdkHttpResponse().isSuccessful(),
"name", response.name());
"name", response.name(), "description", response.description(),
"description", response.description());
break;
case getSecret:
result = ex.getIn().getBody(String.class);
result = Map.of("body", ex.getIn().getBody(String.class),
"version", ex.getIn().getHeader(SecretsManagerConstants.SECRET_VERSION_ID));
break;
case deleteSecret:
result = ex.getIn().getBody(DeleteSecretResponse.class).sdkHttpResponse().isSuccessful();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.quarkus.component.aws.secrets.manager.it;

import io.quarkus.test.junit.QuarkusIntegrationTest;

@QuarkusIntegrationTest
class AwsSecretsManagerIT extends AwsSecretsManagerTest {

}
Loading

0 comments on commit 410fb3b

Please sign in to comment.