翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
条件キーの使用
IAM ポリシーを有効にする方法を決める条件を指定できます。ElastiCache では、JSON ポリシーの Condition
要素を使用して、リクエストコンテキストのキーを、ポリシーで指定したキー値と比較できます。ポリシー要素の詳細については、IAM JSON policy elements: Condition を参照してください。
ElastiCache の条件キーのリストを確認するには、「サービス認可リファレンス」の「Amazon ElastiCache の条件キー」を参照してください。
グローバル条件キーのリストについては、「AWS グローバル条件コンテキストキー」を参照してください。
条件の指定: 条件キーの使用
きめ細かなコントロールを実装するには、特定のリクエストに対して個別のパラメータセットを制御するための条件を指定した IAM アクセス許可ポリシーを作成します。次に、IAM コンソールを使用して作成する IAM ユーザー、グループ、またはロールにそのポリシーを適用します。
条件を適用するには、条件情報を IAM ポリシーステートメントに追加します。次の例では、独自に設計されたすべてのキャッシュクラスターがノードタイプ cache.r5.large
になるという条件を指定します。
注記
String
タイプの条件キーを使用してCondition
要素を構築するには、大文字と小文字を区別しない条件演算子を使用するStringEqualsIgnoreCase
か、StringNotEqualsIgnoreCase
を使用してキーを文字列値と比較します。ElastiCache は、大文字と小文字
CacheParameterGroupName
を区別しない方法でCacheNodeType
および の入力引数を処理します。このため、文字列条件演算子 および はStringEqualsIgnoreCase
、それらを参照するアクセス許可ポリシーで使用StringNotEqualsIgnoreCase
する必要があります。
以下に、Valkey または Redis OSS を使用する場合のこのアクセス許可ポリシーの例を示します。
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "elasticache:CreateCacheCluster", "elasticache:CreateReplicationGroup" ], "Resource": [ "arn:aws:elasticache:*:*:parametergroup:*", "arn:aws:elasticache:*:*:subnetgroup:*" ] }, { "Effect": "Allow", "Action": [ "elasticache:CreateCacheCluster", "elasticache:CreateReplicationGroup" ], "Resource": [ "arn:aws:elasticache:*:*:cluster:*", "arn:aws:elasticache:*:*:replicationgroup:*" ], "Condition": { "StringEquals": { "elasticache:CacheNodeType": [ "cache.r5.large" ] } } } ] }
以下に、Memcached を使用する場合のこのアクセス許可ポリシーの例を示します。
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "elasticache:CreateCacheCluster" ], "Resource": [ "arn:aws:elasticache:*:*:parametergroup:*", "arn:aws:elasticache:*:*:subnetgroup:*" ] }, { "Effect": "Allow", "Action": [ "elasticache:CreateCacheCluster" ], "Resource": [ "arn:aws:elasticache:*:*:cluster:*" ], "Condition": { "StringEquals": { "elasticache:CacheNodeType": [ "cache.r5.large" ] } } } ] }
詳細については、「ElastiCache リソースのタグ付け」を参照してください。
ポリシー条件演算子の使用に関する詳細については、「ElastiCache API のアクセス許可: アクション、リソース、条件リファレンス」を参照してください。
ポリシー例: きめ細かなパラーメータコントロールのための IAM ポリシー条件の使用
このセクションでは、前述の ElastiCache パラメータに対してきめ細かなアクセスコントロールを実装するためのポリシー例について説明します。
elasticache:MaximumDataStorage: サーバーレスキャッシュの最大データストレージを指定します。指定された条件を使用して、特定の量を超えるデータを保存できるキャッシュを作成することはできません。
{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowDependentResources", "Effect": "Allow", "Action": [ "elasticache:CreateServerlessCache" ], "Resource": [ "arn:aws:elasticache:*:*:serverlesscachesnapshot:*", "arn:aws:elasticache:*:*:snapshot:*", "arn:aws:elasticache:*:*:usergroup:*" ] }, { "Effect": "Allow", "Action": [ "elasticache:CreateServerlessCache" ], "Resource": [ "arn:aws:elasticache:*:*:serverlesscache:*" ], "Condition": { "NumericLessThanEquals": { "elasticache:MaximumDataStorage": "30" }, "StringEquals": { "elasticache:DataStorageUnit": "GB" } } } ] }
elasticache:MaximumECPUPerSecond: サーバーレスキャッシュの 1 秒あたりの最大 ECPU 値を指定します。指定された条件では、1 秒あたりに特定の数を超える ECPU を実行できるキャッシュを作成することはできません。
{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowDependentResources", "Effect": "Allow", "Action": [ "elasticache:CreateServerlessCache" ], "Resource": [ "arn:aws:elasticache:*:*:serverlesscachesnapshot:*", "arn:aws:elasticache:*:*:snapshot:*", "arn:aws:elasticache:*:*:usergroup:*" ] }, { "Effect": "Allow", "Action": [ "elasticache:CreateServerlessCache" ], "Resource": [ "arn:aws:elasticache:*:*:serverlesscache:*" ], "Condition": { "NumericLessThanEquals": { "elasticache:MaximumECPUPerSecond": "100000" } } } ] }
elasticache:CacheNodeType: ユーザーが作成できる NodeType を指定します。指定された条件を使用して、ノードタイプの単一値または範囲値を指定できます。
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "elasticache:CreateCacheCluster", "elasticache:CreateReplicationGroup" ], "Resource": [ "arn:aws:elasticache:*:*:parametergroup:*", "arn:aws:elasticache:*:*:subnetgroup:*" ] }, { "Effect": "Allow", "Action": [ "elasticache:CreateCacheCluster", "elasticache:CreateReplicationGroup" ], "Resource": [ "arn:aws:elasticache:*:*:cluster:*", "arn:aws:elasticache:*:*:replicationgroup:*" ], "Condition": { "StringEquals": { "elasticache:CacheNodeType": [ "cache.t2.micro", "cache.t2.medium" ] } } } ] }
elasticache:CacheNodeType: Memcached で、ユーザーが作成できる NodeType を指定します。指定された条件を使用して、ノードタイプの単一値または範囲値を指定できます。
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "elasticache:CreateCacheCluster" ], "Resource": [ "arn:aws:elasticache:*:*:parametergroup:*", "arn:aws:elasticache:*:*:subnetgroup:*" ] }, { "Effect": "Allow", "Action": [ "elasticache:CreateCacheCluster" ], "Resource": [ "arn:aws:elasticache:*:*:cluster:*" ], "Condition": { "StringEquals": { "elasticache:CacheNodeType": [ "cache.t2.micro", "cache.t2.medium" ] } } } ] }
elasticache:NumNodeGroups: 20 未満のノードグループを持つレプリケーショングループを作成します。
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "elasticache:CreateReplicationGroup" ], "Resource": [ "arn:aws:elasticache:*:*:parametergroup:*", "arn:aws:elasticache:*:*:subnetgroup:*" ] }, { "Effect": "Allow", "Action": [ "elasticache:CreateReplicationGroup" ], "Resource": [ "arn:aws:elasticache:*:*:replicationgroup:*" ], "Condition": { "NumericLessThanEquals": { "elasticache:NumNodeGroups": "20" } } } ] }
elasticache:ReplicasPerNodeGroup: ノードごとのレプリカを 5~10 の間で指定します。
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "elasticache:CreateReplicationGroup" ], "Resource": [ "arn:aws:elasticache:*:*:parametergroup:*", "arn:aws:elasticache:*:*:subnetgroup:*" ] }, { "Effect": "Allow", "Action": [ "elasticache:CreateReplicationGroup" ], "Resource": [ "arn:aws:elasticache:*:*:replicationgroup:*" ], "Condition": { "NumericGreaterThanEquals": { "elasticache:ReplicasPerNodeGroup": "5" }, "NumericLessThanEquals": { "elasticache:ReplicasPerNodeGroup": "10" } } } ] }
elasticache:EngineVersion: バージョン 5.0.6 の使用量を指定します。
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "elasticache:CreateCacheCluster", "elasticache:CreateReplicationGroup" ], "Resource": [ "arn:aws:elasticache:*:*:parametergroup:*", "arn:aws:elasticache:*:*:subnetgroup:*" ] }, { "Effect": "Allow", "Action": [ "elasticache:CreateCacheCluster", "elasticache:CreateReplicationGroup" ], "Resource": [ "arn:aws:elasticache:*:*:cluster:*", "arn:aws:elasticache:*:*:replicationgroup:*" ], "Condition": { "StringEquals": { "elasticache:EngineVersion": "5.0.6" } } } ] }
elasticache:EngineVersion: Memcached エンジンバージョン 1.6.6 の使用量を指定します
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "elasticache:CreateCacheCluster" ], "Resource": [ "arn:aws:elasticache:*:*:parametergroup:*", "arn:aws:elasticache:*:*:subnetgroup:*" ] }, { "Effect": "Allow", "Action": [ "elasticache:CreateCacheCluster" ], "Resource": [ "arn:aws:elasticache:*:*:cluster:*" ], "Condition": { "StringEquals": { "elasticache:EngineVersion": "1.6.6" } } } ] }
elasticache:EngineType: Valkey または Redis OSS エンジンのみを使用するよう指定します。
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "elasticache:CreateCacheCluster", "elasticache:CreateReplicationGroup" ], "Resource": [ "arn:aws:elasticache:*:*:parametergroup:*", "arn:aws:elasticache:*:*:subnetgroup:*" ] }, { "Effect": "Allow", "Action": [ "elasticache:CreateCacheCluster", "elasticache:CreateReplicationGroup" ], "Resource": [ "arn:aws:elasticache:*:*:cluster:*", "arn:aws:elasticache:*:*:replicationgroup:*" ], "Condition": { "StringEquals": { "elasticache:EngineType": "redis" } } } ] }
elasticache:AtRestEncryptionEnabled: レプリケーショングループが暗号化を有効にしてのみ作成されるように指定します。
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "elasticache:CreateReplicationGroup" ], "Resource": [ "arn:aws:elasticache:*:*:parametergroup:*", "arn:aws:elasticache:*:*:subnetgroup:*" ] }, { "Effect": "Allow", "Action": [ "elasticache:CreateReplicationGroup" ], "Resource": [ "arn:aws:elasticache:*:*:replicationgroup:*" ], "Condition": { "Bool": { "elasticache:AtRestEncryptionEnabled": "true" } } } ] }
-
elasticache:TransitEncryptionEnabled
-
CreateReplicationGroup アクションの
elasticache:TransitEncryptionEnabled
条件キーをfalse
に設定して、TLS を使用していない場合にのみレプリケーショングループを作成できるように指定します。{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "elasticache:CreateReplicationGroup" ], "Resource": [ "arn:aws:elasticache:*:*:parametergroup:*", "arn:aws:elasticache:*:*:subnetgroup:*" ] }, { "Effect": "Allow", "Action": [ "elasticache:CreateReplicationGroup" ], "Resource": [ "arn:aws:elasticache:*:*:replicationgroup:*" ], "Condition": { "Bool": { "elasticache:TransitEncryptionEnabled": "false" } } } ] }
CreateReplicationGroup アクションのポリシーで
elasticache:TransitEncryptionEnabled
条件キーがfalse
に設定されている場合、TLS が使用されていない (つまり、リクエストでTransitEncryptionEnabled
パラメータがtrue
に設定されていない、またはTransitEncryptionMode
パラメータがrequired
に設定されている) 場合のみCreateReplicationGroup
リクエストが許可されます。 -
CreateReplicationGroup アクションの
elasticache:TransitEncryptionEnabled
条件キーをtrue
に設定して、TLS が使用されている場合にのみレプリケーショングループを作成できるように指定します。{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "elasticache:CreateReplicationGroup" ], "Resource": [ "arn:aws:elasticache:*:*:parametergroup:*", "arn:aws:elasticache:*:*:subnetgroup:*" ] }, { "Effect": "Allow", "Action": [ "elasticache:CreateReplicationGroup" ], "Resource": [ "arn:aws:elasticache:*:*:replicationgroup:*" ], "Condition": { "Bool": { "elasticache:TransitEncryptionEnabled": "true" } } } ] }
CreateReplicationGroup アクションのポリシーで
elasticache:TransitEncryptionEnabled
条件キーがtrue
に設定されている場合、リクエストでTransitEncryptionEnabled
パラメータがtrue
に設定されていて、TransitEncryptionMode
パラメータがrequired
に設定されている場合のみCreateReplicationGroup
リクエストが許可されます。 -
ModifyReplicationGroup
アクションで、TLS が使用されている場合にのみレプリケーショングループを変更できるように指定するには、elasticache:TransitEncryptionEnabled
をtrue
に設定します。{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "elasticache:ModifyReplicationGroup" ], "Resource": [ "arn:aws:elasticache:*:*:replicationgroup:*" ], "Condition": { "BoolIfExists": { "elasticache:TransitEncryptionEnabled": "true" } } } ] }
CreateReplicationGroup アクションのポリシーで
elasticache:TransitEncryptionEnabled
条件キーがtrue
に設定されている場合、リクエストでTransitEncryptionMode
パラメータがrequired
に設定されている場合のみModifyReplicationGroup
リクエストが許可されます。true
に設定したTransitEncryptionEnabled
パラメータもオプションで含めることができますが、これは TLS を有効にするには必要ありません。
-
-
elasticache:AutomaticFailoverEnabled: レプリケーショングループが自動フェイルオーバーを有効にしてのみ作成されるように指定します。
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "elasticache:CreateReplicationGroup" ], "Resource": [ "arn:aws:elasticache:*:*:parametergroup:*", "arn:aws:elasticache:*:*:subnetgroup:*" ] }, { "Effect": "Allow", "Action": [ "elasticache:CreateReplicationGroup" ], "Resource": [ "arn:aws:elasticache:*:*:replicationgroup:*" ], "Condition": { "Bool": { "elasticache:AutomaticFailoverEnabled": "true" } } } ] }
elasticache:MultiAZEnabled: レプリケーショングループがマルチ AZ を無効にしては作成できないように指定します。
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "elasticache:CreateCacheCluster", "elasticache:CreateReplicationGroup" ], "Resource": [ "arn:aws:elasticache:*:*:parametergroup:*", "arn:aws:elasticache:*:*:subnetgroup:*" ] }, { "Effect": "Deny", "Action": [ "elasticache:CreateCacheCluster", "elasticache:CreateReplicationGroup" ], "Resource": [ "arn:aws:elasticache:*:*:cluster:*", "arn:aws:elasticache:*:*:replicationgroup:*" ], "Condition": { "Bool": { "elasticache:MultiAZEnabled": "false" } } } ] }
elasticache:ClusterModeEnabled: レプリケーショングループがクラスターモードを有効にしてのみ作成できるように指定します。
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "elasticache:CreateReplicationGroup" ], "Resource": [ "arn:aws:elasticache:*:*:parametergroup:*", "arn:aws:elasticache:*:*:subnetgroup:*" ] }, { "Effect": "Allow", "Action": [ "elasticache:CreateReplicationGroup" ], "Resource": [ "arn:aws:elasticache:*:*:replicationgroup:*" ], "Condition": { "Bool": { "elasticache:ClusterModeEnabled": "true" } } } ] }
elasticache:AuthTokenEnabled: レプリケーショングループが AUTH トークンを有効にしてのみ作成できるように指定します。
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "elasticache:CreateCacheCluster", "elasticache:CreateReplicationGroup" ], "Resource": [ "arn:aws:elasticache:*:*:parametergroup:*", "arn:aws:elasticache:*:*:subnetgroup:*" ] }, { "Effect": "Allow", "Action": [ "elasticache:CreateCacheCluster", "elasticache:CreateReplicationGroup" ], "Resource": [ "arn:aws:elasticache:*:*:cluster:*", "arn:aws:elasticache:*:*:replicationgroup:*" ], "Condition": { "Bool": { "elasticache:AuthTokenEnabled": "true" } } } ] }
elasticache:SnapshotRetentionLimit: スナップショットを保持する日数 (または最小/最大) を指定します。以下のポリシーは、少なくとも 30 日間バックアップを保存することを強制します。
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "elasticache:CreateCacheCluster", "elasticache:CreateReplicationGroup" ], "Resource": [ "arn:aws:elasticache:*:*:parametergroup:*", "arn:aws:elasticache:*:*:subnetgroup:*" ] }, { "Effect": "Allow", "Action": [ "elasticache:CreateCacheCluster", "elasticache:CreateReplicationGroup", "elasticache:CreateServerlessCache" ], "Resource": [ "arn:aws:elasticache:*:*:cluster:*", "arn:aws:elasticache:*:*:replicationgroup:*", "arn:aws:elasticache:*:*:serverlesscache:*" ], "Condition": { "NumericGreaterThanEquals": { "elasticache:SnapshotRetentionLimit": "30" } } } ] }
elasticache:KmsKeyId: カスタマーマネージド KMS AWS キーの使用を指定します。
{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowDependentResources", "Effect": "Allow", "Action": [ "elasticache:CreateServerlessCache" ], "Resource": [ "arn:aws:elasticache:*:*:serverlesscachesnapshot:*", "arn:aws:elasticache:*:*:snapshot:*", "arn:aws:elasticache:*:*:usergroup:*" ] }, { "Effect": "Allow", "Action": [ "elasticache:CreateServerlessCache" ], "Resource": [ "arn:aws:elasticache:*:*:serverlesscache:*" ], "Condition": { "StringEquals": { "elasticache:KmsKeyId": "my-key" } } } ] }
elasticache:CacheParameterGroupName: クラスター上の組織の特定のパラメータを使用して、デフォルト以外のパラメータグループを指定します。パラメータグループの命名パターンを指定したり、特定のパラメータグループ名に対するブロック削除を指定することもできます。以下は、「my-org-param-group」のみの使用量を制限する例です。
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "elasticache:CreateCacheCluster", "elasticache:CreateReplicationGroup" ], "Resource": [ "arn:aws:elasticache:*:*:parametergroup:*", "arn:aws:elasticache:*:*:subnetgroup:*" ] }, { "Effect": "Allow", "Action": [ "elasticache:CreateCacheCluster", "elasticache:CreateReplicationGroup" ], "Resource": [ "arn:aws:elasticache:*:*:cluster:*", "arn:aws:elasticache:*:*:replicationgroup:*" ], "Condition": { "StringEquals": { "elasticache:CacheParameterGroupName": "my-org-param-group" } } } ] }
elasticache:CacheParameterGroupName: Memcached で、クラスター上の組織の特定のパラメータを使用して、デフォルト以外のパラメータグループを指定します。パラメータグループの命名パターンを指定したり、特定のパラメータグループ名に対するブロック削除を指定することもできます。以下は、「my-org-param-group」のみの使用量を制限する例です。
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "elasticache:CreateCacheCluster" ], "Resource": [ "arn:aws:elasticache:*:*:parametergroup:*", "arn:aws:elasticache:*:*:subnetgroup:*" ] }, { "Effect": "Allow", "Action": [ "elasticache:CreateCacheCluster" ], "Resource": [ "arn:aws:elasticache:*:*:cluster:*" ], "Condition": { "StringEquals": { "elasticache:CacheParameterGroupName": "my-org-param-group" } } } ] }
-
elasticache:CreateCacheCluster: リクエストタグ
Project
が欠落しているか、Dev
、QA
、またはProd
と等しくない場合、CreateCacheCluster
アクションが拒否されます。{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "elasticache:CreateCacheCluster" ], "Resource": [ "arn:aws:elasticache:*:*:parametergroup:*", "arn:aws:elasticache:*:*:subnetgroup:*", "arn:aws:elasticache:*:*:securitygroup:*", "arn:aws:elasticache:*:*:replicationgroup:*" ] }, { "Effect": "Deny", "Action": [ "elasticache:CreateCacheCluster" ], "Resource": [ "arn:aws:elasticache:*:*:cluster:*" ], "Condition": { "Null": { "aws:RequestTag/Project": "true" } } }, { "Effect": "Allow", "Action": [ "elasticache:CreateCacheCluster", "elasticache:AddTagsToResource" ], "Resource": "arn:aws:elasticache:*:*:cluster:*", "Condition": { "StringEquals": { "aws:RequestTag/Project": [ "Dev", "Prod", "QA" ] } } } ] }
elasticache:CacheNodeType:
cacheNodeType
cache.r5.large または cache.r6g.4xlarge を使用したCreateCacheCluster
およびタグProject=XYZ
を許可します。{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "elasticache:CreateCacheCluster", "elasticache:CreateReplicationGroup" ], "Resource": [ "arn:aws:elasticache:*:*:parametergroup:*", "arn:aws:elasticache:*:*:subnetgroup:*" ] }, { "Effect": "Allow", "Action": [ "elasticache:CreateCacheCluster" ], "Resource": [ "arn:aws:elasticache:*:*:cluster:*" ], "Condition": { "StringEqualsIfExists": { "elasticache:CacheNodeType": [ "cache.r5.large", "cache.r6g.4xlarge" ] }, "StringEquals": { "aws:RequestTag/Project": "XYZ" } } } ] }
elasticache:CacheNodeType:
cacheNodeType
cache.r5.large または cache.r6g.4xlarge を使用したCreateCacheCluster
およびタグProject=XYZ
を許可します。{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "elasticache:CreateCacheCluster" ], "Resource": [ "arn:aws:elasticache:*:*:parametergroup:*", "arn:aws:elasticache:*:*:subnetgroup:*" ] }, { "Effect": "Allow", "Action": [ "elasticache:CreateCacheCluster" ], "Resource": [ "arn:aws:elasticache:*:*:cluster:*" ], "Condition": { "StringEqualsIfExists": { "elasticache:CacheNodeType": [ "cache.r5.large", "cache.r6g.4xlarge" ] }, "StringEquals": { "aws:RequestTag/Project": "XYZ" } } } ] }
注記
タグやその他の条件キーを一緒に強制するポリシーを作成する際は、条件付き IfExists
は、--tags
パラメータを用いた作成リクエストの追加の elasticache:AddTagsToResource
ポリシー要件が原因で、条件キー要素で必要となる場合があります。