Integrating Salesforce with AWS Using AWS IAM Roles Anywhere and Private CA
Source: Dev.to
Overview
| Component | Purpose |
|---|---|
| Salesforce Certificate & Key Management | Create a self‑signed certificate that will be uploaded to AWS. |
| AWS Certificate Manager Private CA | Issue a certificate signed by a private root CA. |
| IAM Roles Anywhere | Trust the private CA, create a trust anchor, profile, and role that Salesforce can assume. |
| Salesforce External Credential & Named Credential | Configure AWS Signature V4 authentication using the role created above. |
Step‑by‑Step Instructions
1️⃣ Create a Self‑Signed Certificate in Salesforce
- In Setup, search for Certificate & Key Management.
- Click Create Self‑Signed Certificate.
- Provide a Label and a unique Name, then Save.
- Download the generated certificate as
cert.pemand store it securely.
2️⃣ Set Up a Private Root CA in AWS ACM‑PCA
- Open the AWS Certificate Manager (ACM) Private CA console.
- Choose Create CA → Mode: General‑Purpose → CA Type: Root.
- Fill in the required details and select RSA 2048 for the key algorithm.
- Review the settings and click Create CA.
After creation – under Actions, select Install CA certificate to activate the CA.
Verify the CA status changes from Pending Certificate → Active.
3️⃣ Issue a Certificate Signed by the Private Root CA
# Issue a certificate (replace placeholders)
aws acm-pca issue-certificate \
--certificate-authority-arn "" \
--csr fileb://crt.pem \
--signing-algorithm "SHA256WITHRSA" \
--validity Value=365,Type="DAYS" \
--region "us-east-1"
- Copy the CertificateArn from the command output.
- Retrieve the signed certificate:
aws acm-pca get-certificate \
--certificate-authority-arn "" \
--certificate-arn ""
- Save the returned PEM content to a file named
cert.crt.- Ensure each line (except the header/footer) contains exactly 64 characters.
- Include the
-----BEGIN CERTIFICATE-----and-----END CERTIFICATE-----lines.
4️⃣ Upload the Signed Certificate to Salesforce
- In Setup → Certificate & Key Management, click Upload Certificate.
- Choose the
cert.crtfile created in the previous step and Save.
5️⃣ Create a Trust Anchor in IAM Roles Anywhere
- Open IAM Roles Anywhere in the AWS console.
- Click Create Trust Anchor.
- Provide a name, select the Private CA created in Step 2, and click Create Trust Anchor.
6️⃣ Create an IAM Role with a Trust Policy
Trust Policy (JSON)
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "rolesanywhere.amazonaws.com"
},
"Action": [
"sts:AssumeRole",
"sts:TagSession",
"sts:SetSourceIdentity"
]
}
]
}
- In the IAM console, create a new role and paste the trust policy above.
- Attach the AmazonConnect_FullAccess policy (or a custom policy with the required permissions).
7️⃣ Create a Profile in IAM Roles Anywhere
- In IAM Roles Anywhere, click Create Profile.
- Enter a profile name, attach the role created in Step 6, and click Create Profile.
8️⃣ Configure Salesforce External Credential
- Setup → Named Credentials → External Credentials → New.
| Field | Value |
|---|---|
| Label | AWS IAM Anywhere Credential |
| Name | AWS_IAM_Anywhere_Credential |
| Authentication Protocol | AWS Signature V4 |
| Service | sts (will change to connect later) |
| Region | us-east-1 |
| AWS Account ID | (optional) |
| Obtain Temporary IAM Credentials via STS | Roles Anywhere |
| Trust Anchor ARN | ARN from Step 5 |
| Profile ARN | ARN from Step 7 |
| Signing Certificate | Upload the same certificate used in Step 4 |
| STS Duration (seconds) | 3600 |
- Create a New Principal for the external credential:
| Field | Value |
|---|---|
| Name | connect_principal (example) |
| ARN | ARN of the IAM role from Step 6 |
| Character set | [a-zA-Z0-9_+=,.@-]* |
- Save the external credential.
9️⃣ Create a Named Credential
- Setup → Named Credentials → New Named Credential.
| Field | Value |
|---|---|
| Label | Connect API Connection |
| Name | Connect_API_Connection |
| URL | https://sts.us-east-1.amazonaws.com (will be updated later) |
| External Credential | Select the external credential created above |
| Generate Authorization Header | Checked |
🔟 Grant Permission to the Principal
- Setup → Permission Sets → New.
- Provide a label (e.g.,
AWS_RolesAnywhere_Access). - In the permission set, go to External Credential Principal Access and move
connect_principalto the Enabled column. - Assign the permission set to the appropriate Salesforce users.
1️⃣1️⃣ Test the Integration (STS Call)
Open Developer Console → Execute Anonymous and run:
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:Connect_API_Connection/?Action=GetCallerIdentity&Version=2011-06-15');
req.setMethod('GET');
Http http = new Http();
HTTPResponse res = http.send(req);
System.debug(res.getBody());
Check the debug log: a 200 status code indicates a successful STS GetCallerIdentity call.
1️⃣2️⃣ Switch the Named Credential to Amazon Connect
- Edit the Named Credential (
Connect_API_Connection). - Change Service from
sts→connect. - Update URL to
https://connect.us-east-1.amazonaws.com.
Test the Connect Call
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:Connect_API_Connection/?Action=ListInstances&Version=2017-08-08');
req.setMethod('GET');
Http http = new Http();
HTTPResponse res = http.send(req);
System.debug(res.getBody());
A successful response confirms that Salesforce can now call Amazon Connect using IAM Roles Anywhere.
🎉 All Done!
You now have a certificate‑based, key‑less integration between Salesforce and AWS, leveraging IAM Roles Anywhere and a private CA for secure, temporary credential issuance.
References
// APN_API_Connection is the name of the named credential
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:Connect_API_Connection/?Action=GetCallerIdentity&Version=2011-06-15');
req.setMethod('GET');
Http http = new Http();
HttpResponse res = http.send(req);
System.debug(res.getBody());
Note: Open the log file to see the status.
If successful, the log will show a 200 status code along with the returned attributes, indicating a successful Amazon Connect API call from AWS.
Similar to Amazon Connect, you can configure this approach with any service that supports HTTP callouts.