This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-kamelets-examples.git
The following commit(s) were added to refs/heads/main by this push: new 2707697 Added a little example of AWS Secrets Manager Reloading 2707697 is described below commit 27076979101f67c90934c8932a24f41c2e6db5e1 Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Thu Sep 8 08:33:15 2022 +0200 Added a little example of AWS Secrets Manager Reloading --- jbang/aws-secrets-manager/README.adoc | 98 ++++++++++++++++++++++ .../aws-sec-integration.properties | 7 ++ .../timer-aws-secret-reloading.yaml | 32 +++++++ 3 files changed, 137 insertions(+) diff --git a/jbang/aws-secrets-manager/README.adoc b/jbang/aws-secrets-manager/README.adoc new file mode 100644 index 0000000..4d965b4 --- /dev/null +++ b/jbang/aws-secrets-manager/README.adoc @@ -0,0 +1,98 @@ +== AWS Secrets Manager Vault Example + +In this sample you'll use the AWS Secrets Manager Vault Properties Source + +=== Install JBang + +First install JBang according to https://www.jbang.dev + +When JBang is installed then you should be able to run from a shell: + +[source,sh] +---- +$ jbang --version +---- + +This will output the version of JBang. + +To run this example you can either install Camel on JBang via: + +[source,sh] +---- +$ jbang app install camel@apache/camel +---- + +Which allows to run CamelJBang with `camel` as shown below. + +=== Setup the AWS Secret Manager service + +Create a secret on AWS + +[source,sh] +---- +aws secretsmanager create-secret --name SecretTest --description "Create a secret" --region eu-west-1 --secret-string secret +---- + +=== Setting up the AWS credentials + +This example uses the ProfileCredentialsProvider from AWS SDK v2. So you'll need to have a configuration file, locally to your machine. + +In particular you'll need to have a file placed in `~/.aws/credentials` + +with a content like the following + +[source,sh] +---- +[default] +aws_access_key_id = accessKey +aws_secret_access_key = secretKey +---- + +=== How to run + +Then you can run this example using: + +[source,sh] +---- +$ camel run --properties=aws-sec-integration.properties timer-aws-secret-reloading.yaml +---- + +Or run with JBang using the longer command line (without installing camel as app in JBang): + +[source,sh] +---- +$ jbang camel@apache/camel run --properties=aws-sec-integration.properties timer-aws-secret-reloading.yaml +---- + +=== Modify the secret + +While the integration is running you could modify the secret and the integration will reload automatically + +[source,sh] +---- +aws secretsmanager put-secret-value --secret-id SecretTest --region eu-west-1 --secret-string secretImproved +---- + +Now, get back, to the running Camel application and wait for the reloading. + +=== Developer Web Console + +You can enable the developer console via `--console` flag as show: + +[source,sh] +---- +$ camel run --properties=aws-sec-integration.properties timer-aws-secret-reloading.yaml --console +---- + +Then you can browse: http://localhost:8080/q/dev to introspect the running Camel applicaton. + + +=== Help and contributions + +If you hit any problem using Camel or have some feedback, then please +https://camel.apache.org/community/support/[let us know]. + +We also love contributors, so +https://camel.apache.org/community/contributing/[get involved] :-) + +The Camel riders! diff --git a/jbang/aws-secrets-manager/aws-sec-integration.properties b/jbang/aws-secrets-manager/aws-sec-integration.properties new file mode 100644 index 0000000..75f973f --- /dev/null +++ b/jbang/aws-secrets-manager/aws-sec-integration.properties @@ -0,0 +1,7 @@ +camel.vault.aws.defaultCredentialsProvider=true +camel.vault.aws.region=eu-west-1 +camel.vault.aws.refreshEnabled=true +camel.vault.aws.refreshPeriod=60000 +camel.vault.aws.secrets=SecretTest +camel.main.context-reload-enabled = true +camel.main.name = AWS-secrets-manager diff --git a/jbang/aws-secrets-manager/timer-aws-secret-reloading.yaml b/jbang/aws-secrets-manager/timer-aws-secret-reloading.yaml new file mode 100644 index 0000000..2942c7c --- /dev/null +++ b/jbang/aws-secrets-manager/timer-aws-secret-reloading.yaml @@ -0,0 +1,32 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# camel-k: dependency=camel:aws-secrets-manager + +- route: + from: + uri: "kamelet:timer-source" + parameters: + period: 10000 + message: 'test' + steps: + - set-body: + simple: "Secret is {{aws:SecretTest}}" + - to: + uri: "kamelet:log-sink" + parameters: + showStreams: true