# AWS IAM Roles Anywhere: Workloads Outside AWS Without Static Keys

URL: https://www.devopsness.com/blog/aws-iam-roles-anywhere-workloads-outside-aws
Author: Kiril Urbonas
Published: 2026-07-01
Updated: 2026-11-15
Categories: Cloud
Tags: IAM, Identity, Security, Permissions, AWS

Summary: We had long-lived AWS keys sitting in a datacenter we don't own. IAM Roles Anywhere let us delete every one of them. Here's the real setup.

---
# AWS IAM Roles Anywhere: Workloads Outside AWS Without Static Keys

IAM Roles Anywhere replaces static `AKIA` keys on machines outside AWS with one-hour credentials obtained by signing a request with an X.509 certificate. Register your CA as a trust anchor, lock the role's trust policy to the certificate's subject and that trust anchor, then point `credential_process` at `aws_signing_helper`. Your new chore is certificate renewal.

> [!VERIFIED]
> AWS IAM Roles Anywhere credential helper 1.8.5 (released 2026-08-24), against the AWS IAM Roles Anywhere user guide (trust model and credential helper pages) and the AWS Private CA pricing page. Checked October 2026.

A security review flagged it: a batch job in our colo datacenter had an `AKIA` access key in an environment file, and that key had been valid for three years. It could read a production S3 bucket. Rotating it meant a coordinated change across four machines, so nobody had rotated it, ever. That's the trap with static keys outside AWS. They never expire on their own and rotating them is painful enough that they don't get rotated.

IAM Roles Anywhere is the fix, and it's the same move as [OIDC federation for GitHub Actions](/blog/oidc-federation-github-actions-aws), just with a certificate instead of a token. It lets a workload outside AWS exchange an X.509 certificate for temporary AWS credentials, the same short-lived credentials an EC2 instance gets from its instance profile. No more `AKIA` keys.

## The pieces

Three things connect: a trust anchor (your certificate authority, registered with AWS), a profile (which roles are reachable), and an IAM role with a trust policy that permits the Roles Anywhere service. Your workload already has a client certificate signed by that CA, or you issue it one.

First, register the CA as a trust anchor. You can use AWS Private CA or bring your own CA's certificate. We used our existing internal CA to avoid paying for Private CA, which as of October 2026 costs $400 per CA per month in general-purpose mode, or $50 per month in short-lived certificate mode.

```bash
$ aws rolesanywhere create-trust-anchor \
  --name colo-internal-ca \
  --source 'sourceType=CERTIFICATE_BUNDLE,sourceData={x509CertificateData="'"$(cat ca-cert.pem)"'"}' \
  --enabled
```

Then the IAM role, whose trust policy is the important part. It trusts the Roles Anywhere service and, critically, constrains which certificates can assume it using a condition on the certificate subject.

```json
{
  "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": "batch-runner.colo.internal"
      },
      "ArnEquals": {
        "aws:SourceArn": "arn:aws:rolesanywhere:us-east-1:111122223333:trust-anchor/abc-123"
      }
    }
  }]
}
```

Without that `StringEquals` condition on the CN, any certificate your CA signs could assume the role. That's the mistake we see most often. The `aws:SourceArn` condition is the other half: AWS's trust-model docs strongly recommend it so the role only accepts sessions minted through your trust anchor, which closes the confused-deputy hole. Keep the role's permission policy narrow too; [least privilege without breakage](/blog/cloud-iam-least-privilege-without-breakage) covers how we trim it. The trust anchor says "I trust this CA," and the role's condition says "but only the specific cert I mean." You want both.

Then create a profile linking the role:

```bash
$ aws rolesanywhere create-profile \
  --name batch-runner-profile \
  --role-arns arn:aws:iam::111122223333:role/batch-runner \
  --enabled \
  --duration-seconds 3600
```

## Getting credentials on the workload

AWS ships a signing helper (`aws_signing_helper`, version 1.8.5 as of October 2026) that speaks the credential-process protocol the AWS CLI and SDKs already understand. You point your `~/.aws/config` at it and everything else just works.

