This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch CAMEL-22786-complete
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 4bbb255c75199d6683220527f364851d251b9bb4
Author: Andrea Cosentino <[email protected]>
AuthorDate: Tue Dec 16 11:17:08 2025 +0100

    CAMEL-22786 - Camel-AWS: Extract common logic for clients instantiation in 
a separated module - AWS ECS, AWS EC2, AWS SES, AWS STS
    
    Signed-off-by: Andrea Cosentino <[email protected]>
---
 components/camel-aws/camel-aws2-ec2/pom.xml        |   4 +
 .../component/aws2/ec2/AWS2EC2Configuration.java   |   9 +-
 .../camel/component/aws2/ec2/AWS2EC2Endpoint.java  |   2 +-
 .../aws2/ec2/client/AWS2EC2ClientFactory.java      |  28 ++----
 .../aws2/ec2/client/AWS2EC2InternalClient.java     |  32 ------
 .../client/impl/AWS2EC2ClientIAMOptimizedImpl.java |  93 -----------------
 .../impl/AWS2EC2ClientIAMProfileOptimizedImpl.java |  98 ------------------
 .../client/impl/AWS2EC2ClientSessionTokenImpl.java | 111 ---------------------
 .../ec2/client/impl/AWS2EC2ClientStandardImpl.java | 109 --------------------
 .../aws2/ec2/AWS2EC2ClientFactoryTest.java         |  53 +++++-----
 components/camel-aws/camel-aws2-ecs/pom.xml        |   4 +
 .../component/aws2/ecs/ECS2Configuration.java      |   9 +-
 .../camel/component/aws2/ecs/ECS2Endpoint.java     |   2 +-
 .../aws2/ecs/client/ECS2ClientFactory.java         |  28 ++----
 .../aws2/ecs/client/ECS2InternalClient.java        |  32 ------
 .../client/impl/ECS2ClientIAMOptimizedImpl.java    |  93 -----------------
 .../impl/ECS2ClientIAMProfileOptimizedImpl.java    |  98 ------------------
 .../client/impl/ECS2ClientSessionTokenImpl.java    | 111 ---------------------
 .../ecs/client/impl/ECS2ClientStandardImpl.java    | 109 --------------------
 .../component/aws2/ecs/ECS2ClientFactoryTest.java  |  53 +++++-----
 components/camel-aws/camel-aws2-ses/pom.xml        |   4 +
 .../component/aws2/ses/Ses2Configuration.java      |   8 +-
 .../camel/component/aws2/ses/Ses2Endpoint.java     |   2 +-
 .../aws2/ses/client/Ses2ClientFactory.java         |  28 ++----
 .../aws2/ses/client/Ses2InternalClient.java        |  32 ------
 .../ses/client/impl/Ses2ClientOptimizedImpl.java   |  93 -----------------
 .../impl/Ses2ClientProfileOptimizedImpl.java       |  98 ------------------
 .../client/impl/Ses2ClientSessionTokenImpl.java    | 111 ---------------------
 .../ses/client/impl/Ses2ClientStandardImpl.java    | 109 --------------------
 .../component/aws2/ses/Ses2ClientFactoryTest.java  |  53 +++++-----
 components/camel-aws/camel-aws2-sts/pom.xml        |   4 +
 .../component/aws2/sts/STS2Configuration.java      |  21 +++-
 .../camel/component/aws2/sts/STS2Endpoint.java     |   2 +-
 .../aws2/sts/client/STS2ClientFactory.java         |  25 ++---
 .../aws2/sts/client/STS2InternalClient.java        |  30 ------
 .../sts/client/impl/STS2ClientIAMOptimized.java    |  94 -----------------
 .../client/impl/STS2ClientIAMProfileOptimized.java |  99 ------------------
 .../sts/client/impl/STS2ClientStandardImpl.java    | 109 --------------------
 .../component/aws2/sts/STS2ClientFactoryTest.java  |  44 ++++----
 39 files changed, 199 insertions(+), 1845 deletions(-)

diff --git a/components/camel-aws/camel-aws2-ec2/pom.xml 
b/components/camel-aws/camel-aws2-ec2/pom.xml
index 6854db09c0f0..ea5a0d78878d 100644
--- a/components/camel-aws/camel-aws2-ec2/pom.xml
+++ b/components/camel-aws/camel-aws2-ec2/pom.xml
@@ -40,6 +40,10 @@
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-support</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-aws-common</artifactId>
+        </dependency>
         <dependency>
             <groupId>software.amazon.awssdk</groupId>
             <artifactId>ec2</artifactId>
diff --git 
a/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2Configuration.java
 
b/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2Configuration.java
index 10de36ec9a08..b10991139587 100644
--- 
a/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2Configuration.java
+++ 
b/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2Configuration.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.aws2.ec2;
 
 import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.component.aws.common.AwsCommonConfiguration;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriParams;
@@ -25,7 +26,7 @@ import software.amazon.awssdk.core.Protocol;
 import software.amazon.awssdk.services.ec2.Ec2Client;
 
 @UriParams
-public class AWS2EC2Configuration implements Cloneable {
+public class AWS2EC2Configuration implements Cloneable, AwsCommonConfiguration 
{
 
     @UriPath(description = "Logical name")
     @Metadata(required = true)
@@ -218,14 +219,16 @@ public class AWS2EC2Configuration implements Cloneable {
      * Set whether the EC2 client should expect to load credentials through a 
default credentials provider or to expect
      * static credentials to be passed in.
      */
-    public void setUseDefaultCredentialsProvider(Boolean 
useDefaultCredentialsProvider) {
+    public void setUseDefaultCredentialsProvider(boolean 
useDefaultCredentialsProvider) {
         this.useDefaultCredentialsProvider = useDefaultCredentialsProvider;
     }
 
-    public Boolean isUseDefaultCredentialsProvider() {
+    @Override
+    public boolean isUseDefaultCredentialsProvider() {
         return useDefaultCredentialsProvider;
     }
 
+    @Override
     public boolean isUseProfileCredentialsProvider() {
         return useProfileCredentialsProvider;
     }
diff --git 
a/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2Endpoint.java
 
b/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2Endpoint.java
index 62595174e32c..896549489e7d 100644
--- 
a/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2Endpoint.java
+++ 
b/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/AWS2EC2Endpoint.java
@@ -62,7 +62,7 @@ public class AWS2EC2Endpoint extends DefaultEndpoint 
implements EndpointServiceL
         super.doStart();
 
         ec2Client = configuration.getAmazonEc2Client() != null
-                ? configuration.getAmazonEc2Client() : 
AWS2EC2ClientFactory.getEc2Client(configuration).getEc2Client();
+                ? configuration.getAmazonEc2Client() : 
AWS2EC2ClientFactory.getEc2Client(configuration);
     }
 
     @Override
diff --git 
a/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/client/AWS2EC2ClientFactory.java
 
b/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/client/AWS2EC2ClientFactory.java
index 04c710ff3cda..c95e3430feba 100644
--- 
a/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/client/AWS2EC2ClientFactory.java
+++ 
b/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/client/AWS2EC2ClientFactory.java
@@ -16,14 +16,12 @@
  */
 package org.apache.camel.component.aws2.ec2.client;
 
+import org.apache.camel.component.aws.common.AwsClientBuilderUtil;
 import org.apache.camel.component.aws2.ec2.AWS2EC2Configuration;
-import 
org.apache.camel.component.aws2.ec2.client.impl.AWS2EC2ClientIAMOptimizedImpl;
-import 
org.apache.camel.component.aws2.ec2.client.impl.AWS2EC2ClientIAMProfileOptimizedImpl;
-import 
org.apache.camel.component.aws2.ec2.client.impl.AWS2EC2ClientSessionTokenImpl;
-import 
org.apache.camel.component.aws2.ec2.client.impl.AWS2EC2ClientStandardImpl;
+import software.amazon.awssdk.services.ec2.Ec2Client;
 
 /**
- * Factory class to return the correct type of AWS Athena client.
+ * Factory class to create AWS EC2 clients using common configuration.
  */
 public final class AWS2EC2ClientFactory {
 
@@ -31,20 +29,14 @@ public final class AWS2EC2ClientFactory {
     }
 
     /**
-     * Return the correct AWS EC2 client (based on remote vs local).
+     * Create an EC2 client based on configuration.
      *
-     * @param  configuration configuration
-     * @return               Ec2Client
+     * @param  configuration The EC2 configuration
+     * @return               Configured Ec2Client
      */
-    public static AWS2EC2InternalClient getEc2Client(AWS2EC2Configuration 
configuration) {
-        if 
(Boolean.TRUE.equals(configuration.isUseDefaultCredentialsProvider())) {
-            return new AWS2EC2ClientIAMOptimizedImpl(configuration);
-        } else if 
(Boolean.TRUE.equals(configuration.isUseProfileCredentialsProvider())) {
-            return new AWS2EC2ClientIAMProfileOptimizedImpl(configuration);
-        } else if 
(Boolean.TRUE.equals(configuration.isUseSessionCredentials())) {
-            return new AWS2EC2ClientSessionTokenImpl(configuration);
-        } else {
-            return new AWS2EC2ClientStandardImpl(configuration);
-        }
+    public static Ec2Client getEc2Client(AWS2EC2Configuration configuration) {
+        return AwsClientBuilderUtil.buildClient(
+                configuration,
+                Ec2Client::builder);
     }
 }
diff --git 
a/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/client/AWS2EC2InternalClient.java
 
b/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/client/AWS2EC2InternalClient.java
deleted file mode 100644
index ee83d110d63a..000000000000
--- 
a/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/client/AWS2EC2InternalClient.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.component.aws2.ec2.client;
-
-import software.amazon.awssdk.services.ec2.Ec2Client;
-
-/**
- * Manage the required actions of an EC2 client for either local or remote.
- */
-public interface AWS2EC2InternalClient {
-
-    /**
-     * Returns an EC2 client after a factory method determines which one to 
return.
-     *
-     * @return Ec2Client Ec2Client
-     */
-    Ec2Client getEc2Client();
-}
diff --git 
a/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/client/impl/AWS2EC2ClientIAMOptimizedImpl.java
 
b/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/client/impl/AWS2EC2ClientIAMOptimizedImpl.java
deleted file mode 100644
index 389acc93bb18..000000000000
--- 
a/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/client/impl/AWS2EC2ClientIAMOptimizedImpl.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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.component.aws2.ec2.client.impl;
-
-import java.net.URI;
-
-import org.apache.camel.component.aws2.ec2.AWS2EC2Configuration;
-import org.apache.camel.component.aws2.ec2.client.AWS2EC2InternalClient;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import software.amazon.awssdk.http.SdkHttpClient;
-import software.amazon.awssdk.http.SdkHttpConfigurationOption;
-import software.amazon.awssdk.http.apache.ApacheHttpClient;
-import software.amazon.awssdk.http.apache.ProxyConfiguration;
-import software.amazon.awssdk.regions.Region;
-import software.amazon.awssdk.services.ec2.Ec2Client;
-import software.amazon.awssdk.services.ec2.Ec2ClientBuilder;
-import software.amazon.awssdk.utils.AttributeMap;
-
-/**
- * Manage an AWS EC2 client for all users to use (enabling temporary creds). 
This implementation is for remote instances
- * to manage the credentials on their own (eliminating credential rotations)
- */
-public class AWS2EC2ClientIAMOptimizedImpl implements AWS2EC2InternalClient {
-    private static final Logger LOG = 
LoggerFactory.getLogger(AWS2EC2ClientIAMOptimizedImpl.class);
-    private AWS2EC2Configuration configuration;
-
-    /**
-     * Constructor that uses the config file.
-     */
-    public AWS2EC2ClientIAMOptimizedImpl(AWS2EC2Configuration configuration) {
-        LOG.trace("Creating an AWS EC2 client for an ec2 instance with IAM 
temporary credentials (normal for ec2s).");
-        this.configuration = configuration;
-    }
-
-    /**
-     * Getting the EC2 aws client that is used.
-     *
-     * @return Ec2Client Client.
-     */
-    @Override
-    public Ec2Client getEc2Client() {
-        Ec2Client client = null;
-        Ec2ClientBuilder clientBuilder = Ec2Client.builder();
-        ProxyConfiguration.Builder proxyConfig = null;
-        ApacheHttpClient.Builder httpClientBuilder = null;
-        if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && 
ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
-            proxyConfig = ProxyConfiguration.builder();
-            URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + 
"://" + configuration.getProxyHost() + ":"
-                                           + configuration.getProxyPort());
-            proxyConfig.endpoint(proxyEndpoint);
-            httpClientBuilder = 
ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build());
-            clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder);
-        }
-        if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
-            clientBuilder = 
clientBuilder.region(Region.of(configuration.getRegion()));
-        }
-        if (configuration.isOverrideEndpoint()) {
-            
clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride()));
-        }
-        if (configuration.isTrustAllCertificates()) {
-            if (httpClientBuilder == null) {
-                httpClientBuilder = ApacheHttpClient.builder();
-            }
-            SdkHttpClient ahc = 
httpClientBuilder.buildWithDefaults(AttributeMap
-                    .builder()
-                    .put(
-                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
-                            Boolean.TRUE)
-                    .build());
-            // set created http client to use instead of builder
-            clientBuilder.httpClient(ahc);
-            clientBuilder.httpClientBuilder(null);
-        }
-        client = clientBuilder.build();
-        return client;
-    }
-}
diff --git 
a/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/client/impl/AWS2EC2ClientIAMProfileOptimizedImpl.java
 
