This app demonstrates how to pull data from Salesforce via REST API and drop it into an AWS RDS database on a schedule. It is pre-configured to pull Salesforce Account objects.
Use the Terraform found in the infrastructure
folder to spin up the DB for this app, and deploy this app as a Docker container to AWS ECS.
You will need a database to run this app as it will drop all Salesforce record fetched into it. If you plan on using AWS RDS, this repo contains Terraform in the infrastructure/database
folder that you can use to spin up an instance.
- To authorize your app to the Salesforce API, you will need to generate a digital certificate that you will upload to the Salesforce connected app and sign the JWT using the certificates private key.
- Setup a Salesforce connected app
- Enable
Enable OAuth Settings
- Enable
Enable for Device Flow
(will auto assign callback URL which you don't need for this type of app) - Enable
Use Digital Signatures
- Upload certificate created in previous step
- Add
Selected OAuth Scopes
- After save:
- Go to App Manager >> [App Name] >> Manage
- Click
Edit Policies
- Change
Permitted Users
toAdmin approved users are pre-authorized
- Save
- On the app management page, scroll down to the
Profiles
section and add the profiles that are allowed to access the app
- Enable
This app requires the following configuration variables that you can either pass in via environment variables or by adding a secrets.json
file with the variables included to the project:
ConnectionStrings:default
- Default DB connection stringSalesforce:ApiVersion
- Salesforce API version to use (default is 51.0)Salesforce:ClientId
- Salesforce connected app client IdSalesforce:User
- Salesforce usernameSalesforce:AuthKey
- Salesforce connected app OAuth certificate private key encoded as a base 64 string (you can use an online tool to base 64 encode the private key, or runbase64 <privatekey>
from a bash shell)
All configuration to spin up a database is in src/SalesforceDataCollector/Migrations
. When dealing with a new database, just run the Update-Database
from the Package Manager Console to apply the migrations to a new database on your server.
During development, if you need to quickly test this service against a large data-set, you can use mockaroo.com to create a randomized CSV file and then use dataloader.io or the Salesforce workbench to load all of the data at once into your developer account.