I am using the below code to fetch AWS credentials to connect to SQS. This is my personal credential and when I deploy this code in my qa or prod env , I shouldn't be using my credentials to connect to SQS. This code will be running in a EC2 container in AWS. What are the options available for me to connect to SQS without having to explicitly provide the user id / password like I have done below?
@Bean
public AWSCredentialsProvider awsCredentialsProvider() {
ProfileCredentialsProvider profileCredentialsProvider = new ProfileCredentialsProvider(credentialsProvider);
try {
profileCredentialsProvider.getCredentials();
} catch (Exception e) {
throw new AmazonClientException(
"Cannot load the credentials from the credential profiles file. " +
"Please make sure that your credentials file is at the correct " +
"location (~/.aws/credentials), and is in valid format.",
e);
}
return profileCredentialsProvider;
}
The AWS SDK will automatically retrieve credentials from the Instance Metadata. There is no need to provide any credentials.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.