Have you ever wondered how to achieve seamless integration between AWS and Salesforce?
Imagine a scenario where you're using AWS as your storage server but are now planning to migrate to Salesforce. However, due to certain limitations, directly switching storage platforms becomes complex — especially when it involves changes across multiple parts of your source code.
To address this challenge, a practical solution is to integrate AWS with Salesforce in such a way that whenever a file is uploaded to an AWS S3 bucket, it is automatically uploaded to Salesforce — without any manual intervention.
Prerequisites
- A Salesforce Org where files will be uploaded from AWS
- An AWS Account with proper permissions
Step 1: Set Up Salesforce Org
First, we need to set up our Salesforce org by creating a Connected App Follow the steps below:
- Go to Setup using the gear icon in the top right corner.
- In the Quick Find box, type App Manager.
- Click on App Manager, then click on the New Connected App button.
-
Fill in the required fields and check the checkbox "Enable OAuth Settings".
- For Callback URL, enter: https://login.salesforce.com/services/oauth2/success
- For Selected OAuth Scopes, choose: Full access (full)
-
Also, check the box "Enable Client Credentials Flow"
-
Click Save to create the app
- After saving, click on Manage Consumer Details and copy the Consumer Key and Consumer Secret — you will use these in your code later.
- In the Quick Find box, type OAuth, then click on OAuth and OpenID Connect Settings.
-
Turn on the toggle for Allow OAuth Username-Password Flows.
- Click on your profile icon and go to Settings.
- In the Quick Find box, type Reset, then click on Reset My Security Token.
- Click the Reset Security Token button — the token will be sent to your registered email.
Step 2: Set Up Lambda Function in AWS Account
Now, let’s create a Lambda function in your AWS account. Follow the steps below:
- Log in to your AWS Console and type Lambda in the search bar.
- Select Lambda, then click on the Create Function button.
-
Fill in the basic information, and set the Runtime according to your code requirements. (For this example, we’ll use Python 3.13)
- Click on Create Function.
Once the function is created: - You’ll be taken to the function overview screen. Click on the Configuration tab below.
-
Navigate to the Permissions section and click on your Role Name.
-
Click on the Add Permissions dropdown and select Attach Policies.
- In the Policy search bar, type S3 and select the checkbox for AmazonS3FullAccess.
- Click on Add Permissions to apply the policy.
Now, return to your Lambda function: - Go to the Code tab.
- Click on Upload from → select .zip file.
- Upload your code as a .zip file that includes all required libraries for execution.
Step 3: Set Up an Event Notification for Your S3 Bucket
Now, let’s configure an event notification for your S3 bucket to automatically trigger the Lambda function whenever a new file is uploaded.
Follow the steps below:
- Go to the S3 bucket from which you want to send files to Salesforce.
- Click on the Properties tab.
- Scroll down to the Event Notifications section.
- Click on the Create Event Notification button.
- Provide a suitable Event Name.
- Under Event Types, select All object to create events.
- In the Destination section, choose the Lambda function.
-
Under Specify Lambda function, select the Lambda function you created earlier.
- Click on Save Changes.
Conclusion
By integrating AWS S3 with Salesforce using Lambda and REST APIs, we can ensure seamless file synchronization without any manual effort. This setup not only saves development time but also makes the migration or hybrid storage approach more efficient and scalable.
Got questions? Feel free to drop an email to support@astreait.com