From 0f822d86de96b64d10a2f07cfae923f1cdfe9935 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Thu, 21 Dec 2023 13:26:37 +0100 Subject: [PATCH 1/5] Add an AWS STS Assume Role Action Kamelet Signed-off-by: Andrea Cosentino --- .../aws-sts-assume-role-action.kamelet.yaml | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 kamelets/aws-sts-assume-role-action.kamelet.yaml diff --git a/kamelets/aws-sts-assume-role-action.kamelet.yaml b/kamelets/aws-sts-assume-role-action.kamelet.yaml new file mode 100644 index 000000000..d53c864b4 --- /dev/null +++ b/kamelets/aws-sts-assume-role-action.kamelet.yaml @@ -0,0 +1,111 @@ +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +apiVersion: camel.apache.org/v1 +kind: Kamelet +metadata: + name: aws-sts-assume-role-action + annotations: + camel.apache.org/kamelet.support.level: "Stable" + camel.apache.org/catalog.version: "4.4.0-SNAPSHOT" + camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQ5MCIgcHJlc2VydmVBc3BlY3RSYXRpbz0ieE1pZFlNaWQiIHZpZXdCb3g9IjAgMCAyNTYgNDkwIiB3aWR0aD0iMjU2IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxnIGZpbGw9IiMzYzQ5MjkiPjxwYXRoIGQ9Im0yMSAxNjUuNzUtMjEgNi44NTYgMjEuNz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3N3YtMzQzLjAyOGwyOC41NzIgNS43MSAzMC41ODMgNC4wMzh2LTgyLjc4NGwtNTguMzM4LTIyLjQ5OC0uODE3LTIuNDY1di00OS4wMDN6IiBmaWxsPSIjNzU5YzNlIi8+PHBhdGggZD0ibTE2MC4zNTYgNjEuOTQxLTMyLjM1Ni0xMi45MzEtNjAuNzIzIDI0LjI3IDMyLjEzMSAxMC4wMTh6IiBmaWxsPSIjM2M0OTI5Ii8+PHBhdGggZD0ibTY3LjI3NyA3My4yOCA2MC43MjMtMjQuMjcgMTIuNzc1IDUuMTA0IDE5LjU4MSA3LjgyNyAyOC4zNTMgMTEuMzUzLTEuNTE1IDEuNTQxLTI4Ljg3NiA4Ljk5MS0xLjc0LS41MjgtMjguNTc4LTEwLjAxOC0yOC41OTIgMTAuMDE4eiIgZmlsbD0iIzNjNDkyOSIvPjxwYXRoIGQ9Im0xNTYuNTc4IDgzLjI5OCAzMi4xMzEtMTAuMDA0djg1Ljg2NGwtMzIuMTMxLTYuNDQ2eiIgZmlsbD0iIzRiNjEyYyIvPjwvc3ZnPg==" + camel.apache.org/provider: "Apache Software Foundation" + camel.apache.org/kamelet.group: "AWS STS" + camel.apache.org/kamelet.namespace: "AWS" + labels: + camel.apache.org/kamelet.type: "action" +spec: + definition: + title: "AWS STS Assume Role Action" + description: |- + Assume a role through STS + + Access Key/Secret Key are the basic method for authenticating to the AWS STS Service. These parameters are optional because the Kamelet provides the 'useDefaultCredentialsProvider'. + + When using a default Credentials Provider the Translate client will load the credentials through this provider and won't use the static credential. This is reason for not having the access key and secret key as mandatory parameter for this Kamelet. + + In the headers, you have to specify the `role-arn` / `ce-role-arn` property to specify the role ARN you want to assume. + + In the headers, you have to specify the `role-session-name` / `ce-role-session-name` property to specify the role Session name you want to use. + required: + - region + type: object + properties: + accessKey: + title: Access Key + description: The access key obtained from AWS. + type: string + format: password + x-descriptors: + - urn:camel:group:credentials + secretKey: + title: Secret Key + description: The secret key obtained from AWS. + type: string + format: password + x-descriptors: + - urn:camel:group:credentials + region: + title: AWS Region + description: The AWS region to access. + type: string + enum: ["ap-south-1", "eu-south-1", "us-gov-east-1", "me-central-1", "ca-central-1", "eu-central-1", "us-iso-west-1", "us-west-1", "us-west-2", "af-south-1", "eu-north-1", "eu-west-3", "eu-west-2", "eu-west-1", "ap-northeast-3", "ap-northeast-2", "ap-northeast-1", "me-south-1", "sa-east-1", "ap-east-1", "cn-north-1", "us-gov-west-1", "ap-southeast-1", "ap-southeast-2", "us-iso-east-1", "ap-southeast-3", "us-east-1", "us-east-2", "cn-northwest-1", "us-isob-east-1", "aws-global", "aws-cn-global", "aws-us-gov-global", "aws-iso-global", "aws-iso-b-global"] + useDefaultCredentialsProvider: + title: Default Credentials Provider + description: Set whether the STS client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in. + type: boolean + default: false + dependencies: + - "camel:dns" + - "camel:kamelet" + - "camel:aws2-translate" + template: + from: + uri: "kamelet:source" + steps: + - choice: + when: + - simple: "${header[role-arn]}" + steps: + - setHeader: + name: CamelAwsStsRoleArn + simple: "${header[role-arn]}" + - simple: "${header[ce-role-arn]}" + steps: + - setHeader: + name: CamelAwsStsRoleArn + simple: "${header[ce-role-arn]}" + - choice: + when: + - simple: "${header[role-session-name]}" + steps: + - setHeader: + name: CamelAwsStsRoleSessionName + simple: "${header[role-session-name]}" + - simple: "${header[ce-role-session-name]}" + steps: + - setHeader: + name: CamelAwsStsRoleSessionName + simple: "${header[ce-role-session-name]}" + - to: + uri: "aws2-sts://default" + parameters: + secretKey: "{{?secretKey}}" + accessKey: "{{?accessKey}}" + region: "{{region}}" + operation: "assumeRole" + useDefaultCredentialsProvider: "{{useDefaultCredentialsProvider}}" From 3f94d27dd5b95bc8694c61577be166917fb624bd Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Thu, 21 Dec 2023 13:28:01 +0100 Subject: [PATCH 2/5] Add an AWS STS Assume Role Action Kamelet Signed-off-by: Andrea Cosentino --- .../aws-sts-assume-role-action.kamelet.yaml | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 library/camel-kamelets/src/main/resources/kamelets/aws-sts-assume-role-action.kamelet.yaml diff --git a/library/camel-kamelets/src/main/resources/kamelets/aws-sts-assume-role-action.kamelet.yaml b/library/camel-kamelets/src/main/resources/kamelets/aws-sts-assume-role-action.kamelet.yaml new file mode 100644 index 000000000..d53c864b4 --- /dev/null +++ b/library/camel-kamelets/src/main/resources/kamelets/aws-sts-assume-role-action.kamelet.yaml @@ -0,0 +1,111 @@ +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +apiVersion: camel.apache.org/v1 +kind: Kamelet +metadata: + name: aws-sts-assume-role-action + annotations: + camel.apache.org/kamelet.support.level: "Stable" + camel.apache.org/catalog.version: "4.4.0-SNAPSHOT" + camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQ5MCIgcHJlc2VydmVBc3BlY3RSYXRpbz0ieE1pZFlNaWQiIHZpZXdCb3g9IjAgMCAyNTYgNDkwIiB3aWR0aD0iMjU2IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxnIGZpbGw9IiMzYzQ5MjkiPjxwYXRoIGQ9Im0yMSAxNjUuNzUtMjEgNi44NTYgMjEuNzUgMi41MTl6Ii8+PHBhdGggZD0ibTE5Ljk1NSAyMDYuODA2IDEwOC4wNDUgNi45MDggMTA4LjA0NS02LjkwOC0xMDguMDQ1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00OS4wMDN6IiBmaWxsPSIjNzU5YzNlIi8+PHBhdGggZD0ibTE2MC4zNTYgNjEuOTQxLTMyLjM1Ni0xMi45MzEtNjAuNzIzIDI0LjI3IDMyLjEzMSAxMC4wMTh6IiBmaWxsPSIjM2M0OTI5Ii8+PHBhdGggZD0ibTY3LjI3NyA3My4yOCA2MC43MjMtMjQuMjcgMTIuNzc1IDUuMTA0IDE5LjU4MSA3LjgyNyAyOC4zNTMgMTEuMzUzLTEuNTE1IDEuNTQxLTI4Ljg3NiA4Ljk5MS0xLjc0LS41MjgtMjguNTc4LTEwLjAxOC0yOC41OTIgMTAuMDE4eiIgZmlsbD0iIzNjNDkyOSIvPjxwYXRoIGQ9Im0xNTYuNTc4IDgzLjI5OCAzMi4xMzEtMTAuMDA0djg1Ljg2NGwtMzIuMTMxLTYuNDQ2eiIgZmlsbD0iIzRiNjEyYyIvPjwvc3ZnPg==" + camel.apache.org/provider: "Apache Software Foundation" + camel.apache.org/kamelet.group: "AWS STS" + camel.apache.org/kamelet.namespace: "AWS" + labels: + camel.apache.org/kamelet.type: "action" +spec: + definition: + title: "AWS STS Assume Role Action" + description: |- + Assume a role through STS + + Access Key/Secret Key are the basic method for authenticating to the AWS STS Service. These parameters are optional because the Kamelet provides the 'useDefaultCredentialsProvider'. + + When using a default Credentials Provider the Translate client will load the credentials through this provider and won't use the static credential. This is reason for not having the access key and secret key as mandatory parameter for this Kamelet. + + In the headers, you have to specify the `role-arn` / `ce-role-arn` property to specify the role ARN you want to assume. + + In the headers, you have to specify the `role-session-name` / `ce-role-session-name` property to specify the role Session name you want to use. + required: + - region + type: object + properties: + accessKey: + title: Access Key + description: The access key obtained from AWS. + type: string + format: password + x-descriptors: + - urn:camel:group:credentials + secretKey: + title: Secret Key + description: The secret key obtained from AWS. + type: string + format: password + x-descriptors: + - urn:camel:group:credentials + region: + title: AWS Region + description: The AWS region to access. + type: string + enum: ["ap-south-1", "eu-south-1", "us-gov-east-1", "me-central-1", "ca-central-1", "eu-central-1", "us-iso-west-1", "us-west-1", "us-west-2", "af-south-1", "eu-north-1", "eu-west-3", "eu-west-2", "eu-west-1", "ap-northeast-3", "ap-northeast-2", "ap-northeast-1", "me-south-1", "sa-east-1", "ap-east-1", "cn-north-1", "us-gov-west-1", "ap-southeast-1", "ap-southeast-2", "us-iso-east-1", "ap-southeast-3", "us-east-1", "us-east-2", "cn-northwest-1", "us-isob-east-1", "aws-global", "aws-cn-global", "aws-us-gov-global", "aws-iso-global", "aws-iso-b-global"] + useDefaultCredentialsProvider: + title: Default Credentials Provider + description: Set whether the STS client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in. + type: boolean + default: false + dependencies: + - "camel:dns" + - "camel:kamelet" + - "camel:aws2-translate" + template: + from: + uri: "kamelet:source" + steps: + - choice: + when: + - simple: "${header[role-arn]}" + steps: + - setHeader: + name: CamelAwsStsRoleArn + simple: "${header[role-arn]}" + - simple: "${header[ce-role-arn]}" + steps: + - setHeader: + name: CamelAwsStsRoleArn + simple: "${header[ce-role-arn]}" + - choice: + when: + - simple: "${header[role-session-name]}" + steps: + - setHeader: + name: CamelAwsStsRoleSessionName + simple: "${header[role-session-name]}" + - simple: "${header[ce-role-session-name]}" + steps: + - setHeader: + name: CamelAwsStsRoleSessionName + simple: "${header[ce-role-session-name]}" + - to: + uri: "aws2-sts://default" + parameters: + secretKey: "{{?secretKey}}" + accessKey: "{{?accessKey}}" + region: "{{region}}" + operation: "assumeRole" + useDefaultCredentialsProvider: "{{useDefaultCredentialsProvider}}" From 3277469c3aec393516988bd50849ff172421f7ed Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Thu, 21 Dec 2023 13:30:51 +0100 Subject: [PATCH 3/5] Add an AWS STS Assume Role Action Kamelet Signed-off-by: Andrea Cosentino --- docs/modules/ROOT/nav.adoc | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index 2b1466246..e1d902e6c 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -25,6 +25,7 @@ * xref:aws-sqs-fifo-sink.adoc[] * xref:aws-sqs-sink.adoc[] * xref:aws-sqs-source.adoc[] +* xref:aws-sts-assume-role-action.adoc[] * xref:aws-timestream-query-sink.adoc[] * xref:aws-translate-action.adoc[] * xref:azure-cosmosdb-sink.adoc[] From 03d205e04d56a1046d9a4511dfd6e1d1c67ca170 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Thu, 21 Dec 2023 13:31:32 +0100 Subject: [PATCH 4/5] Add an AWS STS Assume Role Action Kamelet Signed-off-by: Andrea Cosentino --- kamelets/aws-sts-assume-role-action.kamelet.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kamelets/aws-sts-assume-role-action.kamelet.yaml b/kamelets/aws-sts-assume-role-action.kamelet.yaml index d53c864b4..fb095aecd 100644 --- a/kamelets/aws-sts-assume-role-action.kamelet.yaml +++ b/kamelets/aws-sts-assume-role-action.kamelet.yaml @@ -72,7 +72,8 @@ spec: dependencies: - "camel:dns" - "camel:kamelet" - - "camel:aws2-translate" + - "camel:core" + - "camel:aws2-sts" template: from: uri: "kamelet:source" From a75dd6caf72c42ba93fbfebe276961bd82cd8941 Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Thu, 21 Dec 2023 13:32:25 +0100 Subject: [PATCH 5/5] Add an AWS STS Assume Role Action Kamelet Signed-off-by: Andrea Cosentino --- .../org/apache/camel/kamelets/catalog/KameletsCatalogTest.java | 2 +- .../resources/kamelets/aws-sts-assume-role-action.kamelet.yaml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/library/camel-kamelets-catalog/src/test/java/org/apache/camel/kamelets/catalog/KameletsCatalogTest.java b/library/camel-kamelets-catalog/src/test/java/org/apache/camel/kamelets/catalog/KameletsCatalogTest.java index 065105752..abb5b9957 100644 --- a/library/camel-kamelets-catalog/src/test/java/org/apache/camel/kamelets/catalog/KameletsCatalogTest.java +++ b/library/camel-kamelets-catalog/src/test/java/org/apache/camel/kamelets/catalog/KameletsCatalogTest.java @@ -103,7 +103,7 @@ void testGetKameletsByGroup() throws Exception { void testGetKameletsByNamespace() throws Exception { List c = catalog.getKameletsByNamespace("AWS"); assertFalse(c.isEmpty()); - assertEquals(26, c.size()); + assertEquals(27, c.size()); c = catalog.getKameletsByGroups("Not-existing-group"); assertTrue(c.isEmpty()); } diff --git a/library/camel-kamelets/src/main/resources/kamelets/aws-sts-assume-role-action.kamelet.yaml b/library/camel-kamelets/src/main/resources/kamelets/aws-sts-assume-role-action.kamelet.yaml index d53c864b4..fb095aecd 100644 --- a/library/camel-kamelets/src/main/resources/kamelets/aws-sts-assume-role-action.kamelet.yaml +++ b/library/camel-kamelets/src/main/resources/kamelets/aws-sts-assume-role-action.kamelet.yaml @@ -72,7 +72,8 @@ spec: dependencies: - "camel:dns" - "camel:kamelet" - - "camel:aws2-translate" + - "camel:core" + - "camel:aws2-sts" template: from: uri: "kamelet:source"