Add a Heroku Collaborator
Access a Heroku data store from within your function by adding a Heroku user as a collaborator to your function's compute environment. Add a collaborator using the sf env compute collaborator add
command with the Heroku user's email.
Make sure you're logged into Salesforce Functions, then run:
Using sf env compute collaborator
triggers an email to the Heroku user letting them know you've added them as a collaborator. After running this command, the Heroku user can then attach your function's compute environment to a data store as an add-on using the Heroku CLI.
Use sf env list
to get a list of compute environments and retrieve the name of your compute environment:
Example output:
Find the compute environment for your org and provide its name to your collaborator.
Skip to the next step if you have an existing data add-on.
Create the Heroku data add-on that best fits your needs:
- Heroku Postgres is a reliable, robust, and scalable database, managed by Heroku. You can connect any Postgres database running in Heroku's Common Runtime, for example Standard and Premium Postgres plans. In addition, you can sync data from your Salesforce org to Heroku Postgres via Heroku Connect. See the Heroku Dev Center for instructions on creating a Heroku Postgres or Heroku Connect add-on.
- Heroku Data for Redis is Heroku’s managed key-value store as a service. Redis is commonly used for caching and background job queues. See the Heroku Dev Center for instructions on creating a Heroku Redis Add-on.
- Apache Kafka is a distributed commit log for fast, fault-tolerant communication between producers and consumers using message-based topics. Kafka provides a messaging backbone and can handle billions of events and millions of transactions." See the Heroku Dev Center for instructions on creating an Apache Kafka on Heroku Add-On.
- Heroku Connect is an add-on that provides a data synchronization service between Salesforce and Heroku Postgres databases. See the Heroku Dev Center for instructions on creating a Heroku Connect Add-On.
Add your Heroku Data add-on to your compute environment with its unique name.
Use heroku addons:info <type of add-on> -a <compute-environment-name>
to find the unique name for your add-on. Use heroku-postgresql
to find the unique name for a Heroku postgres instance.
For <type of add-on>
, use heroku-postgresql
, heroku-redis
, or heroku-kafka
for your Heroku Postgres, Heroku Redis, Apache Kafka on Heroku instance, respectively.
Use this unique name to connect your add-on to your compute environment.
Run heroku addons:attach
to attach the add-on to the environment:
For more information about attaching and detaching add-ons, see Managing Add-ons in the Heroku Dev Center.