🔐aws-iam
- プラグイン
- aws-core
- ソース
- GitHub で見る ↗
説明
IAM の動作に関する検証済みの訂正集です。AI agents が頻繁に誤る以下の項目をカバーしています:ポリシー評価のエッジケース、信頼ポリシーの落とし穴、STS セッション制限、Organizations の特殊な動作、SAML/MFA の仕様。 IAM ロール管理と最小権限ポリシー生成の構造化ワークフローも提供します。 **カバー内容:** - 条件演算子の安全性(ForAnyValue/ForAllValues と存在しないキーに対する Null チェック) - バケットポリシーの deny パターン(VPC エンドポイント制限、Organization パスの条件) - リソースベースのポリシーで confused deputy 保護 - AWS サービス向けサービスロール作成(Glue、CloudTrail、VPC Flow Logs、Firehose、DataSync、S3 レプリケーション、Lambda、Step Functions、ECS など)- aws:SourceAccount/aws:SourceArn 条件を含む信頼ポリシー付き **次のような場合に使用:** IAM ロールの作成・設定、IAM またはバケットポリシーの記述、STS や Organizations の操作、条件演算子の使用、あるいは IAM サービスロールまたは実行ロール(execution role)が必要なすべてのタスク **注意:** Cognito ユーザープールポリシーやアプリケーションレベルの RBAC など、IAM 以外の認可メカニズムはカバーしていません。
原文を表示
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 least-privilege policy generation. Covers condition operator safety (ForAnyValue/ForAllValues with Null checks for absent keys), bucket policy deny patterns (VPC endpoint restrictions, org path conditions), resource-based policy confused deputy protection, and service role creation for AWS services (Glue, CloudTrail, VPC Flow Logs, Firehose, DataSync, S3 replication, Lambda, Step Functions, ECS, etc.) including trust policies with aws:SourceAccount/aws:SourceArn conditions. Applies when creating or configuring IAM roles, writing IAM or bucket policies, working with STS, Organizations, condition operators, or any task requiring an IAM service role or execution role. Does not cover non-IAM authorization like Cognito user-pool policies or app-level RBAC.
ユースケース
- ✓IAM ロールの作成・設定
- ✓IAM またはバケットポリシーの記述
- ✓STS や Organizations の操作
- ✓条件演算子を使用するとき
- ✓IAM サービスロール作成が必要なとき
本文(日本語訳)
AWS IAM — よくある落とし穴
このSkillについて
このSkillは、AIエージェントがIAMについてよく誤解する事項に対する検証済みの修正情報を含んでいます。包括的なIAMガイドではなく、完全なIAM情報についてはAWSドキュメントを検索してください。IAMに関する質問に答える際は、事前学習に依存するのではなく、具体的な内容(制限、クォータ、正確なAPI名、エッジケースの動作)を公式AWSドキュメントに照らして検証してください。既知のドキュメントURLの取得を広範な検索よりも優先してください。ドキュメントとメモリが矛盾する場合は、公式ドキュメントを信頼してください。
よくあるワークフロー
AWS操作に最適な利用可能なツールを使用してください—AWS MCP serverが推奨されていますが必須ではなく、AWS CLIやSDKを代替手段として使用できます。会話がより詳細な情報を必要とする場合にのみリファレンスファイルを読んでください。
-
ユーザーがAWSリソースのプロビジョニングまたは更新時にIAMロールを作成、スコープ設定、または維持する必要がある場合は、references/aws-iam-role-management.mdを参照してください。サービスロール、実行ロール、信頼ポリシー、confused deputy保護、およびパーミッションハイジーンをカバーしています。
-
ユーザーが最小権限のIAMポリシーを生成する、APIコールに必要なIAMアクションを判断する、またはアクション・オペレーション間のマッピングを理解する必要がある場合は、references/aws-iam-policy-generation.mdを参照してください。重要: ユーザーがソースコード(Python、Go、TypeScript、JavaScript、Java)を提供する場合、このリファレンスを読まなくてはなりません—手動でのポリシー構成の代わりにiam-policy-autopilotを使用することが必須です。 プログラム的なサービス認可リファレンスを使用して、正確なマッピングを提供します。
検証済みのエッジケース
CloudTrail:
- AcceptHandshake/DeclineHandshakeは実行アカウント「のみ」でログされ、管理アカウントではログされません。一元化のには組織トレイルが必須です。
- ConsoleLoginのリージョンはエンドポイント/クッキーに依存し、常にus-east-1ではありません。
?region=で特定のリージョンを強制できます。
STS:
- GetSessionTokenの制限: (1) MFAを含めない限りIAM APIは使用不可 (2) AssumeRoleとGetCallerIdentity以外のSTSは使用不可。
- クロスアカウントAssumeRoleからオプトインリージョンへ: 呼び出し元アカウントではなく、ターゲットアカウントがリージョンを有効にする必要があります。
- ロールチェーン: 最大1時間のセッション。
Organizations:
- 停止/クローズされたアカウントは永続的にクローズされるまで(約90日)削除できません。削除を「先に」実行してからクローズしてください。
- ポリシー管理の委任: register-delegated-administratorではなくPutResourcePolicyを使用してください。
- AIオプトアウトポリシー: デフォルトでは管理アカウントが必須です。
- Organizations ポリシータイプのListPoliciesフィルター:
aws organizations list-available-policy-typesまたはOrganizations APIリファレンスを通じて現在のリストを取得してください。
SDKの詳細:
- Organizations:
DuplicatePolicyAttachmentException(PolicyAlreadyAttachmentExceptionではなく)。 - Boto3 IAM AccessKey: メソッドは
activate()、deactivate()、delete()—update()は「ありません」。 - Instance profiles: waiter +
time.sleep(10)パターン。 - マネージドポリシーの最大バージョン: 5。
SAML:
- 暗号化されたアサーションURL:
https://region-code.signin.aws.amazon.com/saml/acs/IdP-ID。 - IdPからの秘密鍵をIAMに.pem形式でアップロードします。
ポリシー評価:
-
ForAllValuesと空/欠落キー: trueと評価されます(空真)。これを避けるために、同じコンテキストキー上でForAllValuesに加えて
Null条件を使用して、そのキーが存在し、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: "*"+ コンピュートサービスに対する作成/更新(EC2RunInstances、LambdaCreateFunction/UpdateFunctionConfiguration、ECSRegisterTaskDefinition、Glue、SageMaker、CloudFormation等) = アカウント内のAdministratorを含む任意の渡可能ロールへの権限昇格。Resourceを特定のロールARNまたはIAMパスに限定してください。オプションでiam:PassedToService/iam:AssociatedResourceArnで制約できます。IAM User Guide — ロール を渡すアクセス許可をユーザーに付与するを参照してください。
MFA:
- 割り当てられていない仮想MFAデバイスは新しいデバイスを追加する時に自動削除されます。
- MFA再同期専用ポリシーNotActionは正確に以下が必要: iam:ListMFADevices、iam:ListVirtualMFADevices、iam:ResyncMFADevice。
SigV4:
- IncompleteSignatureExceptionには、トランジット改変診断用のAuthorizationヘッダーのSHA-256ハッシュが含まれます。
サービス固有のロール:
- Redshift Serverless信頼ポリシー:
redshift-serverless.amazonaws.com「と」redshift.amazonaws.comの両方をサービスプリンシパルとして含めてください(AWSドキュメント案件; serverlessを省略するとCOPY時にNot authorized to get credentials of roleが発生します)。 - IAM OIDCプロバイダー: ほとんどのプロバイダーではサムプリントは不要です(AWSが信頼されたCAを経由して検証します)。
ポリシーサマリー表示:
- マルチサービスワイルドカードアクション(例:
codebuild:*、codecommit:*) + サービス固有のリソースARNを含む単一ステートメント: 各リソースは、一致するサービスのサマリー「のみ」の下に表示されます(CodeBuildのARNはCodeBuildの下に等)。ステートメント内のアクションとサービスプレフィックスが一致しないリソースは、すべてのアクションサマリーに表示される唯一のケースです("mismatched resource")。
原文(English)を表示
AWS IAM — Common Pitfalls
About This Skill
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.
Common Workflows
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 least-privilege IAM policies, determine required IAM actions for API calls, or understand action-to-operation mappings. CRITICAL: If the user provides source code (Python, Go, TypeScript, JavaScript, Java), 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.
Verified Edge Cases
CloudTrail:
- AcceptHandshake/DeclineHandshake logged in ACTING account ONLY, not management account. Organization trail required for centralization.
- ConsoleLogin region varies by endpoint/cookies, NOT always us-east-1.
?region=forces specific region.
STS:
- GetSessionToken restrictions: (1) No IAM APIs unless MFA included (2) No STS except AssumeRole and GetCallerIdentity.
- Cross-account AssumeRole to opt-in region: TARGET account must enable region, not calling account.
- Role chaining: max 1-hour session.
Organizations:
- Suspended/closed accounts CANNOT be removed until permanently closed (~90 days). Remove FIRST, then close.
- Policy management delegation: use PutResourcePolicy, NOT register-delegated-administrator.
- AI opt-out policies: management account required by default.
- Organizations policy types for ListPolicies filter: fetch the current list via
aws organizations list-available-policy-typesor the Organizations API reference.
SDK Specifics:
- Organizations:
DuplicatePolicyAttachmentException(not PolicyAlreadyAttachedException). - Boto3 IAM AccessKey: methods are
activate(),deactivate(),delete()— NOupdate(). - Instance profiles: waiter +
time.sleep(10)pattern. - Managed policy max versions: 5.
SAML:
- Encrypted assertions URL:
https://region-code.signin.aws.amazon.com/saml/acs/IdP-ID. - Private key from IdP uploaded to IAM in .pem format.
Policy Evaluation:
-
ForAllValues with empty/missing key: evaluates to true (vacuous truth). To avoid that, use a
Nullcondition in addition to theForAllValueson the same context key to require that key to be present and non-null. For example, when evaluating theaws:TagKeyscontext 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:PassRolewithResource: "*"+ create/update on a compute service (EC2RunInstances, LambdaCreateFunction/UpdateFunctionConfiguration, ECSRegisterTaskDefinition, Glue, SageMaker, CloudFormation, etc.) = privilege escalation to any passable role in the account, including Administrator. ScopeResourceto specific role ARNs or an IAM path; optionally constrain withiam:PassedToService/iam:AssociatedResourceArn. See IAM User Guide — Grant a user permissions to pass a role.
MFA:
- Unassigned virtual MFA devices auto-deleted when adding new ones.
- MFA resync-only policy NotAction needs exactly: iam:ListMFADevices, iam:ListVirtualMFADevices, iam:ResyncMFADevice.
SigV4:
- IncompleteSignatureException includes SHA-256 hash of Authorization header for transit modification diagnosis.
Service-Specific Roles:
- Redshift Serverless trust policy: include BOTH
redshift-serverless.amazonaws.comANDredshift.amazonaws.comas service principals (per AWS docs; omitting serverless causesNot authorized to get credentials of roleon COPY). - IAM OIDC providers: thumbprints are not required for most providers (AWS verifies via trusted CAs).
Policy Summary Display:
- Single statement with multi-service wildcard actions (e.g.
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 による自動翻訳です。