b/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/client/impl/AWS2EC2ClientIAMProfileOptimizedImpl.java
deleted file mode 100644
index 0a8986a6a2e3..000000000000
--- 
a/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/client/impl/AWS2EC2ClientIAMProfileOptimizedImpl.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * 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.component.aws2.ec2.client.impl;
-
-import java.net.URI;
-
-import org.apache.camel.component.aws2.ec2.AWS2EC2Configuration;
-import org.apache.camel.component.aws2.ec2.client.AWS2EC2InternalClient;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
-import software.amazon.awssdk.http.SdkHttpClient;
-import software.amazon.awssdk.http.SdkHttpConfigurationOption;
-import software.amazon.awssdk.http.apache.ApacheHttpClient;
-import software.amazon.awssdk.http.apache.ProxyConfiguration;
-import software.amazon.awssdk.regions.Region;
-import software.amazon.awssdk.services.ec2.Ec2Client;
-import software.amazon.awssdk.services.ec2.Ec2ClientBuilder;
-import software.amazon.awssdk.utils.AttributeMap;
-
-/**
- * Manage an AWS EC2 client for all users to use (enabling temporary creds). 
This implementation is for remote instances
- * to manage the credentials on their own (eliminating credential rotations)
- */
-public class AWS2EC2ClientIAMProfileOptimizedImpl implements 
AWS2EC2InternalClient {
-    private static final Logger LOG = 
LoggerFactory.getLogger(AWS2EC2ClientIAMProfileOptimizedImpl.class);
-    private AWS2EC2Configuration configuration;
-
-    /**
-     * Constructor that uses the config file.
-     */
-    public AWS2EC2ClientIAMProfileOptimizedImpl(AWS2EC2Configuration 
configuration) {
-        LOG.trace("Creating an AWS EC2 client for an ec2 instance with IAM 
temporary credentials (normal for ec2s).");
-        this.configuration = configuration;
-    }
-
-    /**
-     * Getting the EC2 aws client that is used.
-     *
-     * @return Ec2Client Client.
-     */
-    @Override
-    public Ec2Client getEc2Client() {
-        Ec2Client client = null;
-        Ec2ClientBuilder clientBuilder = Ec2Client.builder();
-        ProxyConfiguration.Builder proxyConfig = null;
-        ApacheHttpClient.Builder httpClientBuilder = null;
-        if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && 
ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
-            proxyConfig = ProxyConfiguration.builder();
-            URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + 
"://" + configuration.getProxyHost() + ":"
-                                           + configuration.getProxyPort());
-            proxyConfig.endpoint(proxyEndpoint);
-            httpClientBuilder = 
ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build());
-            clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder);
-        }
-        if (configuration.getProfileCredentialsName() != null) {
-            clientBuilder = clientBuilder
-                    
.credentialsProvider(ProfileCredentialsProvider.create(configuration.getProfileCredentialsName()));
-        }
-        if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
-            clientBuilder = 
clientBuilder.region(Region.of(configuration.getRegion()));
-        }
-        if (configuration.isOverrideEndpoint()) {
-            
clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride()));
-        }
-        if (configuration.isTrustAllCertificates()) {
-            if (httpClientBuilder == null) {
-                httpClientBuilder = ApacheHttpClient.builder();
-            }
-            SdkHttpClient ahc = 
httpClientBuilder.buildWithDefaults(AttributeMap
-                    .builder()
-                    .put(
-                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
-                            Boolean.TRUE)
-                    .build());
-            // set created http client to use instead of builder
-            clientBuilder.httpClient(ahc);
-            clientBuilder.httpClientBuilder(null);
-        }
-        client = clientBuilder.build();
-        return client;
-    }
-}
diff --git 
a/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/client/impl/AWS2EC2ClientSessionTokenImpl.java
 
b/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/client/impl/AWS2EC2ClientSessionTokenImpl.java
deleted file mode 100644
index 8a0a96cd20d5..000000000000
--- 
a/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/client/impl/AWS2EC2ClientSessionTokenImpl.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * 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.component.aws2.ec2.client.impl;
-
-import java.net.URI;
-
-import org.apache.camel.component.aws2.ec2.AWS2EC2Configuration;
-import org.apache.camel.component.aws2.ec2.client.AWS2EC2InternalClient;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import software.amazon.awssdk.auth.credentials.AwsSessionCredentials;
-import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
-import software.amazon.awssdk.http.SdkHttpClient;
-import software.amazon.awssdk.http.SdkHttpConfigurationOption;
-import software.amazon.awssdk.http.apache.ApacheHttpClient;
-import software.amazon.awssdk.http.apache.ProxyConfiguration;
-import software.amazon.awssdk.regions.Region;
-import software.amazon.awssdk.services.ec2.Ec2Client;
-import software.amazon.awssdk.services.ec2.Ec2ClientBuilder;
-import software.amazon.awssdk.utils.AttributeMap;
-
-/**
- * Manage an AWS EC2 client for all users to use. This implementation is for 
local instances to use a static and solid
- * credential set.
- */
-public class AWS2EC2ClientSessionTokenImpl implements AWS2EC2InternalClient {
-    private static final Logger LOG = 
LoggerFactory.getLogger(AWS2EC2ClientSessionTokenImpl.class);
-    private AWS2EC2Configuration configuration;
-
-    /**
-     * Constructor that uses the config file.
-     */
-    public AWS2EC2ClientSessionTokenImpl(AWS2EC2Configuration configuration) {
-        LOG.trace("Creating an AWS EC2 manager using static credentials.");
-        this.configuration = configuration;
-    }
-
-    /**
-     * Getting the EC2 AWS client that is used.
-     *
-     * @return Amazon EC2 Client.
-     */
-    @Override
-    public Ec2Client getEc2Client() {
-        Ec2Client client = null;
-        Ec2ClientBuilder clientBuilder = Ec2Client.builder();
-        ProxyConfiguration.Builder proxyConfig = null;
-        ApacheHttpClient.Builder httpClientBuilder = null;
-        boolean isClientConfigFound = false;
-        if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && 
ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
-            proxyConfig = ProxyConfiguration.builder();
-            URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + 
"://" + configuration.getProxyHost() + ":"
-                                           + configuration.getProxyPort());
-            proxyConfig.endpoint(proxyEndpoint);
-            httpClientBuilder = 
ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build());
-            isClientConfigFound = true;
-        }
-        if (configuration.getAccessKey() != null && 
configuration.getSecretKey() != null
-                && configuration.getSessionToken() != null) {
-            AwsSessionCredentials cred = 
AwsSessionCredentials.create(configuration.getAccessKey(),
-                    configuration.getSecretKey(), 
configuration.getSessionToken());
-            if (isClientConfigFound) {
-                clientBuilder = 
clientBuilder.httpClientBuilder(httpClientBuilder)
-                        
.credentialsProvider(StaticCredentialsProvider.create(cred));
-            } else {
-                clientBuilder = 
clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred));
-            }
-        } else {
-            if (!isClientConfigFound) {
-                clientBuilder = 
clientBuilder.httpClientBuilder(httpClientBuilder);
-            }
-        }
-        if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
-            clientBuilder = 
clientBuilder.region(Region.of(configuration.getRegion()));
-        }
-        if (configuration.isOverrideEndpoint()) {
-            
clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride()));
-        }
-        if (configuration.isTrustAllCertificates()) {
-            if (httpClientBuilder == null) {
-                httpClientBuilder = ApacheHttpClient.builder();
-            }
-            SdkHttpClient ahc = 
httpClientBuilder.buildWithDefaults(AttributeMap
-                    .builder()
-                    .put(
-                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
-                            Boolean.TRUE)
-                    .build());
-            // set created http client to use instead of builder
-            clientBuilder.httpClient(ahc);
-            clientBuilder.httpClientBuilder(null);
-        }
-        client = clientBuilder.build();
-        return client;
-    }
-}
diff --git 
a/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/client/impl/AWS2EC2ClientStandardImpl.java
 
b/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/client/impl/AWS2EC2ClientStandardImpl.java
deleted file mode 100644
index 2848af0136fb..000000000000
--- 
a/components/camel-aws/camel-aws2-ec2/src/main/java/org/apache/camel/component/aws2/ec2/client/impl/AWS2EC2ClientStandardImpl.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * 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.component.aws2.ec2.client.impl;
-
-import java.net.URI;
-
-import org.apache.camel.component.aws2.ec2.AWS2EC2Configuration;
-import org.apache.camel.component.aws2.ec2.client.AWS2EC2InternalClient;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
-import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
-import software.amazon.awssdk.http.SdkHttpClient;
-import software.amazon.awssdk.http.SdkHttpConfigurationOption;
-import software.amazon.awssdk.http.apache.ApacheHttpClient;
-import software.amazon.awssdk.http.apache.ProxyConfiguration;
-import software.amazon.awssdk.regions.Region;
-import software.amazon.awssdk.services.ec2.Ec2Client;
-import software.amazon.awssdk.services.ec2.Ec2ClientBuilder;
-import software.amazon.awssdk.utils.AttributeMap;
-
-/**
- * Manage an AWS EC2 client for all users to use. This implementation is for 
local instances to use a static and solid
- * credential set.
- */
-public class AWS2EC2ClientStandardImpl implements AWS2EC2InternalClient {
-    private static final Logger LOG = 
LoggerFactory.getLogger(AWS2EC2ClientStandardImpl.class);
-    private AWS2EC2Configuration configuration;
-
-    /**
-     * Constructor that uses the config file.
-     */
-    public AWS2EC2ClientStandardImpl(AWS2EC2Configuration configuration) {
-        LOG.trace("Creating an AWS EC2 manager using static credentials.");
-        this.configuration = configuration;
-    }
-
-    /**
-     * Getting the EC2 AWS client that is used.
-     *
-     * @return Amazon EC2 Client.
-     */
-    @Override
-    public Ec2Client getEc2Client() {
-        Ec2Client client = null;
-        Ec2ClientBuilder clientBuilder = Ec2Client.builder();
-        ProxyConfiguration.Builder proxyConfig = null;
-        ApacheHttpClient.Builder httpClientBuilder = null;
-        boolean isClientConfigFound = false;
-        if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && 
ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
-            proxyConfig = ProxyConfiguration.builder();
-            URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + 
"://" + configuration.getProxyHost() + ":"
-                                           + configuration.getProxyPort());
-            proxyConfig.endpoint(proxyEndpoint);
-            httpClientBuilder = 
ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build());
-            isClientConfigFound = true;
-        }
-        if (configuration.getAccessKey() != null && 
configuration.getSecretKey() != null) {
-            AwsBasicCredentials cred = 
AwsBasicCredentials.create(configuration.getAccessKey(), 
configuration.getSecretKey());
-            if (isClientConfigFound) {
-                clientBuilder = 
clientBuilder.httpClientBuilder(httpClientBuilder)
-                        
.credentialsProvider(StaticCredentialsProvider.create(cred));
-            } else {
-                clientBuilder = 
clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred));
-            }
-        } else {
-            if (!isClientConfigFound) {
-                clientBuilder = 
clientBuilder.httpClientBuilder(httpClientBuilder);
-            }
-        }
-        if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
-            clientBuilder = 
clientBuilder.region(Region.of(configuration.getRegion()));
-        }
-        if (configuration.isOverrideEndpoint()) {
-            
clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride()));
-        }
-        if (configuration.isTrustAllCertificates()) {
-            if (httpClientBuilder == null) {
-                httpClientBuilder = ApacheHttpClient.builder();
-            }
-            SdkHttpClient ahc = 
httpClientBuilder.buildWithDefaults(AttributeMap
-                    .builder()
-                    .put(
-                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
-                            Boolean.TRUE)
-                    .build());
-            // set created http client to use instead of builder
-            clientBuilder.httpClient(ahc);
-            clientBuilder.httpClientBuilder(null);
-        }
-        client = clientBuilder.build();
-        return client;
-    }
-}
diff --git 
a/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/AWS2EC2ClientFactoryTest.java
 