```ini
# ~/.aws/config (credential_process must be one line; the config file has no line continuation)
[profile colo-batch]
credential_process = /usr/local/bin/aws_signing_helper credential-process --certificate /etc/pki/batch-runner.pem --private-key /etc/pki/batch-runner.key --trust-anchor-arn arn:aws:rolesanywhere:us-east-1:111122223333:trust-anchor/abc-123 --profile-arn arn:aws:rolesanywhere:us-east-1:111122223333:profile/def-456 --role-arn arn:aws:iam::111122223333:role/batch-runner
region = us-east-1
```
Now `aws s3 ls --profile colo-batch` works with credentials that live for one hour (the profile's `--duration-seconds`; the helper accepts 900 to 43,200 seconds) and the SDKs refresh them before they expire. Long-running services that don't read `~/.aws/config` can use `aws_signing_helper serve` instead, which exposes an IMDSv2-compatible endpoint on `127.0.0.1:9911`; any local process can read it, so only use it on single-purpose hosts. The private key never leaves the box, and there is no long-lived AWS secret anywhere in the config. If the machine is compromised, the attacker gets at most an hour of access after they lose the key, versus three years with the old scheme.

## The part nobody mentions until it breaks

Certificate expiry becomes your new operational concern. The old static key never expired, which was the security problem, but it also meant nothing broke on a schedule. Now your client cert has a lifetime, and when it expires the workload loses AWS access instantly. We issue 90-day certs and renew them with a cron job that pulls a fresh cert from the internal CA at 60 days. Monitor cert expiry the same way you'd monitor a TLS cert on a load balancer, because a silent expiry at 2am is an outage.

Clock skew matters too. The signing helper signs a request with a timestamp, and if the workload's clock drifts more than a few minutes, the `CreateSession` call is rejected with an unhelpful signature error. Run NTP. We lost an hour to this before someone checked `timedatectl` and found the box was eight minutes fast.

Revocation works differently from what PKI people expect. Roles Anywhere checks certificates against CRLs you import with `aws rolesanywhere import-crl`; it does not call CRL distribution points or OCSP. If you revoke a cert at your CA and forget to push the new CRL, the cert keeps working until it expires. We push the CRL from the same cron job that renews certs, and the [SSH certificates post](/blog/ssh-hardening-2026-keys-certificates-bastion) covers the same short-lived-cert mindset for humans.

## Questions people ask

### Do I need AWS Private CA to use IAM Roles Anywhere?

No. A trust anchor can be an AWS Private CA or the certificate bundle of any CA you already run, such as an internal Vault PKI or step-ca. Private CA is the low-effort option, but as of October 2026 it costs $400 per CA per month in general-purpose mode or $50 in short-lived certificate mode, plus per-certificate fees. Bring your own CA if you already have one.

### How do I restrict which certificates can assume a role?

Add conditions to the role trust policy. Roles Anywhere maps the certificate's Subject, Issuer and first SAN values to principal tags such as `aws:PrincipalTag/x509Subject/CN` and `aws:PrincipalTag/x509SAN/URI`. Match the exact CN or SAN you issued, and pin `aws:SourceArn` to your trust anchor ARN. Without those conditions, every certificate your CA has ever signed can assume the role.

### When should I use OIDC federation instead?

Whenever the workload can get an OIDC token: GitHub Actions, GitLab CI, Kubernetes service accounts and most CI platforms can. Web identity federation needs no certificates, no renewal cron and no CRLs. Roles Anywhere is for machines that only have an identity in your PKI, such as colo servers, on-prem VMs and appliances.

## The call we'd make

If you have any workload outside AWS holding an `AKIA` key, and it's not behind OIDC federation already, move it to Roles Anywhere. The setup is an afternoon, the operational cost is monitoring cert expiry (which you should be doing anyway), and it eliminates an entire class of "the three-year-old key leaked" incidents. For workloads that can do OIDC, GitHub Actions and the like, prefer web identity federation instead, since there's no cert to manage. Roles Anywhere is specifically for the boxes that only have a certificate and a heartbeat.

## Sources

- [AWS docs: the IAM Roles Anywhere trust model](https://docs.aws.amazon.com/rolesanywhere/latest/userguide/trust-model.html)
- [AWS docs: get temporary credentials with the credential helper](https://docs.aws.amazon.com/rolesanywhere/latest/userguide/credential-helper.html)
- [AWS Private CA pricing](https://aws.amazon.com/private-ca/pricing/)

