ABACとは
タグ(属性)に基づいてアクセス権限を定義する認可戦略。IAMユーザー/ロールに付けたタグと、AWSリソースに付けたタグが一致した場合にアクセスを許可する
出典: Define permissions based on attributes with ABAC authorization
“Attribute-based access control (ABAC) is an authorization strategy that defines permissions based on attributes. AWS calls these attributes tags. You can attach tags to IAM resources, including IAM entities (IAM users or IAM roles) and to AWS resources.”
従来のRBACとの違い
RBAC(ロールベースのアクセスコントロール)
職務(ロール)に基づいてポリシーを作成し、アクセスを制御する従来の方式
開発者ロール → 開発用リソースA, B, Cへのアクセスを許可するポリシー
QAロール → QA用リソースX, Y, Zへのアクセスを許可するポリシー
問題点: 新しいリソースが追加されるたびにポリシーを更新する必要がある
出典: Define permissions based on attributes with ABAC authorization
“The disadvantage to using the traditional RBAC model is that when you or your users add new resources to your environment, you have to update the policies to allow access to those resources.”
ABAC
タグの一致でアクセスを制御
IAMロール: project=Heart
EC2インスタンス: project=Heart → アクセス許可(タグが一致)
EC2インスタンス: project=Star → アクセス拒否(タグが不一致)
ABACのメリット
1. スケーラビリティ
新しいリソースを追加してもポリシーの更新が不要。タグを付けるだけで自動的にアクセス制御される
出典: Define permissions based on attributes with ABAC authorization
“ABAC permissions scale with innovation. It’s no longer necessary for an administrator to update existing policies to allow access to new resources.”
2. ポリシー数の削減
タグベースの汎用ポリシーを少数作るだけで済む
出典: Define permissions based on attributes with ABAC authorization
“ABAC requires fewer policies. Because you don’t have to create different policies for different job functions, you create fewer policies.”
3. 動的な変更対応
プロジェクト追加や人員異動に柔軟に対応できる
出典: Define permissions based on attributes with ABAC authorization
“Using ABAC, teams can dynamically respond to change and growth. Because permissions for new resources are automatically granted based on attributes you don’t have to manually assign policies to identities.”
具体例
3つのプロジェクト(Heart, Star, Lightning)がある場合:
RBACの場合
Heart用ポリシー: Resource: [ec2-heart-1, ec2-heart-2, s3-heart-bucket]
Star用ポリシー: Resource: [ec2-star-1, ec2-star-2, s3-star-bucket]
→ リソース追加のたびにポリシー更新が必要
ABACの場合
{
"Effect": "Allow",
"Action": ["ec2:*", "s3:*"],
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:ResourceTag/project": "${aws:PrincipalTag/project}"
}
}
}→ 1つのポリシーで全プロジェクトに対応。リソース追加時はタグを付けるだけ
主な条件キー
| 条件キー | 用途 |
|---|---|
aws:ResourceTag/キー | リソースに付いたタグで制御 |
aws:PrincipalTag/キー | IAMプリンシパルに付いたタグで制御 |
aws:RequestTag/キー | リクエスト時に指定されたタグで制御 |
aws:TagKeys | 特定のタグキーの有無で制御 |
ABACを構成するコンポーネント
ABACを機能させるには以下の3つが必要:
1. プリンシパルの属性(タグ)
アクセスする側(IAMユーザー、IAMロール、フェデレーションユーザー)に付けるタグ
IAMロール: Department=Engineering, Project=Heart
2. リソースの属性(タグ)
アクセスされる側(EC2、S3、RDSなど)に付けるタグ
EC2インスタンス: Department=Engineering, Project=Heart
3. タグを評価するポリシー
プリンシパルのタグとリソースのタグを比較する条件を含むIAMポリシー
{
"Condition": {
"StringEquals": {
"aws:ResourceTag/Department": "${aws:PrincipalTag/Department}"
}
}
}aws:PrincipalTagとは
IAMポリシーの条件キーの一つで、リクエストを行っているプリンシパル(IAMユーザー、ロール、フェデレーションユーザー)に付いているタグの値を参照するためのもの
出典: AWS global condition context keys
“Use this key to compare the tag attached to the principal making the request with the tag that you specify in the policy.”
ABACを実現するための中核的な条件キーで、「プリンシパルのタグ」と「リソースのタグ」を比較してアクセスを制御する際に使用する
タグの付き方
| プリンシパルの種類 | タグの付け方 |
|---|---|
| IAMユーザー | IAMコンソールで直接タグ付け |
| IAMロール | IAMコンソールで直接タグ付け |
| フェデレーションユーザー | IdPからセッションタグとして渡す |
| AssumeRoleしたセッション | AssumeRole時にセッションタグを指定 |
IdPからの属性マッピング
SAMLやOIDCベースのIdPを使ってAWSにフェデレーションする際、IdP側のユーザー属性をセッションタグとしてAWSに渡せる
出典: Pass session tags in AWS STS
“Session tags are key-value pair attributes that you pass when you assume an IAM role or federate a user in AWS STS. You do this by making an AWS CLI or AWS API request through AWS STS or through your identity provider (IdP).”
SAMLでの属性マッピング例
IdP側でユーザーに以下の属性がある場合:
- 部署: Engineering
- プロジェクト: Automation
SAMLアサーションでこう記述:
<Attribute Name="https://aws.amazon.com/SAML/Attributes/PrincipalTag:Department">
<AttributeValue>Engineering</AttributeValue>
</Attribute>
<Attribute Name="https://aws.amazon.com/SAML/Attributes/PrincipalTag:Project">
<AttributeValue>Automation</AttributeValue>
</Attribute>出典: Pass session tags in AWS STS
“To pass SAML attributes as session tags, include the Attribute element with the Name attribute set to https://aws.amazon.com/SAML/Attributes/PrincipalTag:{TagKey}. Use the AttributeValue element to specify the value of the tag.”
これにより、AWSセッションでaws:PrincipalTag/Departmentなどの条件キーが使えるようになる
IAM Identity Centerでのアクセス制御の属性
IAM Identity CenterでABACを使うには「アクセス制御の属性」機能を有効化する必要がある
出典: Enable and configure attributes for access control
“To use attribute-based access control (ABAC), you must first enable it in either the Settings page of the IAM Identity Center console or the IAM Identity Center API.”
有効化すると何ができるか
Identity Centerで管理しているユーザー属性(部署、コストセンター、プロジェクトなど)を、AWSアカウントへのサインイン時にセッションタグとして自動的に渡せる
ユーザー属性(Identity Center) セッションタグ(AWS)
───────────────────────────── ─────────────────────
CostCenter: 12345 → aws:PrincipalTag/CostCenter = 12345
Department: Engineering → aws:PrincipalTag/Department = Engineering
出典: Enable and configure attributes for access control
“If an attribute from a SAML assertion is also defined as an ABAC attribute in IAM Identity Center, IAM Identity Center will send the value from its Identity Store as a session tag on sign-in to an AWS account.”