Our legacy java web application runs on aws elastic beanstalk, which assumes IAM role to access SES. Today after upgrading elastic beanstalk environment from Tomcat 7 to Tomcat 8 and spring libraries from 3.2.1 to 4.0.0, SES client has stopped working. Below is code which was working fine until yesterday to send out emails:
AmazonSimpleEmailService client = AmazonSimpleEmailServiceClientBuilder.standard()
.withCredentials(com.amazonaws.auth.DefaultAWSCredentialsProviderChain.getInstance())
.withRegion(Regions.US_EAST_1).build();
It is throwing following exception
SEVERE [http-nio-8080-exec-8] The email was not sent.
com.amazonaws.SdkClientException: Unable to load AWS credentials from any provider in the chain: [EnvironmentVariableCredentialsProvider: Unable to load AWS credentials from environment variables (AWS_ACCESS_KEY_ID (or AWS_ACCESS_KEY) and AWS_SECRET_KEY (or AWS_SECRET_ACCESS_KEY)), SystemPropertiesCredentialsProvider: Unable to load AWS credentials from Java system properties (aws.accessKeyId and aws.secretKey), com.amazonaws.auth.profile.ProfileCredentialsProvider@79fc4ef8: profile file cannot be null, com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper@33e618b9: Unauthorized (Service: null; Status Code: 401; Error Code: null; Request ID: null)]
I have tried adding AWS_ACCESS_KEY_ID and AWS_SECRET_KEY as environment variables as well but it didn't work. Searched web, checked aws docs but without anyluck.
I resolved this by upgrading to the latest AWS SDK version.