b/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/AWS2EC2ClientFactoryTest.java
index 41691844e79f..635d1d4caa98 100644
--- 
a/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/AWS2EC2ClientFactoryTest.java
+++ 
b/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/AWS2EC2ClientFactoryTest.java
@@ -17,44 +17,43 @@
 package org.apache.camel.component.aws2.ec2;
 
 import org.apache.camel.component.aws2.ec2.client.AWS2EC2ClientFactory;
-import org.apache.camel.component.aws2.ec2.client.AWS2EC2InternalClient;
-import 
org.apache.camel.component.aws2.ec2.client.impl.AWS2EC2ClientIAMOptimizedImpl;
-import 
org.apache.camel.component.aws2.ec2.client.impl.AWS2EC2ClientSessionTokenImpl;
-import 
org.apache.camel.component.aws2.ec2.client.impl.AWS2EC2ClientStandardImpl;
 import org.junit.jupiter.api.Test;
+import software.amazon.awssdk.services.ec2.Ec2Client;
 
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 public class AWS2EC2ClientFactoryTest {
 
     @Test
-    public void getStandardEC2ClientDefault() {
-        AWS2EC2Configuration ec2Configuration = new AWS2EC2Configuration();
-        AWS2EC2InternalClient ec2Client = 
AWS2EC2ClientFactory.getEc2Client(ec2Configuration);
-        assertTrue(ec2Client instanceof AWS2EC2ClientStandardImpl);
+    public void getEc2ClientWithDefaultCredentials() {
+        AWS2EC2Configuration configuration = new AWS2EC2Configuration();
+        configuration.setUseDefaultCredentialsProvider(true);
+        configuration.setRegion("eu-west-1");
+        Ec2Client ec2Client = AWS2EC2ClientFactory.getEc2Client(configuration);
+        assertNotNull(ec2Client);
+        ec2Client.close();
     }
 
     @Test
-    public void getStandardEC2Client() {
-        AWS2EC2Configuration ec2Configuration = new AWS2EC2Configuration();
-        ec2Configuration.setUseDefaultCredentialsProvider(false);
-        AWS2EC2InternalClient ec2Client = 
AWS2EC2ClientFactory.getEc2Client(ec2Configuration);
-        assertTrue(ec2Client instanceof AWS2EC2ClientStandardImpl);
+    public void getEc2ClientWithStaticCredentials() {
+        AWS2EC2Configuration configuration = new AWS2EC2Configuration();
+        configuration.setAccessKey("testAccessKey");
+        configuration.setSecretKey("testSecretKey");
+        configuration.setRegion("eu-west-1");
+        Ec2Client ec2Client = AWS2EC2ClientFactory.getEc2Client(configuration);
+        assertNotNull(ec2Client);
+        ec2Client.close();
     }
 
     @Test
-    public void getIAMOptimizedEC2Client() {
-        AWS2EC2Configuration ec2Configuration = new AWS2EC2Configuration();
-        ec2Configuration.setUseDefaultCredentialsProvider(true);
-        AWS2EC2InternalClient ec2Client = 
AWS2EC2ClientFactory.getEc2Client(ec2Configuration);
-        assertTrue(ec2Client instanceof AWS2EC2ClientIAMOptimizedImpl);
-    }
-
-    @Test
-    public void getSessionTokenEC2Client() {
-        AWS2EC2Configuration ec2Configuration = new AWS2EC2Configuration();
-        ec2Configuration.setUseSessionCredentials(true);
-        AWS2EC2InternalClient ec2Client = 
AWS2EC2ClientFactory.getEc2Client(ec2Configuration);
-        assertTrue(ec2Client instanceof AWS2EC2ClientSessionTokenImpl);
+    public void getEc2ClientWithEndpointOverride() {
+        AWS2EC2Configuration configuration = new AWS2EC2Configuration();
+        configuration.setUseDefaultCredentialsProvider(true);
+        configuration.setRegion("eu-west-1");
+        configuration.setOverrideEndpoint(true);
+        configuration.setUriEndpointOverride("http://localhost:4566";);
+        Ec2Client ec2Client = AWS2EC2ClientFactory.getEc2Client(configuration);
+        assertNotNull(ec2Client);
+        ec2Client.close();
     }
 }
diff --git a/components/camel-aws/camel-aws2-ecs/pom.xml 
b/components/camel-aws/camel-aws2-ecs/pom.xml
index 49b2ca4eec3d..cb97efb7095f 100644
--- a/components/camel-aws/camel-aws2-ecs/pom.xml
+++ b/components/camel-aws/camel-aws2-ecs/pom.xml
@@ -40,6 +40,10 @@
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-support</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-aws-common</artifactId>
+        </dependency>
         <dependency>
             <groupId>software.amazon.awssdk</groupId>
             <artifactId>ecs</artifactId>
diff --git 
a/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Configuration.java
 
b/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Configuration.java
index c5a96af4b963..8a4adbcf28d7 100644
--- 
a/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Configuration.java
+++ 
b/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Configuration.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.aws2.ecs;
 
 import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.component.aws.common.AwsCommonConfiguration;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriParams;
@@ -25,7 +26,7 @@ import software.amazon.awssdk.core.Protocol;
 import software.amazon.awssdk.services.ecs.EcsClient;
 
 @UriParams
-public class ECS2Configuration implements Cloneable {
+public class ECS2Configuration implements Cloneable, AwsCommonConfiguration {
 
     @UriPath(description = "Logical name")
     @Metadata(required = true)
@@ -217,14 +218,16 @@ public class ECS2Configuration implements Cloneable {
      * Set whether the ECS client should expect to load credentials through a 
default credentials provider or to expect
      * static credentials to be passed in.
      */
-    public void setUseDefaultCredentialsProvider(Boolean 
useDefaultCredentialsProvider) {
+    public void setUseDefaultCredentialsProvider(boolean 
useDefaultCredentialsProvider) {
         this.useDefaultCredentialsProvider = useDefaultCredentialsProvider;
     }
 
-    public Boolean isUseDefaultCredentialsProvider() {
+    @Override
+    public boolean isUseDefaultCredentialsProvider() {
         return useDefaultCredentialsProvider;
     }
 
+    @Override
     public boolean isUseProfileCredentialsProvider() {
         return useProfileCredentialsProvider;
     }
diff --git 
a/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Endpoint.java
 
b/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Endpoint.java
index 4d685b6b4a6f..34a99d95de93 100644
--- 
a/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Endpoint.java
+++ 
b/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Endpoint.java
@@ -67,7 +67,7 @@ public class ECS2Endpoint extends ScheduledPollEndpoint 
implements EndpointServi
         super.doStart();
 
         ecsClient = configuration.getEcsClient() != null
-                ? configuration.getEcsClient() : 
ECS2ClientFactory.getEcsClient(configuration).getEcsClient();
+                ? configuration.getEcsClient() : 
ECS2ClientFactory.getEcsClient(configuration);
     }
 
     @Override
diff --git 
a/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/client/ECS2ClientFactory.java
 
b/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/client/ECS2ClientFactory.java
index 8e6848498cd8..494a5ebce763 100644
--- 
a/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/client/ECS2ClientFactory.java
+++ 
b/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/client/ECS2ClientFactory.java
@@ -16,14 +16,12 @@
  */
 package org.apache.camel.component.aws2.ecs.client;
 
+import org.apache.camel.component.aws.common.AwsClientBuilderUtil;
 import org.apache.camel.component.aws2.ecs.ECS2Configuration;
-import 
org.apache.camel.component.aws2.ecs.client.impl.ECS2ClientIAMOptimizedImpl;
-import 
org.apache.camel.component.aws2.ecs.client.impl.ECS2ClientIAMProfileOptimizedImpl;
-import 
org.apache.camel.component.aws2.ecs.client.impl.ECS2ClientSessionTokenImpl;
-import org.apache.camel.component.aws2.ecs.client.impl.ECS2ClientStandardImpl;
+import software.amazon.awssdk.services.ecs.EcsClient;
 
 /**
- * Factory class to return the correct type of AWS Athena client.
+ * Factory class to create AWS ECS clients using common configuration.
  */
 public final class ECS2ClientFactory {
 
@@ -31,20 +29,14 @@ public final class ECS2ClientFactory {
     }
 
     /**
-     * Return the correct AWS ECS client (based on remote vs local).
+     * Create an ECS client based on configuration.
      *
-     * @param  configuration configuration
-     * @return               EcsClient
+     * @param  configuration The ECS configuration
+     * @return               Configured EcsClient
      */
-    public static ECS2InternalClient getEcsClient(ECS2Configuration 
configuration) {
-        if 
(Boolean.TRUE.equals(configuration.isUseDefaultCredentialsProvider())) {
-            return new ECS2ClientIAMOptimizedImpl(configuration);
-        } else if 
(Boolean.TRUE.equals(configuration.isUseProfileCredentialsProvider())) {
-            return new ECS2ClientIAMProfileOptimizedImpl(configuration);
-        } else if 
(Boolean.TRUE.equals(configuration.isUseSessionCredentials())) {
-            return new ECS2ClientSessionTokenImpl(configuration);
-        } else {
-            return new ECS2ClientStandardImpl(configuration);
-        }
+    public static EcsClient getEcsClient(ECS2Configuration configuration) {
+        return AwsClientBuilderUtil.buildClient(
+                configuration,
+                EcsClient::builder);
     }
 }
diff --git 
a/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/client/ECS2InternalClient.java
 
b/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/client/ECS2InternalClient.java
deleted file mode 100644
index 52ba959d028b..000000000000
--- 
a/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/client/ECS2InternalClient.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.component.aws2.ecs.client;
-
-import software.amazon.awssdk.services.ecs.EcsClient;
-
-/**
- * Manage the required actions of an ECS client for either local or remote.
- */
-public interface ECS2InternalClient {
-
-    /**
-     * Returns an ECS client after a factory method determines which one to 
return.
-     *
-     * @return EcSClient EcSClient
-     */
-    EcsClient getEcsClient();
-}
diff --git 
a/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/client/impl/ECS2ClientIAMOptimizedImpl.java
 
b/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/client/impl/ECS2ClientIAMOptimizedImpl.java
deleted file mode 100644
index 315f2f8d8634..000000000000
--- 
a/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/client/impl/ECS2ClientIAMOptimizedImpl.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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.component.aws2.ecs.client.impl;
-
-import java.net.URI;
-
-import org.apache.camel.component.aws2.ecs.ECS2Configuration;
-import org.apache.camel.component.aws2.ecs.client.ECS2InternalClient;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import software.amazon.awssdk.http.SdkHttpClient;
-import software.amazon.awssdk.http.SdkHttpConfigurationOption;
-import software.amazon.awssdk.http.apache.ApacheHttpClient;
-import software.amazon.awssdk.http.apache.ProxyConfiguration;
-import software.amazon.awssdk.regions.Region;
-import software.amazon.awssdk.services.ecs.EcsClient;
-import software.amazon.awssdk.services.ecs.EcsClientBuilder;
-import software.amazon.awssdk.utils.AttributeMap;
-
-/**
- * Manage an AWS ECS client for all users to use (enabling temporary creds). 
This implementation is for remote instances
- * to manage the credentials on their own (eliminating credential rotations)
- */
-public class ECS2ClientIAMOptimizedImpl implements ECS2InternalClient {
-    private static final Logger LOG = 
LoggerFactory.getLogger(ECS2ClientIAMOptimizedImpl.class);
-    private ECS2Configuration configuration;
-
-    /**
-     * Constructor that uses the config file.
-     */
-    public ECS2ClientIAMOptimizedImpl(ECS2Configuration configuration) {
-        LOG.trace("Creating an AWS ECS client for an ec2 instance with IAM 
temporary credentials (normal for ec2s).");
-        this.configuration = configuration;
-    }
-
-    /**
-     * Getting the ECS aws client that is used.
-     *
-     * @return EcsClient Client.
-     */
-    @Override
-    public EcsClient getEcsClient() {
-        EcsClient client = null;
-        EcsClientBuilder clientBuilder = EcsClient.builder();
-        ProxyConfiguration.Builder proxyConfig = null;
-        ApacheHttpClient.Builder httpClientBuilder = null;
-        if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && 
ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
-            proxyConfig = ProxyConfiguration.builder();
-            URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + 
"://" + configuration.getProxyHost() + ":"
-                                           + configuration.getProxyPort());
-            proxyConfig.endpoint(proxyEndpoint);
-            httpClientBuilder = 
ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build());
-            clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder);
-        }
-        if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
-            clientBuilder = 
clientBuilder.region(Region.of(configuration.getRegion()));
-        }
-        if (configuration.isOverrideEndpoint()) {
-            
clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride()));
-        }
-        if (configuration.isTrustAllCertificates()) {
-            if (httpClientBuilder == null) {
-                httpClientBuilder = ApacheHttpClient.builder();
-            }
-            SdkHttpClient ahc = 
httpClientBuilder.buildWithDefaults(AttributeMap
-                    .builder()
-                    .put(
-                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
-                            Boolean.TRUE)
-                    .build());
-            // set created http client to use instead of builder
-            clientBuilder.httpClient(ahc);
-            clientBuilder.httpClientBuilder(null);
-        }
-        client = clientBuilder.build();
-        return client;
-    }
-}
diff --git 
a/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/client/impl/ECS2ClientIAMProfileOptimizedImpl.java
 
b/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/client/impl/ECS2ClientIAMProfileOptimizedImpl.java
deleted file mode 100644
index ea44b4409cfb..000000000000
--- 
a/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/client/impl/ECS2ClientIAMProfileOptimizedImpl.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * 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.component.aws2.ecs.client.impl;
-
-import java.net.URI;
-
-import org.apache.camel.component.aws2.ecs.ECS2Configuration;
-import org.apache.camel.component.aws2.ecs.client.ECS2InternalClient;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
-import software.amazon.awssdk.http.SdkHttpClient;
-import software.amazon.awssdk.http.SdkHttpConfigurationOption;
-import software.amazon.awssdk.http.apache.ApacheHttpClient;
-import software.amazon.awssdk.http.apache.ProxyConfiguration;
-import software.amazon.awssdk.regions.Region;
-import software.amazon.awssdk.services.ecs.EcsClient;
-import software.amazon.awssdk.services.ecs.EcsClientBuilder;
-import software.amazon.awssdk.utils.AttributeMap;
-
-/**
- * Manage an AWS ECS client for all users to use (enabling temporary creds). 
This implementation is for remote instances
- * to manage the credentials on their own (eliminating credential rotations)
- */
-public class ECS2ClientIAMProfileOptimizedImpl implements ECS2InternalClient {
-    private static final Logger LOG = 
LoggerFactory.getLogger(ECS2ClientIAMProfileOptimizedImpl.class);
-    private ECS2Configuration configuration;
-
-    /**
-     * Constructor that uses the config file.
-     */
-    public ECS2ClientIAMProfileOptimizedImpl(ECS2Configuration configuration) {
-        LOG.trace("Creating an AWS ECS client for an ec2 instance with IAM 
temporary credentials (normal for ec2s).");
-        this.configuration = configuration;
-    }
-
-    /**
-     * Getting the ECS aws client that is used.
-     *
-     * @return EcsClient Client.
-     */
-    @Override
-    public EcsClient getEcsClient() {
-        EcsClient client = null;
-        EcsClientBuilder clientBuilder = EcsClient.builder();
-        ProxyConfiguration.Builder proxyConfig = null;
-        ApacheHttpClient.Builder httpClientBuilder = null;
-        if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && 
ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
-            proxyConfig = ProxyConfiguration.builder();
-            URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + 
"://" + configuration.getProxyHost() + ":"
-                                           + configuration.getProxyPort());
-            proxyConfig.endpoint(proxyEndpoint);
-            httpClientBuilder = 
ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build());
-            clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder);
-        }
-        if (configuration.getProfileCredentialsName() != null) {
-            clientBuilder = clientBuilder
-                    
.credentialsProvider(ProfileCredentialsProvider.create(configuration.getProfileCredentialsName()));
-        }
-        if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
-            clientBuilder = 
clientBuilder.region(Region.of(configuration.getRegion()));
-        }
-        if (configuration.isOverrideEndpoint()) {
-            
clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride()));
-        }
-        if (configuration.isTrustAllCertificates()) {
-            if (httpClientBuilder == null) {
-                httpClientBuilder = ApacheHttpClient.builder();
-            }
-            SdkHttpClient ahc = 
httpClientBuilder.buildWithDefaults(AttributeMap
-                    .builder()
-                    .put(
-                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
-                            Boolean.TRUE)
-                    .build());
-            // set created http client to use instead of builder
-            clientBuilder.httpClient(ahc);
-            clientBuilder.httpClientBuilder(null);
-        }
-        client = clientBuilder.build();
-        return client;
-    }
-}
diff --git 
a/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/client/impl/ECS2ClientSessionTokenImpl.java
 
