Hey guys, today in this post we are going to learn about How to Integrate Amazon S3 with Salesforce Step-By-Step.
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.
Named Credentials also include an OutboundNetworkConnection field that you can use to route callouts through a private connection. By separating the endpoint URL and authentication from the callout definition, named credentials make callouts easier to maintain. For example, if an endpoint URL changes, you update only the named credential. All callouts that reference the named credential simply continue to work. To know more about named credentials, go with Link
First we need create Named Credentials to integrate Amazon S3 for the Authentication.
There are many steps to integrate Amazon S3 with Salesforce.
Final Output
You can download file directly from github by Click Here.
- Find the below steps
Create Free Account on Amazon S3
Step 1:- First we need to Sign Up a personal account. Click here for create account. It is free not chargeable money, They will ask to verify your bank account detail for your verify Name as per your bank account.
Generate the AWSAccessKeyId & AWSSecretKey
Step 2:- Now you have created new account on amazonaws. After that login you credential and go to your username top right and Click on “My Security Credentials”
After that click on βMy Security Credentialβ to generate the AWSAccessKeyId & AWSSecretKey. After that we will get download excel file, where we got Key & Secret that will apply on during creating the Named Credential.
Download the excel file to get (AWSAccessKeyId & AWSSecretKey)
Create Named Credentials in Salesforce
Step 3:- Well done, Now you got AWSAccessKeyId & AWSSecretKey from Amazon AWS.
Then we need to create Named Credentials in Salesforce.
Login into Salesforce Application, navigate to Setup -> Named Credentials and then Click on New Named Credentials.
Provide the Label, Name (Auto populate), URL, Identity Type (Named Principal), AWS Access Key ID , AWS Secret Access Key, AWS Region and AWS Service.
Keep in minds some points during creating URL
- Scheme should be start always https://
- 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 )
- 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= ap-south-1.
- So you need to use value after ?region=, in the example value is ap-south-1
- For AWS S3 it will remain same as amazonaws.com/ ( Do not remove / from the URL ).
Now the value for URL field will look like :- https://s3.ap-south-1.amazonaws.com/
Create Apex Class Controller in Salesforce
From Developer Console β‘ File β‘ New β‘ Apex Class
Step 4:- To test the setup and configuration check It is working on not.
Open anonymous window in Salesforce and execute Apex Class Controller. IntegrateAwsS3Ctrl.getAwsIntegrate();
IntegrateAwsS3Ctrl.apxc [Apex Class Controller]
|
global class IntegrateAwsS3Ctrl {
@AuraEnabled
global static void getAwsIntegrate() {
HttpRequest req = NEW HttpRequest();
req.setEndpoint('callout:Integrate_AWS_S3/');
req.setTimeout(120000);
req.setMethod('GET');
req.setHeader('Content-Type','application/xml');
Http h = NEW Http();
HTTPResponse res = h.send(req);
System.debug('response:######' + res);
INTEGER StatusCode = INTEGER.valueof(res.getStatusCode());
String STATUS = String.valueof(res.getStatus());
system.debug('getStatusCodeAAA ' + StatusCode);
system.debug('getStatusBBB ' + STATUS);
}
}
Show result Status & StatusCode
Step 5:- Now you can see the below result along with Status=OK, StatusCode=200.
Further post that would you like to learn in Salesforce
What is Amazon S3 integration?
Amazon Simple Storage Service (Amazon S3) is built to store and retrieve any amount of data from anywhere for millions of applications and used by organizations across every industry.
How do I connect my S3 to API?
You need to launch the client and carry out authorization to create a pair of security credentials (keys). Add a bucket, for instance, apig-demo-5 to the Amazon S3 account in a specified region.
What is Amazon S3 bucket?
Amazon S3 buckets, which are similar to file folders, store objects, which consist of data and its descriptive metadata.
Related Topics | You May Also Like
Our Free Courses β
π Get Free Course β
π Salesforce Administrators π Salesforce Lightning Flow Builder π Salesforce Record Trigger Flow Builder |
π Get Free Course β
π Aura Lightning Framework π Lightning Web Component (LWC) π Rest APIs Integration |