I know how to read AWS credentials (for one environment) through application properties. I need to create multiple amazonSnsClient() through application properties on application startup.
I have an application properties file that has AWS properties of multiple environments in one file which looks like below example
#DEV
abc.env[0].aws.accessKeyId=xaw
abc.env[0].aws.awsSecretKeyId=yrt
#TEST
abc.env[1].aws.accessKeyId=abc
abc.env[1].aws.awsSecretKeyId=def
I will have a HashMap that will contain all the AWS credentials from a properties file.
I need to read all the AWS Credentials from a properties file and create that many amazonSnsClient How can I achieve the same in Spring boot? Is there any annotation that I can make use of?
Note: The requirement is that the properties of Dev and Test have to be in one file
Can someone please help?
Thank you for your time.
CodePudding user response:
You create the client manually like this ...
var client = SnsClient.builder()
.region(Region.of(awsProperties.getRegion()))
.withCredentials(... add your credentials here)
.build();
// use client methods to interact with AWS