Skip to content

Back to the catalog

Best practices for integrating IAM Roles Anywhere with your PKI
aws.amazon.comarticle

Best practices for integrating IAM Roles Anywhere with your PKI

Best practices for integrating AWS IAM Roles Anywhere with an external PKI so non-AWS workloads get temporary credentials via X.509 certificates. Covers trust anchor placement, certificate attributes (CN, issuer, SAN) in trust policy conditions, short-lived versus just-in-time certificates, and private key protection with PKCS #11, TPM 2.0 and OS certificate stores. Includes credential helper modes (serve, update), expiry monitoring, blue/green trust anchor rotation and a sample CloudFormation template.

TL;DR Explains how to wire an external PKI into IAM Roles Anywhere with scoped trust policies, short-lived certificates, TPM or HSM-backed keys and rotation.
Document

What it is

An AWS Security Blog post on connecting an external PKI to IAM Roles Anywhere, so workloads outside AWS can exchange X.509 certificates for temporary IAM credentials through the CreateSession API. It adds a sample CloudFormation template (the "IAM Roles Anywhere — External PKI Integration" repository on GitHub). The page text we fetched omits the code samples, so the commands and policy JSON are not reproduced here.

How it works

IAM Roles Anywhere reads the subject Common Name (CN), issuer and Subject Alternative Name (SAN) from the authenticating certificate. It exposes them as sts:sourceIdentity and principal tags for policy evaluation. The role trust policy must trust the IAM Roles Anywhere service principal. The post recommends adding conditions on the PrincipalTag values. If certificates have a dynamic subject CN, use the issuer or SAN tags instead. The trust anchor level you choose in the CA hierarchy decides which end-entity certificates are accepted. Effective permissions are the intersection of resource-based, identity-based and session policies.

Preconditions / Affected

  • An empty subject CN is not supported.
  • Just-in-time certificates need support from your CA.
  • The SessionDurationSeconds value must not exceed the role's MaxSessionDuration, which defaults to 3600 seconds. Otherwise CreateSession returns an error.

What to do

Credential helper versions matter for key protection:

  • 1.0.5: certificates and keys in Windows (CryptoAPI, CNG) and macOS (Keychain) stores. Use --cert-selector with the keys x509Subject, x509Issuer and x509Serial, given inline or as file://path/to/selector.json.
  • 1.1.0 and later: PKCS #11 modules, including HSMs, so keys need not be written to disk.
  • 1.4.0 and later (December 2024): TPM 2.0, with non-exportable keys generated inside the TPM. The post calls this the strongest key protection available for on-premises and hybrid workloads.

Choose the helper mode deliberately:

  • serve: vends credentials on localhost using IMDSv2-style URIs and headers. The SDKs discover it and no AWS config files are needed. The post recommends it by default.
  • update: writes credentials to a file that any process able to read it can use. Use it only when the AWS CLI needs file credentials.
  • credential_process in the AWS CLI: it creates a new session on every command and adds latency. SDKs keep credentials in memory and refresh them.

Certificate lifetime and rotation:

  • AWS Private CA short-lived mode is for validity under 7 days. It costs $50 per month, against $400 for general-purpose mode.
  • Expiry notifications for CA and end-entity certificates are on by default and the thresholds can be customized.
  • Rotate trust anchors with blue/green: one trust anchor per environment, with rotation tested in staging first.

The template enforces issuer CN, subject CN and SAN CN as trust policy conditions. It also scopes the role to one trust anchor ARN, so other trust anchors in the account cannot assume it. A mismatch on any of the three values denies CreateSession.

Caveats

The post says nothing about revocation mechanics. It says only that short validity reduces the need for active revocation. A July 2026 note on ACM exportable certificates and ACME describes them as complementary to Roles Anywhere, not a replacement.

Organisations named here

  • CreateSession
  • credential helper
  • IMDSv2
  • PKCS #11
  • short-lived certificates
  • trust anchor

Technologies named here

  • AWS IAM Roles Anywhere
  • AWS Identity and Access Management
  • AWS Private CA
  • AWS Private Certificate Authority
  • AWS Certificate Manager
  • openssl
  • Active Directory Certificate Services
  • Windows CryptoAPI and CNG, and macOS Keychain
  • AWS CLI and AWS SDKs
  • AWS IAM
  • AWS CloudFormation
  • AWS
  • X.509
  • TPM 2.0

Techniques named here

  • Trust anchor setup in three steps