b/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/client/impl/ECS2ClientSessionTokenImpl.java
deleted file mode 100644
index 8c59f90b8148..000000000000
--- 
a/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/client/impl/ECS2ClientSessionTokenImpl.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * 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.component.aws2.ecs.client.impl;
-
-import java.net.URI;
-
-import org.apache.camel.component.aws2.ecs.ECS2Configuration;
-import org.apache.camel.component.aws2.ecs.client.ECS2InternalClient;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import software.amazon.awssdk.auth.credentials.AwsSessionCredentials;
-import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
-import software.amazon.awssdk.http.SdkHttpClient;
-import software.amazon.awssdk.http.SdkHttpConfigurationOption;
-import software.amazon.awssdk.http.apache.ApacheHttpClient;
-import software.amazon.awssdk.http.apache.ProxyConfiguration;
-import software.amazon.awssdk.regions.Region;
-import software.amazon.awssdk.services.ecs.EcsClient;
-import software.amazon.awssdk.services.ecs.EcsClientBuilder;
-import software.amazon.awssdk.utils.AttributeMap;
-
-/**
- * Manage an AWS ECS client for all users to use. This implementation is for 
local instances to use a static and solid
- * credential set.
- */
-public class ECS2ClientSessionTokenImpl implements ECS2InternalClient {
-    private static final Logger LOG = 
LoggerFactory.getLogger(ECS2ClientStandardImpl.class);
-    private ECS2Configuration configuration;
-
-    /**
-     * Constructor that uses the config file.
-     */
-    public ECS2ClientSessionTokenImpl(ECS2Configuration configuration) {
-        LOG.trace("Creating an AWS ECS manager using static credentials.");
-        this.configuration = configuration;
-    }
-
-    /**
-     * Getting the ECS AWS client that is used.
-     *
-     * @return Amazon ECS Client.
-     */
-    @Override
-    public EcsClient getEcsClient() {
-        EcsClient client = null;
-        EcsClientBuilder clientBuilder = EcsClient.builder();
-        ProxyConfiguration.Builder proxyConfig = null;
-        ApacheHttpClient.Builder httpClientBuilder = null;
-        boolean isClientConfigFound = false;
-        if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && 
ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
-            proxyConfig = ProxyConfiguration.builder();
-            URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + 
"://" + configuration.getProxyHost() + ":"
-                                           + configuration.getProxyPort());
-            proxyConfig.endpoint(proxyEndpoint);
-            httpClientBuilder = 
ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build());
-            isClientConfigFound = true;
-        }
-        if (configuration.getAccessKey() != null && 
configuration.getSecretKey() != null
-                && configuration.getSessionToken() != null) {
-            AwsSessionCredentials cred = 
AwsSessionCredentials.create(configuration.getAccessKey(),
-                    configuration.getSecretKey(), 
configuration.getSessionToken());
-            if (isClientConfigFound) {
-                clientBuilder = 
clientBuilder.httpClientBuilder(httpClientBuilder)
-                        
.credentialsProvider(StaticCredentialsProvider.create(cred));
-            } else {
-                clientBuilder = 
clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred));
-            }
-        } else {
-            if (!isClientConfigFound) {
-                clientBuilder = 
clientBuilder.httpClientBuilder(httpClientBuilder);
-            }
-        }
-        if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
-            clientBuilder = 
clientBuilder.region(Region.of(configuration.getRegion()));
-        }
-        if (configuration.isOverrideEndpoint()) {
-            
clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride()));
-        }
-        if (configuration.isTrustAllCertificates()) {
-            if (httpClientBuilder == null) {
-                httpClientBuilder = ApacheHttpClient.builder();
-            }
-            SdkHttpClient ahc = 
httpClientBuilder.buildWithDefaults(AttributeMap
-                    .builder()
-                    .put(
-                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
-                            Boolean.TRUE)
-                    .build());
-            // set created http client to use instead of builder
-            clientBuilder.httpClient(ahc);
-            clientBuilder.httpClientBuilder(null);
-        }
-        client = clientBuilder.build();
-        return client;
-    }
-}
diff --git 
a/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/client/impl/ECS2ClientStandardImpl.java
 
b/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/client/impl/ECS2ClientStandardImpl.java
deleted file mode 100644
index 546f3f9b2866..000000000000
--- 
a/components/camel-aws/camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/client/impl/ECS2ClientStandardImpl.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * 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.component.aws2.ecs.client.impl;
-
-import java.net.URI;
-
-import org.apache.camel.component.aws2.ecs.ECS2Configuration;
-import org.apache.camel.component.aws2.ecs.client.ECS2InternalClient;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
-import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
-import software.amazon.awssdk.http.SdkHttpClient;
-import software.amazon.awssdk.http.SdkHttpConfigurationOption;
-import software.amazon.awssdk.http.apache.ApacheHttpClient;
-import software.amazon.awssdk.http.apache.ProxyConfiguration;
-import software.amazon.awssdk.regions.Region;
-import software.amazon.awssdk.services.ecs.EcsClient;
-import software.amazon.awssdk.services.ecs.EcsClientBuilder;
-import software.amazon.awssdk.utils.AttributeMap;
-
-/**
- * Manage an AWS ECS client for all users to use. This implementation is for 
local instances to use a static and solid
- * credential set.
- */
-public class ECS2ClientStandardImpl implements ECS2InternalClient {
-    private static final Logger LOG = 
LoggerFactory.getLogger(ECS2ClientStandardImpl.class);
-    private ECS2Configuration configuration;
-
-    /**
-     * Constructor that uses the config file.
-     */
-    public ECS2ClientStandardImpl(ECS2Configuration configuration) {
-        LOG.trace("Creating an AWS ECS manager using static credentials.");
-        this.configuration = configuration;
-    }
-
-    /**
-     * Getting the ECS AWS client that is used.
-     *
-     * @return Amazon ECS Client.
-     */
-    @Override
-    public EcsClient getEcsClient() {
-        EcsClient client = null;
-        EcsClientBuilder clientBuilder = EcsClient.builder();
-        ProxyConfiguration.Builder proxyConfig = null;
-        ApacheHttpClient.Builder httpClientBuilder = null;
-        boolean isClientConfigFound = false;
-        if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && 
ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
-            proxyConfig = ProxyConfiguration.builder();
-            URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + 
"://" + configuration.getProxyHost() + ":"
-                                           + configuration.getProxyPort());
-            proxyConfig.endpoint(proxyEndpoint);
-            httpClientBuilder = 
ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build());
-            isClientConfigFound = true;
-        }
-        if (configuration.getAccessKey() != null && 
configuration.getSecretKey() != null) {
-            AwsBasicCredentials cred = 
AwsBasicCredentials.create(configuration.getAccessKey(), 
configuration.getSecretKey());
-            if (isClientConfigFound) {
-                clientBuilder = 
clientBuilder.httpClientBuilder(httpClientBuilder)
-                        
.credentialsProvider(StaticCredentialsProvider.create(cred));
-            } else {
-                clientBuilder = 
clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred));
-            }
-        } else {
-            if (!isClientConfigFound) {
-                clientBuilder = 
clientBuilder.httpClientBuilder(httpClientBuilder);
-            }
-        }
-        if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
-            clientBuilder = 
clientBuilder.region(Region.of(configuration.getRegion()));
-        }
-        if (configuration.isOverrideEndpoint()) {
-            
clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride()));
-        }
-        if (configuration.isTrustAllCertificates()) {
-            if (httpClientBuilder == null) {
-                httpClientBuilder = ApacheHttpClient.builder();
-            }
-            SdkHttpClient ahc = 
httpClientBuilder.buildWithDefaults(AttributeMap
-                    .builder()
-                    .put(
-                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
-                            Boolean.TRUE)
-                    .build());
-            // set created http client to use instead of builder
-            clientBuilder.httpClient(ahc);
-            clientBuilder.httpClientBuilder(null);
-        }
-        client = clientBuilder.build();
-        return client;
-    }
-}
diff --git 
a/components/camel-aws/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ClientFactoryTest.java
 
