Workloads that run in AWS get credentials from an IAM role. A server in your own data center has no role, so the usual workaround is an IAM user whose access key is copied onto the server. That key never expires, works from any network and is rarely rotated. Anyone who can read the file can use it.
IAM Roles Anywhere lets a server outside AWS trade an X.509 certificate from your own certificate authority (CA) for temporary AWS credentials. The only long-lived secret left is the certificate's private key, which you can hold in a TPM or mark non-exportable. It is the same idea as Managed Identities in Azure and OIDC in your pipelines, for servers you host yourself.
Northwind's integration service signs in as an IAM user. Its access key is saved in C:\Users\svc-app\.aws\credentials on 6 servers and was created 3 years ago.
❌ Figure: Bad example - Bad example - Anyone who copies the file has permanent access from anywhere
Each server has its own certificate from Northwind's CA, with the private key held in the TPM. The server gets 1-hour credentials for a role that can invoke 2 Bedrock models and nothing else.
✅ Figure: Good example - Good example - The key cannot be copied off the server and the credentials expire after an hour
rolesanywhere.amazonaws.com service, with conditions that say which certificates can use itaws_signing_helper as a credential_process and the AWS CLI and SDKs call it for credentials. See Get temporary security credentials from IAM Roles AnywhereOn Windows, --cert-selector tells the helper to use a certificate and key from the certificate store:
[profile bedrock-prod]credential_process = aws_signing_helper credential-process --cert-selector Key=x509Subject,Value=CN=app01.northwind.com --trust-anchor-arn arn:aws:rolesanywhere:ap-southeast-2:111122223333:trust-anchor/TA_ID --profile-arn arn:aws:rolesanywhere:ap-southeast-2:111122223333:profile/PROFILE_ID --role-arn arn:aws:iam::111122223333:role/bedrock-invokeregion = ap-southeast-2
On Linux, replace --cert-selector with --certificate and --private-key. The private key can be a file, a TPM handle or a PKCS#11 URI.
By default, any certificate your CA has issued can authenticate, including every user and laptop certificate if the trust anchor is your corporate CA. Add conditions to the role's trust policy so only the intended servers can assume it:
{"Version": "2012-10-17","Statement": [{"Effect": "Allow","Principal": { "Service": "rolesanywhere.amazonaws.com" },"Action": ["sts:AssumeRole", "sts:TagSession", "sts:SetSourceIdentity"],"Condition": {"StringEquals": {"aws:PrincipalTag/x509Subject/CN": "app01.northwind.com"},"ArnEquals": {"aws:SourceArn": "arn:aws:rolesanywhere:ap-southeast-2:111122223333:trust-anchor/TA_ID"}}}]}
You can also match on x509Subject/OU or x509SAN/DNS. See The IAM Roles Anywhere trust model. Give the role only what the server needs, for example bedrock:InvokeModel on the approved model ARNs.
A .pem key file is only a little better than an access key. Use one of these instead:
If you must use a key file, treat it like any other secret. See Do you store your secrets securely?
Use a separate trust anchor and role in each account, and issue production and test certificates from different templates or subjects, so a test certificate cannot open a production role. See Do you use separate AWS accounts as security boundaries? Prove the whole flow, including renewal, in NonProd first.
If your identity team already runs everything in Microsoft Entra ID, let Entra ID control AWS access instead. The server swaps an Entra token, from a managed identity or Azure Arc, for AWS credentials. See Do you use Microsoft Entra ID to give your workloads access to AWS?