![](https://www.infallibletechie.com/wp-content/uploads/2022/11/Salesforce-SOQL-from-AWS-InvokeSalesforceRestApiFunction-Lambda-function-in-the-AWS-Console-1024x576.jpg)
Pre-requisites:
1. Install OpenSSL to generate certificate.
2. Run the below command from MS Command in Windows or Terminal from Mac OS to generate server.pass.key file.
openssl genrsa -des3 -passout pass:SomePassword -out server.pass.key 2048
3. Run the below command from MS Command in Windows or Terminal from Mac OS to generate server.key file.
openssl rsa -passin pass:SomePassword -in server.pass.key -out server.key
4. Run the below command from MS Command in Windows or Terminal from Mac OS to generate server.csr file.
openssl req -new -key server.key -out server.csr
5. Run the below command from MS Command in Windows or Terminal from Mac OS to generate server.crt file.
openssl x509 -req -sha256 -days 365 -in server.csr -signkey server.key -out server.crt
![](https://www.infallibletechie.com/wp-content/uploads/2022/11/OpenSSL-Certificate.jpg)
6. Create a Connected App in Salesforce. Enable “Use digital signatures” and use the certificate created.
![](https://www.infallibletechie.com/wp-content/uploads/2022/11/Salesforce-Connected-App-for-AWS-Lambda.jpg)
Callback URL should be http://localhost:1717/OauthRedirect.
![](https://www.infallibletechie.com/wp-content/uploads/2022/11/Connected-App-Salesforce-AWS-Lambda.jpg)
7. Go to AWS Console. Go to Lambda –> Functions –> {Your contact center name}-InvokeSalesforceRestApiFunction.
8. Go to Configuration and select the Environment Variables. Update the Environment as following. Use your My Domain URL.
![](https://www.infallibletechie.com/wp-content/uploads/2022/11/AWS-Lambda-Environment-Varilables-1024x715.jpg)
ACCESS_TOKEN_PARAM_NAME is InfallibleTechVoice-salesforce-rest-api-access-token
AUDIENCE is InfallibleTechVoice-salesforce-rest-api-audience
CONSUMER_KEY_PARAM_NAME is InfallibleTechVoice-salesforce-rest-api-auth-consumer-key
PRIVATE_KEY_PARAM_NAME is InfallibleTechVoice-salesforce-rest-api-auth-private-key
SALESFORCE_AUTH_ENDPOINT is https://infalliblescv.my.salesforce.com/services/oauth2/token
SALESFORCE_REST_API_ENDPOINT_BASE is https://infalliblescv.my.salesforce.com/services/data/v54.0
SUBJECT is InfallibleTechVoice-salesforce-rest-api-subject
Here InfallibleTechVoice is my Contact Center Name and infalliblescv.my.salesforce.com is my Salesforce My Domain URL.
9. Go to AWS System Manager. Select Parameter Store.
![](https://www.infallibletechie.com/wp-content/uploads/2022/11/Amazon-AWS-System-Manager.jpg)
10. Update the values in the Parameter Store.
InfallibleTechVoice-salesforce-rest-api-access-token – Leave it with the default value generated or make it blank.
InfallibleTechVoice-salesforce-rest-api-audience is https://login.salesforce.com/.
InfallibleTechVoice-salesforce-rest-api-auth-consumer-key is Consumer Key from the Salesforce Connected App.
InfallibleTechVoice-salesforce-rest-api-auth-private-key – Value in the server.key file. Please include all the content of the file. Don’t ignore the first and last lines too.
![](https://www.infallibletechie.com/wp-content/uploads/2022/11/Salesforce-REST-API-Private-Key-for-AWS-Lambda-1024x601.jpg)
InfallibleTechVoice-salesforce-rest-api-subject – [email protected].
Here, [email protected] is my Salesforce Username.
11. Test the Lambda.
![](https://www.infallibletechie.com/wp-content/uploads/2022/11/Test-the-AWS-Lambda.jpg)
Payload:
{
"Details": {
"Parameters": {
"methodName": "queryRecord",
"soql": "SELECT Id FROM Case WHERE ContactPhone = '+14155551234' AND IsClosed = false"
}
}
}
Output:
![](https://www.infallibletechie.com/wp-content/uploads/2022/11/Test-the-AWS-Lambda-Result.jpg)