b/components/camel-aws/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ClientFactoryTest.java
index 0a152d8f9f9f..f748a68b6458 100644
--- 
a/components/camel-aws/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ClientFactoryTest.java
+++ 
b/components/camel-aws/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ClientFactoryTest.java
@@ -17,44 +17,43 @@
 package org.apache.camel.component.aws2.ecs;
 
 import org.apache.camel.component.aws2.ecs.client.ECS2ClientFactory;
-import org.apache.camel.component.aws2.ecs.client.ECS2InternalClient;
-import 
org.apache.camel.component.aws2.ecs.client.impl.ECS2ClientIAMOptimizedImpl;
-import 
org.apache.camel.component.aws2.ecs.client.impl.ECS2ClientSessionTokenImpl;
-import org.apache.camel.component.aws2.ecs.client.impl.ECS2ClientStandardImpl;
 import org.junit.jupiter.api.Test;
+import software.amazon.awssdk.services.ecs.EcsClient;
 
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 public class ECS2ClientFactoryTest {
 
     @Test
-    public void getStandardECS2ClientDefault() {
-        ECS2Configuration ec2Configuration = new ECS2Configuration();
-        ECS2InternalClient ec2Client = 
ECS2ClientFactory.getEcsClient(ec2Configuration);
-        assertTrue(ec2Client instanceof ECS2ClientStandardImpl);
+    public void getEcsClientWithDefaultCredentials() {
+        ECS2Configuration configuration = new ECS2Configuration();
+        configuration.setUseDefaultCredentialsProvider(true);
+        configuration.setRegion("eu-west-1");
+        EcsClient ecsClient = ECS2ClientFactory.getEcsClient(configuration);
+        assertNotNull(ecsClient);
+        ecsClient.close();
     }
 
     @Test
-    public void getStandardECS2Client() {
-        ECS2Configuration ec2Configuration = new ECS2Configuration();
-        ec2Configuration.setUseDefaultCredentialsProvider(false);
-        ECS2InternalClient ec2Client = 
ECS2ClientFactory.getEcsClient(ec2Configuration);
-        assertTrue(ec2Client instanceof ECS2ClientStandardImpl);
+    public void getEcsClientWithStaticCredentials() {
+        ECS2Configuration configuration = new ECS2Configuration();
+        configuration.setAccessKey("testAccessKey");
+        configuration.setSecretKey("testSecretKey");
+        configuration.setRegion("eu-west-1");
+        EcsClient ecsClient = ECS2ClientFactory.getEcsClient(configuration);
+        assertNotNull(ecsClient);
+        ecsClient.close();
     }
 
     @Test
-    public void getIAMOptimizedECS2Client() {
-        ECS2Configuration ec2Configuration = new ECS2Configuration();
-        ec2Configuration.setUseDefaultCredentialsProvider(true);
-        ECS2InternalClient ec2Client = 
ECS2ClientFactory.getEcsClient(ec2Configuration);
-        assertTrue(ec2Client instanceof ECS2ClientIAMOptimizedImpl);
-    }
-
-    @Test
-    public void getSessionTokenECS2Client() {
-        ECS2Configuration ec2Configuration = new ECS2Configuration();
-        ec2Configuration.setUseSessionCredentials(true);
-        ECS2InternalClient ec2Client = 
ECS2ClientFactory.getEcsClient(ec2Configuration);
-        assertTrue(ec2Client instanceof ECS2ClientSessionTokenImpl);
+    public void getEcsClientWithEndpointOverride() {
+        ECS2Configuration configuration = new ECS2Configuration();
+        configuration.setUseDefaultCredentialsProvider(true);
+        configuration.setRegion("eu-west-1");
+        configuration.setOverrideEndpoint(true);
+        configuration.setUriEndpointOverride("http://localhost:4566";);
+        EcsClient ecsClient = ECS2ClientFactory.getEcsClient(configuration);
+        assertNotNull(ecsClient);
+        ecsClient.close();
     }
 }
diff --git a/components/camel-aws/camel-aws2-ses/pom.xml 
b/components/camel-aws/camel-aws2-ses/pom.xml
index db6a6879ecec..e33c208c47e9 100644
--- a/components/camel-aws/camel-aws2-ses/pom.xml
+++ b/components/camel-aws/camel-aws2-ses/pom.xml
@@ -40,6 +40,10 @@
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-support</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-aws-common</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.eclipse.angus</groupId>
             <artifactId>angus-mail</artifactId>
diff --git 
a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Configuration.java
 
b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Configuration.java
index b7bcbfe7f30f..79639ea06fc5 100644
--- 
a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Configuration.java
+++ 
b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Configuration.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.aws2.ses;
 
 import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.component.aws.common.AwsCommonConfiguration;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriParams;
@@ -25,7 +26,7 @@ import software.amazon.awssdk.core.Protocol;
 import software.amazon.awssdk.services.ses.SesClient;
 
 @UriParams
-public class Ses2Configuration implements Cloneable {
+public class Ses2Configuration implements Cloneable, AwsCommonConfiguration {
 
     @UriPath
     @Metadata(required = true)
@@ -285,7 +286,7 @@ public class Ses2Configuration implements Cloneable {
      * Set whether the Ses client should expect to load credentials through a 
default credentials provider or to expect
      * static credentials to be passed in.
      */
-    public void setUseDefaultCredentialsProvider(Boolean 
useDefaultCredentialsProvider) {
+    public void setUseDefaultCredentialsProvider(boolean 
useDefaultCredentialsProvider) {
         this.useDefaultCredentialsProvider = useDefaultCredentialsProvider;
     }
 
@@ -303,7 +304,8 @@ public class Ses2Configuration implements Cloneable {
         this.configurationSet = configurationSet;
     }
 
-    public Boolean isUseDefaultCredentialsProvider() {
+    @Override
+    public boolean isUseDefaultCredentialsProvider() {
         return useDefaultCredentialsProvider;
     }
 
diff --git 
a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Endpoint.java
 
b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Endpoint.java
index c8857fbde779..6a9f420d202f 100644
--- 
a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Endpoint.java
+++ 
b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Endpoint.java
@@ -56,7 +56,7 @@ public class Ses2Endpoint extends DefaultEndpoint implements 
EndpointServiceLoca
         super.doStart();
         sesClient = configuration.getAmazonSESClient() != null
                 ? configuration.getAmazonSESClient()
-                : Ses2ClientFactory.getSesClient(configuration).getSesClient();
+                : Ses2ClientFactory.getSesClient(configuration);
     }
 
     @Override
diff --git 
a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/client/Ses2ClientFactory.java
 
b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/client/Ses2ClientFactory.java
index 985a0379f2d1..d2feb71b34a9 100644
--- 
a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/client/Ses2ClientFactory.java
+++ 
b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/client/Ses2ClientFactory.java
@@ -16,14 +16,12 @@
  */
 package org.apache.camel.component.aws2.ses.client;
 
+import org.apache.camel.component.aws.common.AwsClientBuilderUtil;
 import org.apache.camel.component.aws2.ses.Ses2Configuration;
-import org.apache.camel.component.aws2.ses.client.impl.Ses2ClientOptimizedImpl;
-import 
org.apache.camel.component.aws2.ses.client.impl.Ses2ClientProfileOptimizedImpl;
-import 
org.apache.camel.component.aws2.ses.client.impl.Ses2ClientSessionTokenImpl;
-import org.apache.camel.component.aws2.ses.client.impl.Ses2ClientStandardImpl;
+import software.amazon.awssdk.services.ses.SesClient;
 
 /**
- * Factory class to return the correct type of AWS SES client.
+ * Factory class to create AWS SES clients using common configuration.
  */
 public final class Ses2ClientFactory {
 
@@ -31,20 +29,14 @@ public final class Ses2ClientFactory {
     }
 
     /**
-     * Return the correct AWS SES client (based on remote vs local).
+     * Create a SES client based on configuration.
      *
-     * @param  configuration configuration
-     * @return               SesClient
+     * @param  configuration The SES configuration
+     * @return               Configured SesClient
      */
-    public static Ses2InternalClient getSesClient(Ses2Configuration 
configuration) {
-        if 
(Boolean.TRUE.equals(configuration.isUseDefaultCredentialsProvider())) {
-            return new Ses2ClientOptimizedImpl(configuration);
-        } else if 
(Boolean.TRUE.equals(configuration.isUseProfileCredentialsProvider())) {
-            return new Ses2ClientProfileOptimizedImpl(configuration);
-        } else if 
(Boolean.TRUE.equals(configuration.isUseSessionCredentials())) {
-            return new Ses2ClientSessionTokenImpl(configuration);
-        } else {
-            return new Ses2ClientStandardImpl(configuration);
-        }
+    public static SesClient getSesClient(Ses2Configuration configuration) {
+        return AwsClientBuilderUtil.buildClient(
+                configuration,
+                SesClient::builder);
     }
 }
diff --git 
a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/client/Ses2InternalClient.java
 
b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/client/Ses2InternalClient.java
deleted file mode 100644
index 45f24d643a72..000000000000
--- 
a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/client/Ses2InternalClient.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.component.aws2.ses.client;
-
-import software.amazon.awssdk.services.ses.SesClient;
-
-/**
- * Manage the required actions of a SES client for either local or remote.
- */
-public interface Ses2InternalClient {
-
-    /**
-     * Returns an SES client after a factory method determines which one to 
return.
-     *
-     * @return SesClient SesClient
-     */
-    SesClient getSesClient();
-}
diff --git 
a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/client/impl/Ses2ClientOptimizedImpl.java
 
b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/client/impl/Ses2ClientOptimizedImpl.java
deleted file mode 100644
index b487e49bbce6..000000000000
--- 
a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/client/impl/Ses2ClientOptimizedImpl.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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.component.aws2.ses.client.impl;
-
-import java.net.URI;
-
-import org.apache.camel.component.aws2.ses.Ses2Configuration;
-import org.apache.camel.component.aws2.ses.client.Ses2InternalClient;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import software.amazon.awssdk.http.SdkHttpClient;
-import software.amazon.awssdk.http.SdkHttpConfigurationOption;
-import software.amazon.awssdk.http.apache.ApacheHttpClient;
-import software.amazon.awssdk.http.apache.ProxyConfiguration;
-import software.amazon.awssdk.regions.Region;
-import software.amazon.awssdk.services.ses.SesClient;
-import software.amazon.awssdk.services.ses.SesClientBuilder;
-import software.amazon.awssdk.utils.AttributeMap;
-
-/**
- * Manage an AWS MSK client for all users to use (enabling temporary creds). 
This implementation is for remote instances
- * to manage the credentials on their own (eliminating credential rotations)
- */
-public class Ses2ClientOptimizedImpl implements Ses2InternalClient {
-    private static final Logger LOG = 
LoggerFactory.getLogger(Ses2ClientOptimizedImpl.class);
-    private Ses2Configuration configuration;
-
-    /**
-     * Constructor that uses the config file.
-     */
-    public Ses2ClientOptimizedImpl(Ses2Configuration configuration) {
-        LOG.trace("Creating an AWS SES client for an ec2 instance with IAM 
temporary credentials (normal for ec2s).");
-        this.configuration = configuration;
-    }
-
-    /**
-     * Getting the SES AWS client that is used.
-     *
-     * @return SES Client.
-     */
-    @Override
-    public SesClient getSesClient() {
-        SesClient client = null;
-        SesClientBuilder clientBuilder = SesClient.builder();
-        ProxyConfiguration.Builder proxyConfig = null;
-        ApacheHttpClient.Builder httpClientBuilder = null;
-        if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && 
ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
-            proxyConfig = ProxyConfiguration.builder();
-            URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + 
"://" + configuration.getProxyHost() + ":"
-                                           + configuration.getProxyPort());
-            proxyConfig.endpoint(proxyEndpoint);
-            httpClientBuilder = 
ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build());
-            clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder);
-        }
-        if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
-            clientBuilder = 
clientBuilder.region(Region.of(configuration.getRegion()));
-        }
-        if (configuration.isOverrideEndpoint()) {
-            
clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride()));
-        }
-        if (configuration.isTrustAllCertificates()) {
-            if (httpClientBuilder == null) {
-                httpClientBuilder = ApacheHttpClient.builder();
-            }
-            SdkHttpClient ahc = 
httpClientBuilder.buildWithDefaults(AttributeMap
-                    .builder()
-                    .put(
-                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
-                            Boolean.TRUE)
-                    .build());
-            // set created http client to use instead of builder
-            clientBuilder.httpClient(ahc);
-            clientBuilder.httpClientBuilder(null);
-        }
-        client = clientBuilder.build();
-        return client;
-    }
-}
diff --git 
a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/client/impl/Ses2ClientProfileOptimizedImpl.java
 
b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/client/impl/Ses2ClientProfileOptimizedImpl.java
deleted file mode 100644
index 7e5d3e450370..000000000000
--- 
a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/client/impl/Ses2ClientProfileOptimizedImpl.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * 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.component.aws2.ses.client.impl;
-
-import java.net.URI;
-
-import org.apache.camel.component.aws2.ses.Ses2Configuration;
-import org.apache.camel.component.aws2.ses.client.Ses2InternalClient;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
-import software.amazon.awssdk.http.SdkHttpClient;
-import software.amazon.awssdk.http.SdkHttpConfigurationOption;
-import software.amazon.awssdk.http.apache.ApacheHttpClient;
-import software.amazon.awssdk.http.apache.ProxyConfiguration;
-import software.amazon.awssdk.regions.Region;
-import software.amazon.awssdk.services.ses.SesClient;
-import software.amazon.awssdk.services.ses.SesClientBuilder;
-import software.amazon.awssdk.utils.AttributeMap;
-
-/**
- * Manage an AWS MSK client for all users to use (enabling temporary creds). 
This implementation is for remote instances
- * to manage the credentials on their own (eliminating credential rotations)
- */
-public class Ses2ClientProfileOptimizedImpl implements Ses2InternalClient {
-    private static final Logger LOG = 
LoggerFactory.getLogger(Ses2ClientProfileOptimizedImpl.class);
-    private Ses2Configuration configuration;
-
-    /**
-     * Constructor that uses the config file.
-     */
-    public Ses2ClientProfileOptimizedImpl(Ses2Configuration configuration) {
-        LOG.trace("Creating an AWS SES client for an ec2 instance with IAM 
temporary credentials (normal for ec2s).");
-        this.configuration = configuration;
-    }
-
-    /**
-     * Getting the SES AWS client that is used.
-     *
-     * @return SES Client.
-     */
-    @Override
-    public SesClient getSesClient() {
-        SesClient client = null;
-        SesClientBuilder clientBuilder = SesClient.builder();
-        ProxyConfiguration.Builder proxyConfig = null;
-        ApacheHttpClient.Builder httpClientBuilder = null;
-        if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && 
ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
-            proxyConfig = ProxyConfiguration.builder();
-            URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + 
"://" + configuration.getProxyHost() + ":"
-                                           + configuration.getProxyPort());
-            proxyConfig.endpoint(proxyEndpoint);
-            httpClientBuilder = 
ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build());
-            clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder);
-        }
-        if (configuration.getProfileCredentialsName() != null) {
-            clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder)
-                    
.credentialsProvider(ProfileCredentialsProvider.create(configuration.getProfileCredentialsName()));
-        }
-        if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
-            clientBuilder = 
clientBuilder.region(Region.of(configuration.getRegion()));
-        }
-        if (configuration.isOverrideEndpoint()) {
-            
clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride()));
-        }
-        if (configuration.isTrustAllCertificates()) {
-            if (httpClientBuilder == null) {
-                httpClientBuilder = ApacheHttpClient.builder();
-            }
-            SdkHttpClient ahc = 
httpClientBuilder.buildWithDefaults(AttributeMap
-                    .builder()
-                    .put(
-                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
-                            Boolean.TRUE)
-                    .build());
-            // set created http client to use instead of builder
-            clientBuilder.httpClient(ahc);
-            clientBuilder.httpClientBuilder(null);
-        }
-        client = clientBuilder.build();
-        return client;
-    }
-}
diff --git 
a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/client/impl/Ses2ClientSessionTokenImpl.java
 
