How to Integrate Amazon S3 into Salesforce Uses of Named Credentials and checked the results Status=OK, StatusCode=200 after connected Amazon AWS S3 through the anonymous window in Salesforce | Integrate aws s3 using named credentials in Salesforce

2,379 views


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.

Note:: – You will get an email, so put correct email and mobile number and BEGIN YOUR JOURNEY from Today!
   

There are many steps to integrate Amazon S3 with Salesforce.

Final Output

aws integration with salesforce -- w3web.net

 

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.

Amazon S3 Sign Up -- w3web.net

Note:: – You will get an email, so put correct email and mobile number and BEGIN YOUR JOURNEY from Today!
 
 

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”

AWS My Security Credentials  -- w3web.net

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)

Download the excel aws -- w3web.net

AWS S# AWSSecretKey -- w3web.net

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.

Named Credentials in Salesforce -- w3web.net

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 ).

aws region -- w3web.net

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]

  1.     global class IntegrateAwsS3Ctrl {
  2.  
  3.     @AuraEnabled
  4.     global static void getAwsIntegrate() {        
  5.         HttpRequest req = NEW HttpRequest();
  6.         req.setEndpoint('callout:Integrate_AWS_S3/');
  7.         req.setTimeout(120000);
  8.         req.setMethod('GET');
  9.         req.setHeader('Content-Type','application/xml');
  10.         Http h = NEW Http();
  11.         HTTPResponse res = h.send(req);
  12.         System.debug('response:######' + res);    
  13.  
  14.         INTEGER StatusCode = INTEGER.valueof(res.getStatusCode());
  15.         String STATUS = String.valueof(res.getStatus());
  16.  
  17.         system.debug('getStatusCodeAAA ' + StatusCode);
  18.         system.debug('getStatusBBB ' + STATUS);
  19.     }
  20. }

Show result Status & StatusCode

Step 5:- Now you can see the below result along with Status=OK, StatusCode=200.

aws integration with salesforce -- w3web.net

 

Further post that would you like to learn in Salesforce

 

 

 

FAQ (Frequently Asked Questions)

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

 
Note:: – You will get an email, so put correct email and mobile number and BEGIN YOUR JOURNEY from Today!
 
 
  

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



Hi, This is Vijay Kumar behind the admin and founder of w3web.net. I am a senior software developer and working in MNC company from more than 8 years. I am great fan of technology, configuration, customization & development. Apart of this, I love to write about Blogging in spare time, Working on Mobile & Web application development, Salesforce lightning, Salesforce LWC and Salesforce Integration development in full time. [Read full bio] | | The Sitemap where you can find all published post on w3web.net

Leave a Comment