Salesforce and AWS Integration made easy via Named Credentials!!
Hi, very happy to see you here! 😀
Before we start, I would like to thank Tim Peng for helping me out with some technicalities on this one.
In this article, I will be sharing a great news for all the devs who have, or in future might be in the working, on any Salesforce and AWS integration.
Sending request to AWS is tricky, at least to me they are, especially when creating the signature version.
Well, you are in for a treat today. In Summer 19 release, Salesforce released a feature that now allows you to choose AWS Signature Version 4 as the Authentication protocol while creating a Named credential. What this means is you no longer have to create and send the signature version to along with your HTTP requests. The Named Credential will do it all!
Let’s see how that is going to look like in Apex.
So the first step is to create a Named Credential inside Salesforce.

Please make sure you use the Access ID and Key of the connected app that you have created in your AWS account. Also, remember to put the correct AWS region according to your account. After updating the correct values, please ensure to check the “Generate Authorization Header” checkbox.
Now use this Named Credential in your Http requests. So this is how your request should look like:
HttpRequest req = new HttpRequest();req.setEndpoint('callout:AWS/?Action=DescribeImages&Owner.1=368772107083&Version=2016-11-15');req.setMethod('GET');System.debug(req.getBody());Http http = new Http();HTTPResponse res = http.send(req);system.debug(res.getStatusCode());System.debug(res.getBody());
Here ‘368772107083’ is the Id of the owner/user.
I also wrote an article on “AWS and Salesforce integration using AWS Signature Version 1“. While comparing the code, first thing you is notice that with the Named Credentials a lot of code is reduced. In addition, you do not have to worry about the authorization which used to be a pain!
That brings us to the end of this article! Thank you for being an awesome reader! Subscribe to this blog for receiving all the latest updates straight to your inbox. 🙂

.png)




Comments