I am using below code to publish message to SNS.
AmazonSNSclient snsClient=null;
snsClient=AmazonSNSClientBuilder.standard.withRegion("us-east-2").build();
snsClient.publish(topicAr,"Sample SNS Message");
This code is inside a java servlet and it's war is deployed using docker on EC2 instance. The issue is docker is unable to pick the IAM role from Ec2 instance hence failing to publish a message to SNS
Background: When I am running the above code via EC2 instance terminal, I am able to publish message. But When I am putting this code in java servlet based application and deploying the war of it on Docker, It is not able to publish the message because it is not getting IAM role.
Error message is in the screen short.