Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (5.6k points)
As per the documentation it says, you need a shared credentials file in the home directory but it's not working for production. So How can I specify the AWS key while sending an email?

1 Answer

0 votes
by (12.4k points)

If you are working with EC2 or AWS Lambda or maybe any AWS IAM supported service, the secure way is to go with creating a role that has access to SES and attach it to the resource. You can give it within your program:

AWSCredentialsProvider credentialsProvider = new AWSCredentialsProvider() {

    @Override

    public void refresh() {}

        @Override

        public AWSCredentials getCredentials() {

        return new AWSCredentials() {

            @Override

            public String getAWSSecretKey() {

                return "YOUR_SECRET_KEY";

            }

            @Override

            public String getAWSAccessKeyId() {

                return "YOUR_ACCESS_KEY";

            }

        };

    }

};

AmazonSimpleEmailService client = AmazonSimpleEmailServiceClientBuilder.standard()

            .withCredentials(credentialsProvider).build();

 Learn more about AWS by going through AWS Online training and master this technology.

Related questions

0 votes
1 answer

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer

Browse Categories

...