b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/client/impl/Ses2ClientSessionTokenImpl.java
deleted file mode 100644
index fd51eede61b1..000000000000
--- 
a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/client/impl/Ses2ClientSessionTokenImpl.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * 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.component.aws2.ses.client.impl;
-
-import java.net.URI;
-
-import org.apache.camel.component.aws2.ses.Ses2Configuration;
-import org.apache.camel.component.aws2.ses.client.Ses2InternalClient;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import software.amazon.awssdk.auth.credentials.AwsSessionCredentials;
-import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
-import software.amazon.awssdk.http.SdkHttpClient;
-import software.amazon.awssdk.http.SdkHttpConfigurationOption;
-import software.amazon.awssdk.http.apache.ApacheHttpClient;
-import software.amazon.awssdk.http.apache.ProxyConfiguration;
-import software.amazon.awssdk.regions.Region;
-import software.amazon.awssdk.services.ses.SesClient;
-import software.amazon.awssdk.services.ses.SesClientBuilder;
-import software.amazon.awssdk.utils.AttributeMap;
-
-/**
- * Manage an AWS SES client for all users to use. This implementation is for 
local instances to use a static and solid
- * credential set.
- */
-public class Ses2ClientSessionTokenImpl implements Ses2InternalClient {
-    private static final Logger LOG = 
LoggerFactory.getLogger(Ses2ClientSessionTokenImpl.class);
-    private Ses2Configuration configuration;
-
-    /**
-     * Constructor that uses the config file.
-     */
-    public Ses2ClientSessionTokenImpl(Ses2Configuration configuration) {
-        LOG.trace("Creating an AWS SES manager using static credentials.");
-        this.configuration = configuration;
-    }
-
-    /**
-     * Getting the SES AWS client that is used.
-     *
-     * @return Amazon SES Client.
-     */
-    @Override
-    public SesClient getSesClient() {
-        SesClient client = null;
-        SesClientBuilder clientBuilder = SesClient.builder();
-        ProxyConfiguration.Builder proxyConfig = null;
-        ApacheHttpClient.Builder httpClientBuilder = null;
-        boolean isClientConfigFound = false;
-        if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && 
ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
-            proxyConfig = ProxyConfiguration.builder();
-            URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + 
"://" + configuration.getProxyHost() + ":"
-                                           + configuration.getProxyPort());
-            proxyConfig.endpoint(proxyEndpoint);
-            httpClientBuilder = 
ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build());
-            isClientConfigFound = true;
-        }
-        if (configuration.getAccessKey() != null && 
configuration.getSecretKey() != null
-                && configuration.getSessionToken() != null) {
-            AwsSessionCredentials cred = 
AwsSessionCredentials.create(configuration.getAccessKey(),
-                    configuration.getSecretKey(), 
configuration.getSessionToken());
-            if (isClientConfigFound) {
-                clientBuilder = 
clientBuilder.httpClientBuilder(httpClientBuilder)
-                        
.credentialsProvider(StaticCredentialsProvider.create(cred));
-            } else {
-                clientBuilder = 
clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred));
-            }
-        } else {
-            if (!isClientConfigFound) {
-                clientBuilder = 
clientBuilder.httpClientBuilder(httpClientBuilder);
-            }
-        }
-        if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
-            clientBuilder = 
clientBuilder.region(Region.of(configuration.getRegion()));
-        }
-        if (configuration.isOverrideEndpoint()) {
-            
clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride()));
-        }
-        if (configuration.isTrustAllCertificates()) {
-            if (httpClientBuilder == null) {
-                httpClientBuilder = ApacheHttpClient.builder();
-            }
-            SdkHttpClient ahc = 
httpClientBuilder.buildWithDefaults(AttributeMap
-                    .builder()
-                    .put(
-                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
-                            Boolean.TRUE)
-                    .build());
-            // set created http client to use instead of builder
-            clientBuilder.httpClient(ahc);
-            clientBuilder.httpClientBuilder(null);
-        }
-        client = clientBuilder.build();
-        return client;
-    }
-}
diff --git 
a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/client/impl/Ses2ClientStandardImpl.java
 
b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/client/impl/Ses2ClientStandardImpl.java
deleted file mode 100644
index cd20dd15b9a4..000000000000
--- 
a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/client/impl/Ses2ClientStandardImpl.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * 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.component.aws2.ses.client.impl;
-
-import java.net.URI;
-
-import org.apache.camel.component.aws2.ses.Ses2Configuration;
-import org.apache.camel.component.aws2.ses.client.Ses2InternalClient;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
-import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
-import software.amazon.awssdk.http.SdkHttpClient;
-import software.amazon.awssdk.http.SdkHttpConfigurationOption;
-import software.amazon.awssdk.http.apache.ApacheHttpClient;
-import software.amazon.awssdk.http.apache.ProxyConfiguration;
-import software.amazon.awssdk.regions.Region;
-import software.amazon.awssdk.services.ses.SesClient;
-import software.amazon.awssdk.services.ses.SesClientBuilder;
-import software.amazon.awssdk.utils.AttributeMap;
-
-/**
- * Manage an AWS SES client for all users to use. This implementation is for 
local instances to use a static and solid
- * credential set.
- */
-public class Ses2ClientStandardImpl implements Ses2InternalClient {
-    private static final Logger LOG = 
LoggerFactory.getLogger(Ses2ClientStandardImpl.class);
-    private Ses2Configuration configuration;
-
-    /**
-     * Constructor that uses the config file.
-     */
-    public Ses2ClientStandardImpl(Ses2Configuration configuration) {
-        LOG.trace("Creating an AWS SES manager using static credentials.");
-        this.configuration = configuration;
-    }
-
-    /**
-     * Getting the SES AWS client that is used.
-     *
-     * @return Amazon SES Client.
-     */
-    @Override
-    public SesClient getSesClient() {
-        SesClient client = null;
-        SesClientBuilder clientBuilder = SesClient.builder();
-        ProxyConfiguration.Builder proxyConfig = null;
-        ApacheHttpClient.Builder httpClientBuilder = null;
-        boolean isClientConfigFound = false;
-        if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && 
ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
-            proxyConfig = ProxyConfiguration.builder();
-            URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + 
"://" + configuration.getProxyHost() + ":"
-                                           + configuration.getProxyPort());
-            proxyConfig.endpoint(proxyEndpoint);
-            httpClientBuilder = 
ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build());
-            isClientConfigFound = true;
-        }
-        if (configuration.getAccessKey() != null && 
configuration.getSecretKey() != null) {
-            AwsBasicCredentials cred = 
AwsBasicCredentials.create(configuration.getAccessKey(), 
configuration.getSecretKey());
-            if (isClientConfigFound) {
-                clientBuilder = 
clientBuilder.httpClientBuilder(httpClientBuilder)
-                        
.credentialsProvider(StaticCredentialsProvider.create(cred));
-            } else {
-                clientBuilder = 
clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred));
-            }
-        } else {
-            if (!isClientConfigFound) {
-                clientBuilder = 
clientBuilder.httpClientBuilder(httpClientBuilder);
-            }
-        }
-        if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
-            clientBuilder = 
clientBuilder.region(Region.of(configuration.getRegion()));
-        }
-        if (configuration.isOverrideEndpoint()) {
-            
clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride()));
-        }
-        if (configuration.isTrustAllCertificates()) {
-            if (httpClientBuilder == null) {
-                httpClientBuilder = ApacheHttpClient.builder();
-            }
-            SdkHttpClient ahc = 
httpClientBuilder.buildWithDefaults(AttributeMap
-                    .builder()
-                    .put(
-                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
-                            Boolean.TRUE)
-                    .build());
-            // set created http client to use instead of builder
-            clientBuilder.httpClient(ahc);
-            clientBuilder.httpClientBuilder(null);
-        }
-        client = clientBuilder.build();
-        return client;
-    }
-}
diff --git 
a/components/camel-aws/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/Ses2ClientFactoryTest.java
 
