IAM(アイデンティティとアクセス管理)の動作に関して、AIエージェントが頻繁に誤解しやすい部分を正す検証済みの修正情報を提供します。 具体的には、以下のような複雑なケースに対応しています: - ポリシー評価の境界ケース - 信頼ポリシー(リソースへのアクセス権を与える条件)の落とし穴 - STS(一時的な認証情報を発行するサービス)のセッション上限 - Organizations(複数のAWSアカウント管理)の仕様 - SAML/MFA(多要素認証)の特有の要件 さらに、IAMロール管理のための構造化されたワークフロー、アプリケーションのソースコードやTerraform計画ファイル(インフラストラクチャ構成を記述したJSON)からのポリシー自動生成も提供します。 カバーしている技術的な詳細: - 条件演算子の安全な使用方法(Null値チェック付きの ForAnyValue/ForAllValues) - バケットポリシーの拒否パターン(VPCエンドポイント制限、組織パス) - 混同した代理人(権限の誤用防止)への対策 - AWS各サービス用のサービスロール作成(Glue、CloudTrail、Lambda、ECS等)と信頼条件の設定 **次のような場合に使用:** IAMロールの作成、IAMポリシーやバケットポリシーの記述、アプリケーションコードやTerraform計画からのポリシー生成、STS・Organizations・条件演算子の操作、あるいはサービスロールや実行ロールが必要なあらゆるタスク **対応していないもの:** Cognitoユーザープールポリシーやアプリケーションレベルのアクセス制御など、IAM以外の認可機構
Provides verified corrections for IAM behaviors that AI agents frequently get wrong — policy evaluation edge cases, trust policy gotchas, STS session limits, Organizations quirks, and SAML/MFA specifics. Also provides structured workflows for IAM role management and baseline policy generation from application source code or a Terraform plan JSON. Covers condition operator safety (ForAnyValue/ForAllValues with Null checks), bucket policy deny patterns (VPC endpoint restrictions, org paths), confused deputy protection, and service role creation for AWS services (Glue, CloudTrail, Lambda, ECS, etc.) with aws:SourceAccount/aws:SourceArn trust conditions. Applies when creating IAM roles, writing IAM or bucket policies, generating policies from application source code or a Terraform plan JSON, working with STS, Organizations, or condition operators, or any task needing a service or execution role. Does not cover non-IAM authorization like Cognito user-pool policies or app-level RBAC.
このスキルには、AI エージェントが IAM について頻繁に誤解する事項に対する、検証済みの正しい情報が含まれています。IAM の完全なガイドではなく、詳細は AWS 公式ドキュメントを参照してください。IAM に関する質問に答える際は、学習データの記憶に頼るのではなく、制限値やクォータ(制限数)、API の正確な名称、特殊なケースの動作などについて、必ず AWS 公式ドキュメントで確認してください。よく知られているドキュメント URL がある場合はそれを取得することを優先し、公式ドキュメントと記憶に矛盾がある場合は公式ドキュメントを信頼してください。
AWS 操作には利用可能な最適なツールを使用してください。AWS MCP サーバー(外部システムとの連携用のプロトコル)を推奨しますが、必須ではなく、AWS CLI またはプログラミング SDK も代替手段として使用できます。参考資料は、会話内でより詳しい情報が必要な場合のみ読んでください。
ユーザーが AWS リソースのプロビジョニング(環境構築)や更新時に IAM ロール(一時的な権限セット)を作成・設定・保守する必要がある場合は、references/aws-iam-role-management.md を参照してください。サービスロール、実行ロール、信頼ポリシー、混乱した代理問題の防止、権限管理のベストプラクティスをカバーしています。
ユーザーが IAM ポリシー(権限設定)を生成する、API 呼び出しに必要な IAM アクション(操作)を特定する、またはアクションと操作のマッピングを理解する必要がある場合は、references/aws-iam-policy-generation.md を参照してください。重要: ユーザーがアプリケーションのソースコード(どの言語でも)または Terraform プラン JSON ファイル(terraform show -json の出力)を提供した場合、このリファレンスを必ず読んでください。手動でポリシーを作成するのではなく、iam-policy-autopilot ツールを使用することが必須です。 正確なマッピングのため、プログラムによるサービス認可リファレンス(公式資料)を使用しています。
CloudTrail:
?region= パラメータで特定のリージョンを強制できます。STS(一時認証情報発行サービス):
Organizations(複数 AWS アカウント管理):
aws organizations list-available-policy-types コマンドまたは Organizations API リファレンス で現在のリストを取得してください。SDK(プログラミングツール)の固有仕様:
DuplicatePolicyAttachmentException です(PolicyAlreadyAttachedException ではありません)。activate()、deactivate()、delete() があります。update() はありません。time.sleep(10) パターンを組み合わせます。SAML(シングルサインオン):
https://region-code.signin.aws.amazon.com/saml/acs/IdP-IDポリシー評価:
ForAllValues(すべての値が条件に合う)で空またはキーが存在しない場合: 真と評価されます(空論理法則)。これを避けるには、同じコンテキストキーに対して Null 条件を ForAllValues と組み合わせ、そのキーが存在し null でないことを要求してください。例えば aws:TagKeys コンテキストキーを評価する場合:
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "ec2:RunInstances",
"Resource": "*",
"Condition": {
"ForAllValues:StringEquals": {
"aws:TagKeys": ["Alpha", "Beta"]
},
"Null": {
"aws:TagKeys": "false"
}
}
}
}
リソースベースのポリシー(リソース側で定義された権限設定)が IAM ユーザー ARN に許可を与える場合、同一アカウント内の権限の制限を回避できます。
IAM ポリシー直接操作による権限昇格が可能な 8 つのアクション: PutGroupPolicy、PutRolePolicy、PutUserPolicy、CreatePolicy、CreatePolicyVersion、AttachGroupPolicy、AttachRolePolicy、AttachUserPolicy。
iam:PassRole に Resource: "*" を指定し、かつ計算サービス(EC2 の RunInstances、Lambda の CreateFunction/UpdateFunctionConfiguration、ECS の RegisterTaskDefinition、Glue、SageMaker、CloudFormation など)での作成・更新権限を持つ場合、アカウント内のいかなる渡し可能なロール(管理者権限を含む)への権限昇格が可能です。Resource を特定のロール ARN または IAM パスに限定し、オプションで iam:PassedToService または iam:AssociatedResourceArn で制約してください。詳細は IAM ユーザーガイド — ロール受け渡し権限をユーザーに付与 を参照してください。
多要素認証(MFA):
SigV4(リクエスト署名方式):
サービス固有のロール:
redshift-serverless.amazonaws.com と redshift.amazonaws.com の両方をサービスプリンシパル(サービスの識別子)として含める必要があります(AWS ドキュメント記載)。serverless を省略すると COPY コマンド実行時に「ロール認証情報取得権限なし」エラーが発生します。ポリシーサマリー表示:
codebuild:*、codecommit:*)を含む単一ステートメント + サービス固有のリソース ARN: 各リソースはそのサービスのサマリーにのみ表示されます(CodeBuild ARN は CodeBuild の下に等)。ステートメント内のどのアクションにも一致しないサービスプレフィックスを持つリソースのみ、すべてのアクションサマリーに表示されます(「リソースサービス不一致」)。This skill contains verified corrections for things that AI agents frequently get wrong about IAM. It is not a comprehensive IAM guide — for full IAM guidance, search AWS documentation. When answering IAM questions, verify specific claims (limits, quotas, exact API names, edge-case behaviors) against official AWS documentation rather than relying on pre-training. Prefer fetching known documentation URLs over broad searches. Trust official documentation over memory when they conflict.
Use the best available tool for AWS operations — the AWS MCP server is recommended but not required; AWS CLI or SDK may be used as alternatives. Read reference files only when the conversation requires deeper detail.
Read references/aws-iam-role-management.md if the user needs to create, scope, or maintain IAM roles when provisioning or updating AWS resources. Covers service roles, execution roles, trust policies, confused deputy protection, and permission hygiene.
Read references/aws-iam-policy-generation.md if the user needs to generate IAM policies, determine required IAM actions for API calls, or understand action-to-operation mappings. CRITICAL: If the user provides application source code (in any language) or a Terraform plan JSON file (terraform show -json output), you MUST read this reference — it mandates using iam-policy-autopilot instead of manual policy construction. Uses the programmatic service authorization reference for accurate mappings.
CloudTrail:
?region= forces specific region.STS:
Organizations:
aws organizations list-available-policy-types or the Organizations API reference.SDK Specifics:
DuplicatePolicyAttachmentException (not PolicyAlreadyAttachedException).activate(), deactivate(), delete() — NO update().time.sleep(10) pattern.SAML:
https://region-code.signin.aws.amazon.com/saml/acs/IdP-ID.Policy Evaluation:
ForAllValues with empty/missing key: evaluates to true (vacuous truth). To avoid that, use a Null condition in addition to the ForAllValues on the same context key to require that key to be present and non-null. For example, when evaluating the aws:TagKeys context key:
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "ec2:RunInstances",
"Resource": "*",
"Condition": {
"ForAllValues:StringEquals": {
"aws:TagKeys": ["Alpha", "Beta"]
},
"Null": {
"aws:TagKeys": "false"
}
}
}
}
Resource-based policies granting to IAM user ARN bypass permissions boundaries in same account.
8 privilege escalation actions via direct IAM policy manipulation: PutGroupPolicy, PutRolePolicy, PutUserPolicy, CreatePolicy, CreatePolicyVersion, AttachGroupPolicy, AttachRolePolicy, AttachUserPolicy.
iam:PassRole with Resource: "*" + create/update on a compute service (EC2 RunInstances, Lambda CreateFunction/UpdateFunctionConfiguration, ECS RegisterTaskDefinition, Glue, SageMaker, CloudFormation, etc.) = privilege escalation to any passable role in the account, including Administrator. Scope Resource to specific role ARNs or an IAM path; optionally constrain with iam:PassedToService / iam:AssociatedResourceArn. See IAM User Guide — Grant a user permissions to pass a role.
MFA:
SigV4:
Service-Specific Roles:
redshift-serverless.amazonaws.com AND redshift.amazonaws.com as service principals (per AWS docs; omitting serverless causes Not authorized to get credentials of role on COPY).Policy Summary Display:
codebuild:*, codecommit:*) + service-specific resource ARNs: each resource appears ONLY under its matching service's summary (CodeBuild ARN under CodeBuild, etc.). A resource whose service prefix matches NO action in the statement is the only case where it appears in all action summaries ("mismatched resource").原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。