I am trying to use spring config server with cross account as I am deploying config server in kubernetise with aws backed. but due to DefaultAWSCredentialsProviderChain I am unable to get connected to s3 bucket and gets 403 error.
In DefaultAWSCredentialsProviderChain as per logs WebIdentityTokenCredentialsProvider try to get credentials get 403 error.
but when I am try to connect with my awss3 client with STSAssumeRoleSessionCredentialsProvider it gets connect.
Is there any way so that I can provide STSAssumeRoleSessionCredentialsProvider instead of DefaultAWSCredentialsProviderChain
Comment From: ryanjbaxter
Can you try providing your own bean of type AwsS3EnvironmentRepositoryFactory
. You would have the override the build
method and customize the AmazonS3
client.
You will probably have to mark your bean with @Primary
.
Let me know if that works.
Comment From: digambar1912
Hi Ryan,
I have tried way you mention, But getting BeanDefinitionOverrideException
invalid bean defination with name ' define awsS3EnvironmentRepositoryFactory' define in classpath resource [org/springframework/cloud/config/server/config/EnvironmentRepositoryConfiguration$AwsS3FactoryConfig ] cannot register bean defination for bean my Bean
My implementaion
@Primary
@configuration
public class AwsS3EnvironmentRepositoryFactory
implements EnvironmentRepositoryFactory<AwsS3EnvironmentRepository, AwsS3EnvironmentProperties> {
final private ConfigServerProperties server;
@Autowired
AmazonS3 amazonS3Client;
public AwsS3EnvironmentRepositoryFactory(ConfigServerProperties server) {
this.server = server;
}
@Override
public AwsS3EnvironmentRepository build(AwsS3EnvironmentProperties environmentProperties) {
AwsS3EnvironmentRepository repository = new AwsS3EnvironmentRepository(amazonS3Client,
environmentProperties.getBucket(), server);
repository.setOrder(environmentProperties.getOrder());
return repository;
}
}
Comment From: ryanjbaxter
Something doesn't seem right, can you provide a complete sample?
Comment From: digambar1912
If I try to get object from s3 bucket with amazonS3Client
and assume role it works , only when I am using config server it is giving issue.
Below is complete implementation for AwsS3EnvironmentRepositoryFactory
@primary
@configuration
public class AwsS3EnvironmentRepositoryFactory
implements EnvironmentRepositoryFactory<AwsS3EnvironmentRepository, AwsS3EnvironmentProperties> {
final private ConfigServerProperties server;
@Autowired
AmazonS3 amazonS3Client;
public AwsS3EnvironmentRepositoryFactory(ConfigServerProperties server) {
this.server = server;
}
@Override
public AwsS3EnvironmentRepository build(AwsS3EnvironmentProperties environmentProperties) {
AwsS3EnvironmentRepository repository = new AwsS3EnvironmentRepository( amazonS3Client,
environmentProperties.getBucket(), server);
repository.setOrder(environmentProperties.getOrder());
return repository;
}
}
Comment From: ryanjbaxter
I need a working project please
Comment From: spring-cloud-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-cloud-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.