b/components/camel-aws/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/Ses2ClientFactoryTest.java
index b194e8787e49..343663d86173 100644
--- 
a/components/camel-aws/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/Ses2ClientFactoryTest.java
+++ 
b/components/camel-aws/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/Ses2ClientFactoryTest.java
@@ -17,44 +17,43 @@
 package org.apache.camel.component.aws2.ses;
 
 import org.apache.camel.component.aws2.ses.client.Ses2ClientFactory;
-import org.apache.camel.component.aws2.ses.client.Ses2InternalClient;
-import org.apache.camel.component.aws2.ses.client.impl.Ses2ClientOptimizedImpl;
-import 
org.apache.camel.component.aws2.ses.client.impl.Ses2ClientSessionTokenImpl;
-import org.apache.camel.component.aws2.ses.client.impl.Ses2ClientStandardImpl;
 import org.junit.jupiter.api.Test;
+import software.amazon.awssdk.services.ses.SesClient;
 
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 public class Ses2ClientFactoryTest {
 
     @Test
-    public void getStandardSESClientDefault() {
-        Ses2Configuration ses2Configuration = new Ses2Configuration();
-        Ses2InternalClient sesClient = 
Ses2ClientFactory.getSesClient(ses2Configuration);
-        assertTrue(sesClient instanceof Ses2ClientStandardImpl);
+    public void getSesClientWithDefaultCredentials() {
+        Ses2Configuration configuration = new Ses2Configuration();
+        configuration.setUseDefaultCredentialsProvider(true);
+        configuration.setRegion("eu-west-1");
+        SesClient sesClient = Ses2ClientFactory.getSesClient(configuration);
+        assertNotNull(sesClient);
+        sesClient.close();
     }
 
     @Test
-    public void getStandardSESClient() {
-        Ses2Configuration ses2Configuration = new Ses2Configuration();
-        ses2Configuration.setUseDefaultCredentialsProvider(false);
-        Ses2InternalClient sesClient = 
Ses2ClientFactory.getSesClient(ses2Configuration);
-        assertTrue(sesClient instanceof Ses2ClientStandardImpl);
+    public void getSesClientWithStaticCredentials() {
+        Ses2Configuration configuration = new Ses2Configuration();
+        configuration.setAccessKey("testAccessKey");
+        configuration.setSecretKey("testSecretKey");
+        configuration.setRegion("eu-west-1");
+        SesClient sesClient = Ses2ClientFactory.getSesClient(configuration);
+        assertNotNull(sesClient);
+        sesClient.close();
     }
 
     @Test
-    public void getSESOptimizedIAMClient() {
-        Ses2Configuration ses2Configuration = new Ses2Configuration();
-        ses2Configuration.setUseDefaultCredentialsProvider(true);
-        Ses2InternalClient sesClient = 
Ses2ClientFactory.getSesClient(ses2Configuration);
-        assertTrue(sesClient instanceof Ses2ClientOptimizedImpl);
-    }
-
-    @Test
-    public void getSESSessionTokenImplClient() {
-        Ses2Configuration ses2Configuration = new Ses2Configuration();
-        ses2Configuration.setUseSessionCredentials(true);
-        Ses2InternalClient sesClient = 
Ses2ClientFactory.getSesClient(ses2Configuration);
-        assertTrue(sesClient instanceof Ses2ClientSessionTokenImpl);
+    public void getSesClientWithEndpointOverride() {
+        Ses2Configuration configuration = new Ses2Configuration();
+        configuration.setUseDefaultCredentialsProvider(true);
+        configuration.setRegion("eu-west-1");
+        configuration.setOverrideEndpoint(true);
+        configuration.setUriEndpointOverride("http://localhost:4566";);
+        SesClient sesClient = Ses2ClientFactory.getSesClient(configuration);
+        assertNotNull(sesClient);
+        sesClient.close();
     }
 }
diff --git a/components/camel-aws/camel-aws2-sts/pom.xml 
b/components/camel-aws/camel-aws2-sts/pom.xml
index fdf7173de19b..54711b913c02 100644
--- a/components/camel-aws/camel-aws2-sts/pom.xml
+++ b/components/camel-aws/camel-aws2-sts/pom.xml
@@ -40,6 +40,10 @@
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-support</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-aws-common</artifactId>
+        </dependency>
         <dependency>
             <groupId>software.amazon.awssdk</groupId>
             <artifactId>sts</artifactId>
diff --git 
a/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Configuration.java
 
b/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Configuration.java
index e3c0505b0576..79c93bc9d2dc 100644
--- 
a/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Configuration.java
+++ 
b/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Configuration.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.aws2.sts;
 
 import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.component.aws.common.AwsCommonConfiguration;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriParams;
@@ -26,7 +27,7 @@ import software.amazon.awssdk.regions.Region;
 import software.amazon.awssdk.services.sts.StsClient;
 
 @UriParams
-public class STS2Configuration implements Cloneable {
+public class STS2Configuration implements Cloneable, AwsCommonConfiguration {
 
     @UriPath(description = "Logical name")
     @Metadata(required = true)
@@ -203,18 +204,32 @@ public class STS2Configuration implements Cloneable {
      * Set whether the STS client should expect to load credentials through a 
default credentials provider or to expect
      * static credentials to be passed in.
      */
-    public void setUseDefaultCredentialsProvider(Boolean 
useDefaultCredentialsProvider) {
+    public void setUseDefaultCredentialsProvider(boolean 
useDefaultCredentialsProvider) {
         this.useDefaultCredentialsProvider = useDefaultCredentialsProvider;
     }
 
-    public Boolean isUseDefaultCredentialsProvider() {
+    @Override
+    public boolean isUseDefaultCredentialsProvider() {
         return useDefaultCredentialsProvider;
     }
 
+    @Override
     public boolean isUseProfileCredentialsProvider() {
         return useProfileCredentialsProvider;
     }
 
+    @Override
+    public String getSessionToken() {
+        // STS doesn't use session tokens - it provides them
+        return null;
+    }
+
+    @Override
+    public boolean isUseSessionCredentials() {
+        // STS doesn't use session credentials - it provides them
+        return false;
+    }
+
     /**
      * Set whether the STS client should expect to load credentials through a 
profile credentials provider.
      */
diff --git 
a/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Endpoint.java
 
b/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Endpoint.java
index d2c9373cfdc0..525faf79c2c1 100644
--- 
a/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Endpoint.java
+++ 
b/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Endpoint.java
@@ -65,7 +65,7 @@ public class STS2Endpoint extends DefaultEndpoint implements 
EndpointServiceLoca
 
         stsClient = configuration.getStsClient() != null
                 ? configuration.getStsClient()
-                : STS2ClientFactory.getStsClient(configuration).getStsClient();
+                : STS2ClientFactory.getStsClient(configuration);
     }
 
     @Override
diff --git 
a/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/client/STS2ClientFactory.java
 
b/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/client/STS2ClientFactory.java
index 53bcdc58da82..cffeb6c19d22 100644
--- 
a/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/client/STS2ClientFactory.java
+++ 
b/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/client/STS2ClientFactory.java
@@ -16,13 +16,12 @@
  */
 package org.apache.camel.component.aws2.sts.client;
 
+import org.apache.camel.component.aws.common.AwsClientBuilderUtil;
 import org.apache.camel.component.aws2.sts.STS2Configuration;
-import org.apache.camel.component.aws2.sts.client.impl.STS2ClientIAMOptimized;
-import 
org.apache.camel.component.aws2.sts.client.impl.STS2ClientIAMProfileOptimized;
-import org.apache.camel.component.aws2.sts.client.impl.STS2ClientStandardImpl;
+import software.amazon.awssdk.services.sts.StsClient;
 
 /**
- * Factory class to return the correct type of AWS STS aws.
+ * Factory class to create AWS STS clients using common configuration.
  */
 public final class STS2ClientFactory {
 
@@ -30,18 +29,14 @@ public final class STS2ClientFactory {
     }
 
     /**
-     * Return the correct aws STS client (based on remote vs local).
+     * Create an STS client based on configuration.
      *
-     * @param  configuration configuration
-     * @return               StsClient
+     * @param  configuration The STS configuration
+     * @return               Configured StsClient
      */
-    public static STS2InternalClient getStsClient(STS2Configuration 
configuration) {
-        if 
(Boolean.TRUE.equals(configuration.isUseDefaultCredentialsProvider())) {
-            return new STS2ClientIAMOptimized(configuration);
-        } else if 
(Boolean.TRUE.equals(configuration.isUseProfileCredentialsProvider())) {
-            return new STS2ClientIAMProfileOptimized(configuration);
-        } else {
-            return new STS2ClientStandardImpl(configuration);
-        }
+    public static StsClient getStsClient(STS2Configuration configuration) {
+        return AwsClientBuilderUtil.buildClient(
+                configuration,
+                StsClient::builder);
     }
 }
diff --git 
a/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/client/STS2InternalClient.java
 
b/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/client/STS2InternalClient.java
deleted file mode 100644
index d30cdc3cb5aa..000000000000
--- 
a/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/client/STS2InternalClient.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.component.aws2.sts.client;
-
-import software.amazon.awssdk.services.sts.StsClient;
-
-public interface STS2InternalClient {
-
-    /**
-     * Returns an sts client after a factory method determines which one to 
return.
-     *
-     * @return StsClient stsClient
-     */
-    StsClient getStsClient();
-
-}
diff --git 
a/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/client/impl/STS2ClientIAMOptimized.java
 
b/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/client/impl/STS2ClientIAMOptimized.java
deleted file mode 100644
index a4d5616040f7..000000000000
--- 
a/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/client/impl/STS2ClientIAMOptimized.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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.component.aws2.sts.client.impl;
-
-import java.net.URI;
-
-import org.apache.camel.component.aws2.sts.STS2Configuration;
-import org.apache.camel.component.aws2.sts.client.STS2InternalClient;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import software.amazon.awssdk.http.SdkHttpClient;
-import software.amazon.awssdk.http.SdkHttpConfigurationOption;
-import software.amazon.awssdk.http.apache.ApacheHttpClient;
-import software.amazon.awssdk.http.apache.ProxyConfiguration;
-import software.amazon.awssdk.regions.Region;
-import software.amazon.awssdk.services.sts.StsClient;
-import software.amazon.awssdk.services.sts.StsClientBuilder;
-import software.amazon.awssdk.utils.AttributeMap;
-
-/**
- * Manage an AWS STS client for all users to use. This implementation is for 
remote instances to manage the credentials
- * on their own (eliminating credential rotations)
- */
-public class STS2ClientIAMOptimized implements STS2InternalClient {
-    private static final Logger LOG = 
LoggerFactory.getLogger(STS2ClientIAMOptimized.class);
-    private STS2Configuration configuration;
-
-    /**
-     * Constructor that uses the config file.
-     */
-    public STS2ClientIAMOptimized(STS2Configuration configuration) {
-        LOG.trace("Creating an AWS STS client for working on AWS Services");
-        this.configuration = configuration;
-    }
-
-    /**
-     * Getting the STS aws client that is used.
-     *
-     * @return Amazon STS Client.
-     */
-    @Override
-    public StsClient getStsClient() {
-        StsClient client = null;
-        StsClientBuilder clientBuilder = StsClient.builder();
-        ProxyConfiguration.Builder proxyConfig = null;
-        ApacheHttpClient.Builder httpClientBuilder = null;
-
-        if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && 
ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
-            proxyConfig = ProxyConfiguration.builder();
-            URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + 
"://" + configuration.getProxyHost() + ":"
-                                           + configuration.getProxyPort());
-            proxyConfig.endpoint(proxyEndpoint);
-            httpClientBuilder = 
ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build());
-            clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder);
-        }
-        if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
-            clientBuilder = 
clientBuilder.region(Region.of(configuration.getRegion()));
-        }
-        if (configuration.isOverrideEndpoint()) {
-            
clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride()));
-        }
-        if (configuration.isTrustAllCertificates()) {
-            if (httpClientBuilder == null) {
-                httpClientBuilder = ApacheHttpClient.builder();
-            }
-            SdkHttpClient ahc = 
httpClientBuilder.buildWithDefaults(AttributeMap
-                    .builder()
-                    .put(
-                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
-                            Boolean.TRUE)
-                    .build());
-            // set created http client to use instead of builder
-            clientBuilder.httpClient(ahc);
-            clientBuilder.httpClientBuilder(null);
-        }
-        client = clientBuilder.build();
-        return client;
-    }
-}
diff --git 
a/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/client/impl/STS2ClientIAMProfileOptimized.java
 
b/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/client/impl/STS2ClientIAMProfileOptimized.java
deleted file mode 100644
index 497728e212b5..000000000000
--- 
a/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/client/impl/STS2ClientIAMProfileOptimized.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * 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.component.aws2.sts.client.impl;
-
-import java.net.URI;
-
-import org.apache.camel.component.aws2.sts.STS2Configuration;
-import org.apache.camel.component.aws2.sts.client.STS2InternalClient;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
-import software.amazon.awssdk.http.SdkHttpClient;
-import software.amazon.awssdk.http.SdkHttpConfigurationOption;
-import software.amazon.awssdk.http.apache.ApacheHttpClient;
-import software.amazon.awssdk.http.apache.ProxyConfiguration;
-import software.amazon.awssdk.regions.Region;
-import software.amazon.awssdk.services.sts.StsClient;
-import software.amazon.awssdk.services.sts.StsClientBuilder;
-import software.amazon.awssdk.utils.AttributeMap;
-
-/**
- * Manage an AWS STS client for all users to use. This implementation is for 
remote instances to manage the credentials
- * on their own (eliminating credential rotations)
- */
-public class STS2ClientIAMProfileOptimized implements STS2InternalClient {
-    private static final Logger LOG = 
LoggerFactory.getLogger(STS2ClientIAMProfileOptimized.class);
-    private STS2Configuration configuration;
-
-    /**
-     * Constructor that uses the config file.
-     */
-    public STS2ClientIAMProfileOptimized(STS2Configuration configuration) {
-        LOG.trace("Creating an AWS STS client for working on AWS Services");
-        this.configuration = configuration;
-    }
-
-    /**
-     * Getting the STS aws client that is used.
-     *
-     * @return Amazon STS Client.
-     */
-    @Override
-    public StsClient getStsClient() {
-        StsClient client = null;
-        StsClientBuilder clientBuilder = StsClient.builder();
-        ProxyConfiguration.Builder proxyConfig = null;
-        ApacheHttpClient.Builder httpClientBuilder = null;
-
-        if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && 
ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
-            proxyConfig = ProxyConfiguration.builder();
-            URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + 
"://" + configuration.getProxyHost() + ":"
-                                           + configuration.getProxyPort());
-            proxyConfig.endpoint(proxyEndpoint);
-            httpClientBuilder = 
ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build());
-            clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder);
-        }
-        if (configuration.getProfileCredentialsName() != null) {
-            clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder)
-                    
.credentialsProvider(ProfileCredentialsProvider.create(configuration.getProfileCredentialsName()));
-        }
-        if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
-            clientBuilder = 
clientBuilder.region(Region.of(configuration.getRegion()));
-        }
-        if (configuration.isOverrideEndpoint()) {
-            
clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride()));
-        }
-        if (configuration.isTrustAllCertificates()) {
-            if (httpClientBuilder == null) {
-                httpClientBuilder = ApacheHttpClient.builder();
-            }
-            SdkHttpClient ahc = 
httpClientBuilder.buildWithDefaults(AttributeMap
-                    .builder()
-                    .put(
-                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
-                            Boolean.TRUE)
-                    .build());
-            // set created http client to use instead of builder
-            clientBuilder.httpClient(ahc);
-            clientBuilder.httpClientBuilder(null);
-        }
-        client = clientBuilder.build();
-        return client;
-    }
-}
diff --git 
a/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/client/impl/STS2ClientStandardImpl.java
 
