How can I prevent Spring Cloud AWS from automatically picking up AWS credentials from the default credentials file (~/.aws/credentials) when the application is executed by others on their computers, without their knowledge that it might use these credentials by default?
Upon reviewing the Spring Cloud AWS documentation at https://docs.awspring.io/spring-cloud-aws/docs/3.0.0/reference/html/index.html#credentials, it appears that the only solution is to supply our own AwsCredentials and Region to override the default behavior. Below is the code snippet I have implemented for this purpose:
@Configuration
public class AwsProviderConfiguration {
@Value("${spring.cloud.aws.credentials.access-key}")
private String awsAccessKeyId;
@Value("${spring.cloud.aws.credentials.secret-key}")
private String awsSecretAccessKey;
@Value("${spring.cloud.aws.region.static}")
private String awsRegion;
@Bean
public AwsCredentialsProvider customAwsCredentialsProvider() {
return StaticCredentialsProvider.create(AwsBasicCredentials.create(awsAccessKeyId, awsSecretAccessKey));
}
@Bean
public AwsRegionProvider customRegionProvider() {
return () -> Region.of(awsRegion);
}
}
Despite implementing this solution, I still observe logs indicating that the application is attempting to read profiles from the credentials file. The relevant log entries are as follows:
2024-01-28T11:45:54.746-07:00 INFO 54870 --- [app] [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 4 ms. Found 0 JDBC repository interfaces.
2024-01-28T11:45:54.869-07:00 WARN 54870 --- [app] [ main] s.a.a.p.internal.ProfileFileReader : Ignoring profile 'xxxxxxxxxx' on line 1 because it did not start with 'profile ' and it was not 'default'.
2024-01-28T11:45:55.103-07:00 WARN 54870 --- [app] [ main] s.a.a.p.internal.ProfileFileReader : Ignoring profile 'xxxxxxxxxx' on line 1 because it did not start with 'profile ' and it was not 'default'.
2024-01-28T11:45:55.103-07:00 WARN 54870 --- [app] [ main] s.a.a.p.internal.ProfileFileReader : Ignoring profile 'xxxxxxxxxx' on line 1 because it did not start with 'profile ' and it was not 'default'.
2024-01-28T11:45:55.104-07:00 WARN 54870 --- [app] [ main] s.a.a.p.internal.ProfileFileReader : Ignoring profile 'xxxxxxxxxx' on line 1 because it did not start with 'profile ' and it was not 'default'.
2024-01-28T11:45:55.105-07:00 WARN 54870 --- [app] [ main] s.a.a.p.internal.ProfileFileReader : Ignoring profile 'xxxxxxxxxx' on line 1 because it did not start with 'profile ' and it was not 'default'.
Could someone please advise on how to completely disable the auto-configuration of Spring Cloud AWS and ensure that it does not attempt to use credentials?