• Projects
  • Service
  • About
  • branding.bz
  • Podcast
  • Tips
  • FAQ
  • Recruit
  • Download
  • Contact
  • branding.bz(ブランド構築SaaS)
  • DESIGN NOW(デザインメディア)
  • X
  • LinkedIn
  • Spotify
  • Facebook

213-0011 神奈川県川崎市高津区久本3-6-7-303

© 2026 ID INC. All rights reserved

claude-skills/スキル
SKILLOfficialdevelopment

aws-iam

プラグイン
aws-core
ソース
GitHub で見る ↗
説明

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.

ユースケース
  • IAMロールを作成するとき
  • IAMポリシーやバケットポリシーを記述するとき
  • アプリケーションやTerraformからポリシーを自動生成するとき
  • STS・Organizations・条件演算子を操作するとき
  • サービスロールや実行ロールを設定するとき
本文(日本語訳)

AWS IAM — よくある落とし穴

このスキルについて

このスキルには、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:

  • AcceptHandshake/DeclineHandshake は実行アカウントのみログに記録され、管理アカウント(organization 全体を管理するアカウント)には記録されません。一元化には Organization trail(全体ログ)が必要です。
  • ConsoleLogin のリージョン(データセンター所在地)は us-east-1 とは限らず、エンドポイント設定やクッキーによって変わります。?region= パラメータで特定のリージョンを強制できます。

STS(一時認証情報発行サービス):

  • GetSessionToken の制限: (1) MFA を含めない場合は IAM API 使用不可 (2) STS では AssumeRole と GetCallerIdentity のみ使用可能。
  • クロスアカウント AssumeRole(別のアカウント内の権限に切り替え)でオプトイン地域に接続する場合: 呼び出し元アカウントではなく、対象アカウント側がリージョンを有効化する必要があります。
  • ロールチェーン(複数ロール経由での認証切り替え): 最大セッション継続時間は 1 時間です。

Organizations(複数 AWS アカウント管理):

  • 一時停止中または閉鎖中のアカウントは、完全に閉鎖されるまで(約 90 日間)削除できません。削除は先に行い、その後に閉鎖してください。
  • ポリシー管理の委譲: register-delegated-administrator ではなく PutResourcePolicy を使用してください。
  • AI オプトアウトポリシー: デフォルトでは管理アカウント側の設定が必要です。
  • Organizations ポリシータイプの一覧表示フィルター: aws organizations list-available-policy-types コマンドまたは Organizations API リファレンス で現在のリストを取得してください。

SDK(プログラミングツール)の固有仕様:

  • Organizations: DuplicatePolicyAttachmentException です(PolicyAlreadyAttachedException ではありません)。
  • Boto3(Python AWS ツール)の IAM AccessKey メソッド: activate()、deactivate()、delete() があります。update() はありません。
  • インスタンスプロフィール(EC2 に割り当てられた権限セット): waiter(完了待ち)と time.sleep(10) パターンを組み合わせます。
  • 管理ポリシー(AWS が管理・複数アカウントで共有できるポリシー)の最大バージョン数: 5。

SAML(シングルサインオン):

  • 暗号化されたアサーション(認証情報)URL: https://region-code.signin.aws.amazon.com/saml/acs/IdP-ID
  • IdP(外部認証システム)から取得した秘密鍵は .pem 形式で IAM にアップロードします。

ポリシー評価:

  • 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):

  • 割り当てられていない仮想 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 コマンド実行時に「ロール認証情報取得権限なし」エラーが発生します。
  • IAM OIDC プロバイダー(OpenID Connect による外部認証連携): 多くのプロバイダーではサムプリント(証明書の指紋)は不要です(AWS が信頼できる認証局経由で検証)。

ポリシーサマリー表示:

  • 複数サービスワイルドカードアクション(例: codebuild:*、codecommit:*)を含む単一ステートメント + サービス固有のリソース ARN: 各リソースはそのサービスのサマリーにのみ表示されます(CodeBuild ARN は CodeBuild の下に等)。ステートメント内のどのアクションにも一致しないサービスプレフィックスを持つリソースのみ、すべてのアクションサマリーに表示されます(「リソースサービス不一致」)。
原文(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 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.

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-types or the Organizations API reference.

SDK Specifics:

  • Organizations: DuplicatePolicyAttachmentException (not PolicyAlreadyAttachedException).
  • Boto3 IAM AccessKey: methods are activate(), deactivate(), delete() — NO update().
  • 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 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:

  • 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.com AND redshift.amazonaws.com as service principals (per AWS docs; omitting serverless causes Not authorized to get credentials of role on 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 による自動翻訳です。