IAM Roles Anywhere
概要
IAM Roles Anywhere は、AWS外部で動作するワークロード(オンプレミスサーバー、コンテナ、他クラウドのアプリケーション等)が、一時的なAWS認証情報を取得するためのサービス
出典: What is AWS Identity and Access Management Roles Anywhere?
“You can use AWS Identity and Access Management Roles Anywhere to obtain temporary security credentials in IAM for workloads such as servers, containers, and applications that run outside of AWS.”
なぜ必要か
従来、AWS外部からAWSリソースにアクセスするには、IAMユーザーの長期認証情報(アクセスキー)を使う必要があった。長期認証情報には以下の問題がある:
- 漏洩した場合の被害が大きい
- 定期的なローテーション管理が必要
- 攻撃者に悪用されやすい
出典: Extend AWS IAM roles to workloads outside of AWS with IAM Roles Anywhere
“When you use IAM Roles Anywhere to vend short-term credentials you can remove the need for long-term AWS access keys and secrets, which can help improve security, and remove the operational overhead of managing and rotating the long-term credentials.”
仕組み
IAM Roles Anywhere は PKI(公開鍵基盤)を利用して信頼関係を構築する。ワークロードは X.509 証明書を使って認証し、一時的なAWS認証情報を取得する
出典: The IAM Roles Anywhere trust model
“AWS Identity and Access Management Roles Anywhere works by bridging the trust model of IAM and Public Key Infrastructure (PKI). The model connects the role, the IAM Roles Anywhere service principal, and identities encoded in X.509 certificates, that are issued by a Certificate Authority (CA).”
コンポーネント
1. Trust Anchor(トラストアンカー)
IAM Roles Anywhere と認証局(CA)の間の信頼関係を確立するコンポーネント。AWS Private CA または外部CAの証明書を登録する
出典: What is AWS Identity and Access Management Roles Anywhere?
“You establish trust between IAM Roles Anywhere and your certificate authority (CA) by creating a trust anchor. A trust anchor is a reference to either AWS Private CA or an external CA certificate.”
2. X.509 証明書
ワークロードの身元を証明するデジタル証明書。Trust Anchor として登録されたCAから発行される必要がある
証明書の要件:
出典: The IAM Roles Anywhere trust model - Signature validation
“The certificates MUST be X.509v3.” “The key usage MUST include Digital Signature.” “The signing algorithm MUST include SHA256 or stronger. MD5 and SHA1 signing algorithms are rejected.”
3. IAM Role(IAMロール)
ワークロードが引き受けるロール。このロールに付与された権限でAWSリソースにアクセスする
ロールの信頼ポリシーで rolesanywhere.amazonaws.com を許可する必要がある
出典: The IAM Roles Anywhere trust model - Role trusts
“To use an IAM role with IAM Roles Anywhere, you must create a trust relationship with the IAM Roles Anywhere service principal rolesanywhere.amazonaws.com.”
4. Profile(プロファイル)
どのロールを引き受けるか、セッションにどのような制限を付けるかを定義するコンポーネント
出典: What is AWS Identity and Access Management Roles Anywhere?
“To specify which roles IAM Roles Anywhere assumes and what your workloads can do with the temporary credentials, you create a profile. In a profile, you can define IAM session policies, which can be managed or inline, to limit the permissions created for a session.”
ユースケース
出典: Extend AWS IAM roles to workloads outside of AWS with IAM Roles Anywhere
“You can use IAM Roles Anywhere for any workload running in your data center, or in other cloud providers, that requires credentials to access AWS APIs.”
具体例:
- オンプレミスサーバーからS3へのバックアップ
- オンプレミスのKubernetesワークロードからAWSサービスへのアクセス
- マルチクラウド環境での統一的な認証
認証フロー
- ワークロードが X.509 証明書と秘密鍵で署名したリクエストを IAM Roles Anywhere に送信
- IAM Roles Anywhere が署名を検証し、証明書が Trust Anchor に登録されたCAから発行されたものか確認
- 検証成功後、指定されたIAMロールの一時認証情報を発行
- ワークロードは一時認証情報を使ってAWSリソースにアクセス
出典: Extend AWS IAM roles to workloads outside of AWS with IAM Roles Anywhere
“Your application makes an authentication request to IAM Roles Anywhere, sending along its public key (encoded in a certificate) and a signature signed by the corresponding private key. Your application also specifies the role to assume in the request. When IAM Roles Anywhere receives the request, it first validates the signature with the public key, then it validates that the certificate was issued by a trust anchor previously configured in the account.”
認証処理の流れ
オンプレミス AWS
──────────── ─────
┌─────────────┐
│ ワークロード │
│ │
│ 証明書+秘密鍵│
└──────┬──────┘
│
│ ① CreateSession API呼び出し
│ - X.509証明書
│ - 秘密鍵による署名
│ - 引き受けたいロールのARN
│ - プロファイルのARN
│
▼
┌─────────────────────┐
│ IAM Roles Anywhere │
└──────────┬──────────┘
│
┌──────────────────┼──────────────────┐
│ │ │
▼ ▼ ▼
┌────────────┐ ┌────────────┐ ┌────────────┐
│Trust Anchor│ │ Profile │ │ IAM Role │
└─────┬──────┘ └─────┬──────┘ └─────┬──────┘
│ │ │
② 証明書の発行元 ③ このロールを ④ 信頼ポリシー
は登録済みか? 引き受けてOK? の確認
│ │ │
▼ ▼ ▼
OK OK OK
│ │ │
└────────┬────────┘ │
│ │
▼ │
┌─────────────────┐ │
│ STS │◀────────────────┘
│ AssumeRole実行 │
└────────┬────────┘
│
│ ⑤ 一時認証情報を生成
│ - AccessKeyId
│ - SecretAccessKey
│ - SessionToken
│ - 有効期限
▼
┌─────────────────────────────────────┘
│
│ ⑥ 一時認証情報を返却
▼
┌─────────────┐
│ ワークロード │
│ │
│ 一時認証情報 │
│ を受け取る │
└──────┬──────┘
│
│ ⑦ 一時認証情報でAWSサービスにアクセス
│
▼
┌─────────────────────┐
│ S3 / DynamoDB 等 │
└─────────────────────┘