Dear Trailblazers,
In this blog post, we will learn how we can integrate Salesforce with Amazon S3 within 15 minutes. Yes, you read it correctly we will be able to integrate it within 15 minutes. Let’s start
Named Credentials
Before we start let’s talk about named credentials as we are going to use named credentials for the authentication.
A named credential specifies the URL of a callout endpoint and its required authentication parameters in one definition. Salesforce manages all authentication for Apex callouts that specify a named credential as the callout endpoint so that your code doesn’t have to. You can also skip remote site settings, which are otherwise required for callouts to external sites, for the site defined in the named credential. To learn more Click Here
Step1 – Get AWS Access Key ID & AWS Secret Access Key
Login into Amazon S3 Console using This URL then Click on your name on the Top right and the Click on “My Security Credentials“

Then Click on Access Keys & Click on Generate Access Key to generate the Key & Secret File. Download the Key file or Copy and paste the Key and Secret file and we are going to use these in next step.


Step 2 Create Named Credentials in Salesforce
Login into Salesforce Application, navigate to Setup -> Named Credentials and then Click on New Named Credentials
Provide Label and it will populate the Name automatically. And for the URL, the value should be combination of
scheme (https://) + instance name ( s3 ) + region name ( us-east-1 ) +amazonaws.com/
#1 – scheme will always be https://
#3 – As we are connecting with Amazon S3, so instance name will be s3. If you wanted to connect with EC2 then instance name will be ec2 ( all in small )
#3 – region name, you need to provide the region name here. To get the region name go back to Amazon S3 Console and in the URL you will get something like ?region=us-east-1 . So you need to use value after ?region=, in the example value is us-east-1

#4 – For AWS S3 it will remain same as amazonaws.com/ ( Do not remove / from the URL ) and it will keep changing based on the instance that you are trying to connect.
Now the value for URL field will look like below ( Considering above scenario )
https://s3.us-east-1.amazonaws.com/
For Identity select Named Principal from Dropdown, Provde AWS Key value and Secret value from that file that you downloaded from the Step 1.
For AWS Region, provide the value of the region and for AWS Service provide s3. Verify from the below image

Step3 – Test the Setup
To test the setup and check if this is working on not. We will try to get the list of Buckets from our AWS S3 Instance.
Execute below code from Developer Console.
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:AWS_S3');
req.setMethod('GET');
req.setHeader('Content-Type','application/xml');
Http http = new Http();
HTTPResponse res = http.send(req);
System.debug(res.getBody());
System.debug(res.getStatusCode());
System.debug(res.getStatus());
You will see the result like below along with Status Code as 200

And Boom, you have connected Amazon AWS S3 with Salesforce.
If you have any questions or any feedback please share with us.
#KeepSharing #KeepLearning
Resources
12 comments
Can I know more about Put / data pull from salesforce in S3?
Let me know what you wanted to know?
Do you have any sample class that allows you to copy a text file from S3 to Salesforce.com files?
Hi Joseph,
I am working on it. I will post the same over here.
Besides setting up the Name Credentials, what about Private Connect? does it need to set up also to integrate Salesforce with S3? we are using s3 for community cloud.
Hi Harry,
You can give it a try but I have not implemented a private connect.
Hi Amit, My requirement is to replicate the Salesforce database into the AWS. So if I want to post the Account record to S3, what should I need to create in the s3. A table as similar as Account in SF? Can you share the high level idea that would be really helpful. Thanks!
You need to ask your business where they wanted to store the data and in which format as there is no concept of the table in AWS S3.
Hi , My requirement is upload large files Salesforce to aws using apis. Please help me on this.
What sort of help are you looking from me?
I am looking gor aws s3 mulitipart api Integration with salefore for uploading files in s3 bucket. If you created any blog please share with me.
I did not create any blog for this.