This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch CAMEL-21021 in repository https://gitbox.apache.org/repos/asf/camel.git
commit 7acca82fb48d5954f731161162dd43cdf69399f7 Author: Andrea Cosentino <[email protected]> AuthorDate: Mon Jul 29 09:36:23 2024 +0200 CAMEL-21021 - Camel-AWS-Secrets-Manager: Give the ability of refreshing the context on Secrets update by using Eventbridge service instead of pure Cloudtrail Signed-off-by: Andrea Cosentino <[email protected]> --- .../apache/camel/vault/AwsVaultConfiguration.java | 27 ++++++++++++++++++++++ .../main/AwsVaultConfigurationConfigurer.java | 12 ++++++++++ .../AwsVaultConfigurationPropertiesConfigurer.java | 12 ++++++++++ .../camel-main-configuration-metadata.json | 2 ++ core/camel-main/src/main/docs/main.adoc | 4 +++- .../main/AwsVaultConfigurationProperties.java | 17 ++++++++++++++ .../java/org/apache/camel/main/MainVaultTest.java | 24 +++++++++++++++++++ 7 files changed, 97 insertions(+), 1 deletion(-) diff --git a/core/camel-api/src/main/java/org/apache/camel/vault/AwsVaultConfiguration.java b/core/camel-api/src/main/java/org/apache/camel/vault/AwsVaultConfiguration.java index e686031d21a..72ed6b656b7 100644 --- a/core/camel-api/src/main/java/org/apache/camel/vault/AwsVaultConfiguration.java +++ b/core/camel-api/src/main/java/org/apache/camel/vault/AwsVaultConfiguration.java @@ -41,6 +41,10 @@ public class AwsVaultConfiguration extends VaultConfiguration { private long refreshPeriod = 30000; @Metadata private String secrets; + @Metadata + private boolean useSqsNotification; + @Metadata + private String sqsQueueName; public String getAccessKey() { return accessKey; @@ -140,4 +144,27 @@ public class AwsVaultConfiguration extends VaultConfiguration { public void setSecrets(String secrets) { this.secrets = secrets; } + + public boolean isUseSqsNotification() { + return useSqsNotification; + } + + /** + * Whether to use AWS SQS for secrets updates notification, this will require setting up Eventbridge/Cloudtrail/SQS + * communication + */ + public void setUseSqsNotification(boolean useSqsNotification) { + this.useSqsNotification = useSqsNotification; + } + + public String getSqsQueueName() { + return sqsQueueName; + } + + /** + * In case of usage of SQS notification this field will specified the Queue name to use + */ + public void setSqsQueueName(String sqsQueueName) { + this.sqsQueueName = sqsQueueName; + } } diff --git a/core/camel-main/src/generated/java/org/apache/camel/main/AwsVaultConfigurationConfigurer.java b/core/camel-main/src/generated/java/org/apache/camel/main/AwsVaultConfigurationConfigurer.java index 79ab686dbd4..12636eefeb5 100644 --- a/core/camel-main/src/generated/java/org/apache/camel/main/AwsVaultConfigurationConfigurer.java +++ b/core/camel-main/src/generated/java/org/apache/camel/main/AwsVaultConfigurationConfigurer.java @@ -47,6 +47,10 @@ public class AwsVaultConfigurationConfigurer extends org.apache.camel.support.co case "secretkey": case "secretKey": target.setSecretKey(property(camelContext, java.lang.String.class, value)); return true; case "secrets": target.setSecrets(property(camelContext, java.lang.String.class, value)); return true; + case "sqsqueuename": + case "sqsQueueName": target.setSqsQueueName(property(camelContext, java.lang.String.class, value)); return true; + case "usesqsnotification": + case "useSqsNotification": target.setUseSqsNotification(property(camelContext, boolean.class, value)); return true; default: return false; } } @@ -78,6 +82,10 @@ public class AwsVaultConfigurationConfigurer extends org.apache.camel.support.co case "secretkey": case "secretKey": return java.lang.String.class; case "secrets": return java.lang.String.class; + case "sqsqueuename": + case "sqsQueueName": return java.lang.String.class; + case "usesqsnotification": + case "useSqsNotification": return boolean.class; default: return null; } } @@ -110,6 +118,10 @@ public class AwsVaultConfigurationConfigurer extends org.apache.camel.support.co case "secretkey": case "secretKey": return target.getSecretKey(); case "secrets": return target.getSecrets(); + case "sqsqueuename": + case "sqsQueueName": return target.getSqsQueueName(); + case "usesqsnotification": + case "useSqsNotification": return target.isUseSqsNotification(); default: return null; } } diff --git a/core/camel-main/src/generated/java/org/apache/camel/main/AwsVaultConfigurationPropertiesConfigurer.java b/core/camel-main/src/generated/java/org/apache/camel/main/AwsVaultConfigurationPropertiesConfigurer.java index de5336e6680..a61c7726914 100644 --- a/core/camel-main/src/generated/java/org/apache/camel/main/AwsVaultConfigurationPropertiesConfigurer.java +++ b/core/camel-main/src/generated/java/org/apache/camel/main/AwsVaultConfigurationPropertiesConfigurer.java @@ -47,6 +47,10 @@ public class AwsVaultConfigurationPropertiesConfigurer extends org.apache.camel. case "secretkey": case "secretKey": target.setSecretKey(property(camelContext, java.lang.String.class, value)); return true; case "secrets": target.setSecrets(property(camelContext, java.lang.String.class, value)); return true; + case "sqsqueuename": + case "sqsQueueName": target.setSqsQueueName(property(camelContext, java.lang.String.class, value)); return true; + case "usesqsnotification": + case "useSqsNotification": target.setUseSqsNotification(property(camelContext, boolean.class, value)); return true; default: return false; } } @@ -78,6 +82,10 @@ public class AwsVaultConfigurationPropertiesConfigurer extends org.apache.camel. case "secretkey": case "secretKey": return java.lang.String.class; case "secrets": return java.lang.String.class; + case "sqsqueuename": + case "sqsQueueName": return java.lang.String.class; + case "usesqsnotification": + case "useSqsNotification": return boolean.class; default: return null; } } @@ -110,6 +118,10 @@ public class AwsVaultConfigurationPropertiesConfigurer extends org.apache.camel. case "secretkey": case "secretKey": return target.getSecretKey(); case "secrets": return target.getSecrets(); + case "sqsqueuename": + case "sqsQueueName": return target.getSqsQueueName(); + case "usesqsnotification": + case "useSqsNotification": return target.isUseSqsNotification(); default: return null; } } diff --git a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json index e917f1a6269..e313418d297 100644 --- a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json +++ b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json @@ -306,6 +306,8 @@ { "name": "camel.vault.aws.region", "description": "The AWS region", "sourceType": "org.apache.camel.vault.AwsVaultConfiguration", "type": "string", "javaType": "java.lang.String" }, { "name": "camel.vault.aws.secretKey", "description": "The AWS secret key", "sourceType": "org.apache.camel.vault.AwsVaultConfiguration", "type": "string", "javaType": "java.lang.String" }, { "name": "camel.vault.aws.secrets", "description": "Specify the secret names (or pattern) to check for updates. Multiple secrets can be separated by comma.", "sourceType": "org.apache.camel.vault.AwsVaultConfiguration", "type": "string", "javaType": "java.lang.String" }, + { "name": "camel.vault.aws.sqsQueueName", "description": "In case of usage of SQS notification this field will specified the Queue name to use", "sourceType": "org.apache.camel.vault.AwsVaultConfiguration", "type": "string", "javaType": "java.lang.String" }, + { "name": "camel.vault.aws.useSqsNotification", "description": "Whether to use AWS SQS for secrets updates notification, this will require setting up Eventbridge\/Cloudtrail\/SQS communication", "sourceType": "org.apache.camel.vault.AwsVaultConfiguration", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, { "name": "camel.vault.azure.azureIdentityEnabled", "description": "Whether the Azure Identity Authentication should be used or not.", "sourceType": "org.apache.camel.vault.AzureVaultConfiguration", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, { "name": "camel.vault.azure.blobAccessKey", "description": "The Eventhubs Blob Access Key for CheckpointStore purpose", "sourceType": "org.apache.camel.vault.AzureVaultConfiguration", "type": "string", "javaType": "java.lang.String" }, { "name": "camel.vault.azure.blobAccountName", "description": "The Eventhubs Blob Account Name for CheckpointStore purpose", "sourceType": "org.apache.camel.vault.AzureVaultConfiguration", "type": "string", "javaType": "java.lang.String" }, diff --git a/core/camel-main/src/main/docs/main.adoc b/core/camel-main/src/main/docs/main.adoc index 7933f980f5d..1cbf2c55858 100644 --- a/core/camel-main/src/main/docs/main.adoc +++ b/core/camel-main/src/main/docs/main.adoc @@ -325,7 +325,7 @@ The camel.rest supports 29 options, which are listed below. === Camel AWS Vault configurations -The camel.vault.aws supports 9 options, which are listed below. +The camel.vault.aws supports 11 options, which are listed below. [width="100%",cols="2,5,^1,2",options="header"] |=== @@ -339,6 +339,8 @@ The camel.vault.aws supports 9 options, which are listed below. | *camel.vault.aws.region* | The AWS region | | String | *camel.vault.aws.secretKey* | The AWS secret key | | String | *camel.vault.aws.secrets* | Specify the secret names (or pattern) to check for updates. Multiple secrets can be separated by comma. | | String +| *camel.vault.aws.sqsQueueName* | In case of usage of SQS notification this field will specified the Queue name to use | | String +| *camel.vault.aws.useSqs{zwsp}Notification* | Whether to use AWS SQS for secrets updates notification, this will require setting up Eventbridge/Cloudtrail/SQS communication | false | boolean |=== diff --git a/core/camel-main/src/main/java/org/apache/camel/main/AwsVaultConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/AwsVaultConfigurationProperties.java index 9dc9e3d3a7e..bce45e8d3a9 100644 --- a/core/camel-main/src/main/java/org/apache/camel/main/AwsVaultConfigurationProperties.java +++ b/core/camel-main/src/main/java/org/apache/camel/main/AwsVaultConfigurationProperties.java @@ -121,4 +121,21 @@ public class AwsVaultConfigurationProperties extends AwsVaultConfiguration imple return this; } + /** + * Whether to use AWS SQS for secrets updates notification, this will require setting up Eventbridge/Cloudtrail/SQS + * communication + */ + public AwsVaultConfigurationProperties withUseSqsNotification(boolean useSqsNotification) { + setUseSqsNotification(useSqsNotification); + return this; + } + + /** + * In case of usage of SQS notification this field will specified the Queue name to use + */ + public AwsVaultConfigurationProperties withSqsQueueName(String sqsQueueName) { + setSqsQueueName(sqsQueueName); + return this; + } + } diff --git a/core/camel-main/src/test/java/org/apache/camel/main/MainVaultTest.java b/core/camel-main/src/test/java/org/apache/camel/main/MainVaultTest.java index 312725ae10b..d70347ecf1e 100644 --- a/core/camel-main/src/test/java/org/apache/camel/main/MainVaultTest.java +++ b/core/camel-main/src/test/java/org/apache/camel/main/MainVaultTest.java @@ -82,11 +82,35 @@ public class MainVaultTest { main.addInitialProperty("camel.vault.aws.defaultCredentialsProvider", "false"); main.addInitialProperty("camel.vault.aws.profileCredentialsProvider", "true"); main.addInitialProperty("camel.vault.aws.profileName", "jack"); + main.addInitialProperty("camel.vault.aws.sqsQueueName", "sqs-2"); + main.addInitialProperty("camel.vault.aws.useSqsNotification", "true"); main.start(); return main; } + @Test + public void testUseSqsNotification() { + final Main main = getMain(); + + CamelContext context = main.getCamelContext(); + assertNotNull(context); + + AwsVaultConfiguration cfg = context.getVaultConfiguration().aws(); + assertNotNull(cfg); + + Assertions.assertEquals("myKey", cfg.getAccessKey()); + Assertions.assertEquals("mySecret", cfg.getSecretKey()); + Assertions.assertEquals("myRegion", cfg.getRegion()); + Assertions.assertFalse(cfg.isDefaultCredentialsProvider()); + Assertions.assertTrue(cfg.isProfileCredentialsProvider()); + Assertions.assertEquals("jack", cfg.getProfileName()); + Assertions.assertEquals("sqs-2", cfg.getSqsQueueName()); + Assertions.assertTrue(cfg.isUseSqsNotification()); + + main.stop(); + } + @Test public void testMainAwsFluent() { Main main = new Main();
