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.git
commit c69d7839dae9910eb48b53749dd920124354372f Author: Andrea Cosentino <[email protected]> AuthorDate: Fri Jun 9 11:09:11 2023 +0200 CAMEL-19159 - Camel-AWS: Support Profile Credential provider as configuration - AWS Lambda Signed-off-by: Andrea Cosentino <[email protected]> --- .../component/aws2/lambda/Lambda2Component.java | 6 +++-- .../aws2/lambda/Lambda2Configuration.java | 27 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Component.java b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Component.java index 8e583ca63b4..e043ce35d9a 100644 --- a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Component.java +++ b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Component.java @@ -47,10 +47,12 @@ public class Lambda2Component extends DefaultComponent { Lambda2Endpoint endpoint = new Lambda2Endpoint(uri, this, configuration); setProperties(endpoint, parameters); endpoint.setFunction(remaining); - if (Boolean.FALSE.equals(configuration.isUseDefaultCredentialsProvider()) && configuration.getAwsLambdaClient() == null + if (Boolean.FALSE.equals(configuration.isUseDefaultCredentialsProvider()) + && Boolean.FALSE.equals(configuration.isUseProfileCredentialsProvider()) + && configuration.getAwsLambdaClient() == null && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) { throw new IllegalArgumentException( - "useDefaultCredentialsProvider is set to false, accessKey/secretKey or awsLambdaClient must be specified"); + "useDefaultCredentialsProvider is set to false, useProfileCredentialsProvider is set to false, AmazonLambdaClient or accessKey and secretKey must be specified"); } return endpoint; diff --git a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Configuration.java b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Configuration.java index 1ecfd3448e8..681ed852aad 100644 --- a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Configuration.java +++ b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Configuration.java @@ -53,6 +53,10 @@ public class Lambda2Configuration implements Cloneable { private String uriEndpointOverride; @UriParam(defaultValue = "false") private boolean useDefaultCredentialsProvider; + @UriParam(defaultValue = "false") + private boolean useProfileCredentialsProvider; + @UriParam + private String profileCredentialsName; public LambdaClient getAwsLambdaClient() { return awsLambdaClient; @@ -199,6 +203,29 @@ public class Lambda2Configuration implements Cloneable { public Boolean isUseDefaultCredentialsProvider() { return useDefaultCredentialsProvider; } + + /** + * Set whether the Lambda client should expect to load credentials through a profile credentials provider. + */ + public void setUseProfileCredentialsProvider(boolean useProfileCredentialsProvider) { + this.useProfileCredentialsProvider = useProfileCredentialsProvider; + } + + public String getProfileCredentialsName() { + return profileCredentialsName; + } + + /** + * If using a profile credentials provider this parameter will set the profile name + */ + public void setProfileCredentialsName(String profileCredentialsName) { + this.profileCredentialsName = profileCredentialsName; + } + + public boolean isUseProfileCredentialsProvider() { + return useProfileCredentialsProvider; + } + // ************************************************* // // *************************************************
