一般的なポリシーパターン
これらの例は、頻繁に使用される Cedar ポリシーパターンを示しています。パターンは OAuth 認証と IAM 認証の両方で機能します。AgentCore Gateway 設定に適したプリンシパルタイプを選択します。プリンシパル属性の詳細については、「プリンシパル属性」を参照してください。
これらのパターンは、認証タイプに関係なく適用されます。
緊急シャットダウン
Gateway 全体のすべてのツール呼び出しを無効にします。
forbid( principal, action, resource );
ユースケース: 緊急シャットダウン、メンテナンスモード、またはインシデント対応。
効果: forbid-wins セマンティクスにより、すべての許可ポリシーを上書きします。
特定のツールを無効にする
特定のツールを無効にし、他のツールを運用できるようにします。
forbid( principal, action == AgentCore::Action::"RefundTool___process_refund", resource == AgentCore::Gateway::"arn:aws:bedrock-agentcore:us-west-2:123456789012:gateway/refund-gateway" );
ユースケース: 他の機能に影響を与えずに、問題のあるツールを一時的に無効にします。
ユーザーアクセスのブロック
特定のユーザーまたはアカウントがアクションを実行できないようにします。
OAuth: 特定のユーザーをブロックする
ユーザー名タグを一致させてユーザーをブロックします。
forbid( principal is AgentCore::OAuthUser, action, resource ) when { principal.hasTag("username") && principal.getTag("username") == "suspended-user" };
ユースケース: 侵害されたユーザーアカウントまたは停止されたユーザーアカウントのアクセスを直ちに取り消す。
IAM: 特定のアカウントをブロックする
特定の AWS アカウントから発信者をブロックします。
forbid( principal is AgentCore::IamEntity, action, resource ) when { principal.id like "*:444455556666:*" };
ユースケース: テストアカウントまたは不正なアカウントが本番稼働用ツールにアクセスできないようにします。このパターンは、そのアカウント ID を含む任意の ARN 形式 (引き受けたロール、IAM ユーザー、または IAM ロール) :444455556666: と一致します。
ロールベースアクセスコントロール
ロールに基づいてアクセスを制限します。OAuth はロールタグを使用します。IAM はロール ARN パターンを使用します。
OAuth: ロールタグの使用
特定のロールを持つユーザーのみにアクセスを許可します。
permit( principal is AgentCore::OAuthUser, action == AgentCore::Action::"AdminAPI___delete_resource", resource == AgentCore::Gateway::"arn:aws:bedrock-agentcore:us-west-2:123456789012:gateway/admin" ) when { principal.hasTag("role") && (principal.getTag("role") == "admin" || principal.getTag("role") == "manager") };
ユースケース: 管理者ロールまたはマネージャーロールを持つユーザーのみに管理オペレーションを許可します。
IAM: IAM ロール ARNs
特定の IAM ロールを使用する発信者にのみアクセスを許可します。完全principal ==一致またはprincipal.id likeパターン一致を使用できます。
// Exact match (recommended for single-role policies) permit( principal == AgentCore::IamEntity::"arn:aws:sts::123456789012:assumed-role/AdminRole", action == AgentCore::Action::"AdminAPI___delete_resource", resource == AgentCore::Gateway::"arn:aws:bedrock-agentcore:us-west-2:123456789012:gateway/admin" );
ユースケース: AdminRole IAM ロールを引き受ける発信者にのみ管理オペレーションを許可します。引き受けたロールの Cedar エンティティ ID は、 形式を使用しますarn:aws:sts::<account>:assumed-role/<role-name>。
パターンマッチングを使用したバリエーション:
// Match a specific role from any account principal.id like "arn:aws:sts::*:assumed-role/AdminRole" // Match any role in a specific account principal.id like "arn:aws:sts::123456789012:assumed-role/*"
データ型オペレーション
Cedar は、条件でさまざまなデータ型をサポートしています。これらの例では、OAuth プリンシパル () AgentCore::OAuthUser を使用します。IAM 認証ゲートウェイの場合は、AgentCore::IamEntity代わりに を使用します。入力検証ロジックは同じままです。
整数 (ロング)
// Check if passenger count is exactly 2 permit( principal is AgentCore::OAuthUser, action == AgentCore::Action::"TravelAPI___search_flights", resource == AgentCore::Gateway::"arn:aws:bedrock-agentcore:us-west-2:123456789012:gateway/travel" ) when { context.input.passengers == 2 };
文字列
// Check if payment method is credit card permit( principal is AgentCore::OAuthUser, action == AgentCore::Action::"PaymentAPI___process_payment", resource == AgentCore::Gateway::"arn:aws:bedrock-agentcore:us-west-2:123456789012:gateway/payment" ) when { context.input.paymentMethod == "credit-card" };
リスト (セット)
// Check if country is in allowed list permit( principal is AgentCore::OAuthUser, action == AgentCore::Action::"ShippingAPI___calculate_rate", resource == AgentCore::Gateway::"arn:aws:bedrock-agentcore:us-west-2:123456789012:gateway/shipping" ) when { ["US", "CA", "MX"].contains(context.input.country) };
オプションのフィールドの確認
// Require optional field to be present permit( principal is AgentCore::OAuthUser, action == AgentCore::Action::"OrderAPI___create_order", resource == AgentCore::Gateway::"arn:aws:bedrock-agentcore:us-west-2:123456789012:gateway/order" ) when { context.input has shippingAddress };