Replacing Access Keys Outside AWS with IAM Roles Anywhere
This lesson explains how IAM Roles Anywhere lets servers and applications outside AWS obtain temporary credentials by presenting X.509 certificates, instead of using long-term access keys that leak and are rarely rotated.
Learning outcomes
After completing this lesson, you will be able to:
- Configure a trust anchor, profile and role.
- Explain how trust policy conditions restrict which certificates are accepted.
- Choose Roles Anywhere among the mechanisms for temporary credentials.
Configuration
Workloads that run outside AWS, such as on-premises servers, often authenticate with long-term IAM access keys, which can leak and must be rotated by hand. IAM Roles Anywhere removes the need for those keys: the workload presents an X.509 certificate issued by a certificate authority (CA) that the account trusts, and receives temporary credentials for an IAM role, exactly as an EC2 instance does with its instance profile. The following list describes how Roles Anywhere is configured.
-
Create a trust anchor
Reference AWS Private CA or your own CA certificate.
-
Create profiles
Name the roles that can be assumed, with optional session policies.
-
Trust the service
Allow
rolesanywhere.amazonaws.comin each role's trust policy.
The credential helper integrates with the AWS SDKs and CLI through credential_process.
Setting up Roles Anywhere
Restricting which certificates are accepted
A trust anchor trusts every certificate its CA issues, which may include certificates for many servers and users. Without further restrictions, any holder of such a certificate could assume every role in the profiles. Roles should therefore accept only specific certificates, and the impact of a stolen certificate should be limited. The following list describes the controls.
- Trust policy conditions on certificate attributes, such as the subject common name, so only a specific server can assume a role.
- Certificate revocation lists imported into Roles Anywhere.
- Short-lived certificates, which limit the impact of a stolen key.
- Session policies in the profile, which cap permissions further.
The following diagram follows the server's certificate to temporary credentials.

Narrowing which certificates work
Where Roles Anywhere fits
Several mechanisms provide temporary credentials, and the right one depends on where the workload runs and what identity it already has. Roles Anywhere suits servers and applications outside AWS that can store a certificate and private key securely, ideally in a hardware security module or a trusted platform module. CI/CD systems that issue OpenID Connect (OIDC) tokens, such as GitHub Actions, use OIDC federation with AssumeRoleWithWebIdentity instead, which needs no certificates. Workloads running on AWS use IAM roles directly through instance profiles, task roles or execution roles. Long-term access keys should be the last resort in every case.
Which credential mechanism?
Giving an on-premises server AWS credentials without keys
A reporting server in the data centre uploads files to S3 nightly using an access key that is years old. IAM Roles Anywhere replaces the key with a certificate issued by the company's private CA:
aws rolesanywhere create-trust-anchor --name corp-ca --enabled \
--source 'sourceType=AWS_ACM_PCA,sourceData={acmPcaArn=arn:aws:acm-pca:eu-west-1:111111111111:certificate-authority/1a2b}'
aws rolesanywhere create-profile --name report-uploader --enabled \
--role-arns arn:aws:iam::111111111111:role/ReportUploader --duration-seconds 3600
# ~/.aws/config on the server
[profile reports]
credential_process = aws_signing_helper credential-process \
--certificate /etc/pki/report-server.pem --private-key /etc/pki/report-server.key \
--trust-anchor-arn arn:aws:rolesanywhere:eu-west-1:111111111111:trust-anchor/ta-id \
--profile-arn arn:aws:rolesanywhere:eu-west-1:111111111111:profile/pr-id \
--role-arn arn:aws:iam::111111111111:role/ReportUploaderThe role's trust policy allows rolesanywhere.amazonaws.com and requires the certificate's subject common name to match the server, so a certificate issued to another machine cannot assume it. The old access key is then deactivated and deleted.
What does IAM Roles Anywhere trust instead of access keys?
Show answer
Certificates issued by a configured trust anchor.
Exam Tips
Remember for the exam
- To replace access keys on on-premises servers, use IAM Roles Anywhere.
- Roles Anywhere trusts certificates from a configured trust anchor.
- Restrict roles by certificate attributes in the trust policy.
- Import revocation lists to reject compromised certificates.
- CI/CD systems with OIDC tokens use OIDC federation rather than Roles Anywhere.