b/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/client/impl/STS2ClientStandardImpl.java
deleted file mode 100644
index 9821ea4a4395..000000000000
--- 
a/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/client/impl/STS2ClientStandardImpl.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * 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.component.aws2.sts.client.impl;
-
-import java.net.URI;
-
-import org.apache.camel.component.aws2.sts.STS2Configuration;
-import org.apache.camel.component.aws2.sts.client.STS2InternalClient;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
-import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
-import software.amazon.awssdk.http.SdkHttpClient;
-import software.amazon.awssdk.http.SdkHttpConfigurationOption;
-import software.amazon.awssdk.http.apache.ApacheHttpClient;
-import software.amazon.awssdk.http.apache.ProxyConfiguration;
-import software.amazon.awssdk.regions.Region;
-import software.amazon.awssdk.services.sts.StsClient;
-import software.amazon.awssdk.services.sts.StsClientBuilder;
-import software.amazon.awssdk.utils.AttributeMap;
-
-/**
- * Manage an AWS STS client for all users to use. This implementation is for 
local instances to use a static and solid
- * credential set.
- */
-public class STS2ClientStandardImpl implements STS2InternalClient {
-    private static final Logger LOG = 
LoggerFactory.getLogger(STS2ClientStandardImpl.class);
-    private STS2Configuration configuration;
-
-    /**
-     * Constructor that uses the config file.
-     */
-    public STS2ClientStandardImpl(STS2Configuration configuration) {
-        LOG.trace("Creating an AWS STS manager using static credentials.");
-        this.configuration = configuration;
-    }
-
-    /**
-     * Getting the STS aws client that is used.
-     *
-     * @return Amazon STS Client.
-     */
-    @Override
-    public StsClient getStsClient() {
-        StsClient client = null;
-        StsClientBuilder clientBuilder = StsClient.builder();
-        ProxyConfiguration.Builder proxyConfig = null;
-        ApacheHttpClient.Builder httpClientBuilder = null;
-        boolean isClientConfigFound = false;
-        if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && 
ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
-            proxyConfig = ProxyConfiguration.builder();
-            URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + 
"://" + configuration.getProxyHost() + ":"
-                                           + configuration.getProxyPort());
-            proxyConfig.endpoint(proxyEndpoint);
-            httpClientBuilder = 
ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build());
-            isClientConfigFound = true;
-        }
-        if (configuration.getAccessKey() != null && 
configuration.getSecretKey() != null) {
-            AwsBasicCredentials cred = 
AwsBasicCredentials.create(configuration.getAccessKey(), 
configuration.getSecretKey());
-            if (isClientConfigFound) {
-                clientBuilder = 
clientBuilder.httpClientBuilder(httpClientBuilder)
-                        
.credentialsProvider(StaticCredentialsProvider.create(cred));
-            } else {
-                clientBuilder = 
clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred));
-            }
-        } else {
-            if (!isClientConfigFound) {
-                clientBuilder = 
clientBuilder.httpClientBuilder(httpClientBuilder);
-            }
-        }
-        if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
-            clientBuilder = 
clientBuilder.region(Region.of(configuration.getRegion()));
-        }
-        if (configuration.isOverrideEndpoint()) {
-            
clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride()));
-        }
-        if (configuration.isTrustAllCertificates()) {
-            if (httpClientBuilder == null) {
-                httpClientBuilder = ApacheHttpClient.builder();
-            }
-            SdkHttpClient ahc = 
httpClientBuilder.buildWithDefaults(AttributeMap
-                    .builder()
-                    .put(
-                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
-                            Boolean.TRUE)
-                    .build());
-            // set created http client to use instead of builder
-            clientBuilder.httpClient(ahc);
-            clientBuilder.httpClientBuilder(null);
-        }
-        client = clientBuilder.build();
-        return client;
-    }
-}
diff --git 
a/components/camel-aws/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/sts/STS2ClientFactoryTest.java
 
b/components/camel-aws/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/sts/STS2ClientFactoryTest.java
index d9aa7ce52786..1cc30dfdd958 100644
--- 
a/components/camel-aws/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/sts/STS2ClientFactoryTest.java
+++ 
b/components/camel-aws/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/sts/STS2ClientFactoryTest.java
@@ -17,35 +17,43 @@
 package org.apache.camel.component.aws2.sts;
 
 import org.apache.camel.component.aws2.sts.client.STS2ClientFactory;
-import org.apache.camel.component.aws2.sts.client.STS2InternalClient;
-import org.apache.camel.component.aws2.sts.client.impl.STS2ClientIAMOptimized;
-import org.apache.camel.component.aws2.sts.client.impl.STS2ClientStandardImpl;
 import org.junit.jupiter.api.Test;
+import software.amazon.awssdk.services.sts.StsClient;
 
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 public class STS2ClientFactoryTest {
 
     @Test
-    public void getStandardSTSClientDefault() {
-        STS2Configuration sts2Configuration = new STS2Configuration();
-        STS2InternalClient stsClient = 
STS2ClientFactory.getStsClient(sts2Configuration);
-        assertTrue(stsClient instanceof STS2ClientStandardImpl);
+    public void getStsClientWithDefaultCredentials() {
+        STS2Configuration configuration = new STS2Configuration();
+        configuration.setUseDefaultCredentialsProvider(true);
+        configuration.setRegion("eu-west-1");
+        StsClient stsClient = STS2ClientFactory.getStsClient(configuration);
+        assertNotNull(stsClient);
+        stsClient.close();
     }
 
     @Test
-    public void getStandardSTSClient() {
-        STS2Configuration sts2Configuration = new STS2Configuration();
-        sts2Configuration.setUseDefaultCredentialsProvider(false);
-        STS2InternalClient stsClient = 
STS2ClientFactory.getStsClient(sts2Configuration);
-        assertTrue(stsClient instanceof STS2ClientStandardImpl);
+    public void getStsClientWithStaticCredentials() {
+        STS2Configuration configuration = new STS2Configuration();
+        configuration.setAccessKey("testAccessKey");
+        configuration.setSecretKey("testSecretKey");
+        configuration.setRegion("eu-west-1");
+        StsClient stsClient = STS2ClientFactory.getStsClient(configuration);
+        assertNotNull(stsClient);
+        stsClient.close();
     }
 
     @Test
-    public void getSTSOptimizedIAMClient() {
-        STS2Configuration sts2Configuration = new STS2Configuration();
-        sts2Configuration.setUseDefaultCredentialsProvider(true);
-        STS2InternalClient stsClient = 
STS2ClientFactory.getStsClient(sts2Configuration);
-        assertTrue(stsClient instanceof STS2ClientIAMOptimized);
+    public void getStsClientWithEndpointOverride() {
+        STS2Configuration configuration = new STS2Configuration();
+        configuration.setUseDefaultCredentialsProvider(true);
+        configuration.setRegion("eu-west-1");
+        configuration.setOverrideEndpoint(true);
+        configuration.setUriEndpointOverride("http://localhost:4566";);
+        StsClient stsClient = STS2ClientFactory.getStsClient(configuration);
+        assertNotNull(stsClient);
+        stsClient.close();
     }
 }

Reply via email to