Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅
中国的 Amazon Web Services 服务入门
(PDF)。
本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
使用条件键
您可以指定决定 IAM 策略如何生效的条件。在 ElastiCache,你可以使用 Condition JSON 策略的元素,用于将请求上下文中的密钥与您在策略中指定的密钥值进行比较。有关更多信息,请参阅 IAM JSON 策略元素:条件。
要查看清单 ElastiCache 条件键,请参阅 亚马逊条件密钥 ElastiCache 在 服务授权参考。
有关全局条件键的列表,请参阅 Amazon 全局条件上下文键。
使用 ElastiCache 和 Amazon 全局条件密钥
使用时 Amazon 全局条件键 这需要 ElastiCache的 校长,使用 OR 条件为 都 校长: elasticache.amazonaws.com 和 ec.amazonaws.com。
如果您没有将两个校长都添加到 ElastiCache,将无法对您的策略中列出的任何资源正确执行预期的 “允许” 或 “拒绝” 操作。
带有 aws:CalledVia 全局条件键的策略示例:
- JSON
-
-
{
"Version":"2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "ec2:*",
"Resource": "*",
"Condition": {
"ForAnyValue:StringLike": {
"aws:CalledVia": [
"ec.amazonaws.com",
"elasticache.amazonaws.com"
]
}
}
}
]
}
指定条件:使用条件键
要实现精细控制,您需要编写 IAM 权限策略,用于指定控制某些请求上单独参数集的条件。然后,将该策略应用于您使用 IAM 控制台创建的 IAM 用户、组或角色。
要应用条件,请将条件信息添加到 IAM policy 语句。在以下示例中,您指定了条件,为创建的所有基于节点的集群使用节点类型 cache.r5.large。
要使用 String 类型的条件键构造 Condition 元素,请使用不区分大小写的条件运算符 StringEqualsIgnoreCase 或 StringNotEqualsIgnoreCase 将键与字符串值进行比较。
ElastiCache 处理的输入参数 CacheNodeType 和 CacheParameterGroupName 以不区分大小写的方式。因此,在引用这些参数的权限策略中,应使用字符串条件运算符 StringEqualsIgnoreCase 和 StringNotEqualsIgnoreCase。
下面展示了使用 Valkey 或 Redis OSS 时的权限策略示例。
- JSON
-
-
{
"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 时的权限策略示例。
- JSON
-
-
{
"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 权限:操作、资源和条件参考。
策略示例:使用条件 Fine-Grained 参数控制
本节显示了对前面列出的实施细粒度访问控制的策略示例 ElastiCache 参数。
弹性缓存:MaximumDataStorage:指定无服务器缓存的最大数据存储空间。使用提供的条件,客户不能创建存储超过特定数量数据的缓存。
- JSON
-
-
{
"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"
}
}
}
]
}
弹性缓存:MaximumECPUPerSecond:指定无服务器缓存的每秒最大 ECPU 值。使用提供的条件,客户不能创建每秒执行的 ECPU 数超过特定数量的缓存。
- JSON
-
-
{
"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"
}
}
}
]
}
弹性缓存:CacheNodeType: 指定哪个 NodeType(s) 用户可以创建。使用提供的条件,客户可以为节点类型指定单个值或范围值。
- JSON
-
-
{
"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"
]
}
}
}
]
}
弹性缓存:CacheNodeType: 使用 Memcached,指定哪个 NodeType(s) 用户可以创建。使用提供的条件,客户可以为节点类型指定单个值或范围值。
- JSON
-
-
{
"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"
]
}
}
}
]
}
弹性缓存:NumNodeGroups:创建少于 20 个节点组的复制组。
- JSON
-
-
{
"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"
}
}
}
]
}
弹性缓存:ReplicasPerNodeGroup:指定介于 5 到 10 之间的每个节点的副本。
- JSON
-
-
{
"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"
}
}
}
]
}
弹性缓存:EngineVersion:指定引擎版本 5.0.6 的用法。
- JSON
-
-
{
"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"
}
}
}
]
}
弹性缓存:EngineVersion: 指定 Memcached 引擎版本 1.6.6 的用法
- JSON
-
-
{
"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"
}
}
}
]
}
弹性缓存:EngineType:仅使用 Valkey 或 Redis OSS 引擎指定。
- JSON
-
-
{
"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"
}
}
}
]
}
弹性缓存:AtRestEncryptionEnabled:指定仅在启用加密的情况下创建复制组。
- JSON
-
-
{
"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"
}
}
}
]
}
-
弹性缓存:TransitEncryptionEnabled
-
设置 elasticache:TransitEncryptionEnabled 条件密钥 false 对于 CreateReplicationGroup 指定只有在不使用 TLS 时才能创建复制组的操作:
- JSON
-
-
{
"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"
}
}
}
]
}
当 elasticache:TransitEncryptionEnabled 条件键设置为 false 在保单中 CreateReplicationGroup 动作,a CreateReplicationGroup 只有在不使用 TLS 时才允许请求(即,如果请求不包含 TransitEncryptionEnabled 参数设置为 true 或者 TransitEncryptionMode 参数设置为 required。
-
设置 elasticache:TransitEncryptionEnabled 条件键 true 对于 CreateReplicationGroup 指定只有在使用 TLS 时才能创建复制组的操作:
- JSON
-
-
{
"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"
}
}
}
]
}
当 elasticache:TransitEncryptionEnabled 条件键设置为 true 在保单中 CreateReplicationGroup 动作,a CreateReplicationGroup 仅当请求包含以下内容时,才允许请求 TransitEncryptionEnabled 参数设置为 true 还有一个 TransitEncryptionMode 参数设置为 required。
-
针对 ModifyReplicationGroup 操作将 elasticache:TransitEncryptionEnabled 设置为 true,以指定只有在使用 TLS 时才能修改复制组:
- JSON
-
-
{
"Version":"2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"elasticache:ModifyReplicationGroup"
],
"Resource": [
"arn:aws:elasticache:*:*:replicationgroup:*"
],
"Condition": {
"BoolIfExists": {
"elasticache:TransitEncryptionEnabled": "true"
}
}
}
]
}
当 elasticache:TransitEncryptionEnabled 条件键设置为 true 在保单中 ModifyReplicationGroup 动作,a ModifyReplicationGroup 仅当请求包含以下内容时,才允许请求 TransitEncryptionMode 参数设置为 required。也可以选择包含设置为 true 的 TransitEncryptionEnabled 参数,但在这种情况下,该设置并不是启用 TLS 所必需的。
-
弹性缓存:AutomaticFailoverEnabled:指定仅在启用自动故障转移的情况下创建复制组。
- JSON
-
-
{
"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: 启用多可用区:指定不能使用创建复制组 Multi-AZ 已禁用。
- JSON
-
-
{
"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"
}
}
}
]
}
弹性缓存:ClusterModeEnabled:指定只能在启用集群模式的情况下创建复制组。
- JSON
-
-
{
"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"
}
}
}
]
}
弹性缓存:AuthTokenEnabled:指定只能在启用 AUTH 令牌的情况下创建复制组。
- JSON
-
-
{
"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"
}
}
}
]
}
弹性缓存:SnapshotRetentionLimit: 指定天数(或 min/max) 来保留快照。以下策略强制将备份存储至少 30 天。
- JSON
-
-
{
"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"
}
}
}
]
}
弹性缓存:KmsKeyId: 指定客户管理的用法 Amazon KMS 密钥。
- JSON
-
-
{
"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"
}
}
}
]
}
弹性缓存:CacheParameterGroupName:使用集群上某个组织的特定参数指定非默认参数组。您还可以为参数组指定命名模式,或阻止删除特定参数组名称。以下是限制使用仅“my-org-param-group”的示例。
- JSON
-
-
{
"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"
}
}
}
]
}
弹性缓存:CacheParameterGroupName:使用 Memcached,使用集群上某个组织的特定参数指定一个非默认参数组。您还可以为参数组指定命名模式,或阻止删除特定参数组名称。以下是限制使用仅“my-org-param-group”的示例。
- JSON
-
-
{
"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"
}
}
}
]
}
-
弹性缓存:CreateCacheCluster: 否认 CreateCacheCluster 请求标签的操作 Project 缺失或不等于 Dev, QA 要么 Prod。
- JSON
-
-
{
"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"
]
}
}
}
]
}
弹性缓存:CacheNodeType: 允许 CreateCacheCluster 和 cacheNodeType cache.r5.large 或 cache.r6g.4xlarge 然后标记 Project=XYZ。
- JSON
-
-
{
"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"
}
}
}
]
}
弹性缓存:CacheNodeType: 允许 CreateCacheCluster 和 cacheNodeType cache.r5.large 或 cache.r6g.4xlarge 然后标记 Project=XYZ。
- JSON
-
-
{
"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"
}
}
}
]
}
弹性缓存:ConnectionType:拒绝使用公共连接类型创建无服务器缓存。使用提供的条件,管理员可以阻止用户使用公共端点创建缓存。
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Action": "elasticache:CreateServerlessCache",
"Resource": "*",
"Condition": {
"StringEqualsIgnoreCase": {
"elasticache:ConnectionType": "public"
}
}
}
]
}
在创建策略以将标签和其他条件键一起强制执行时,由于使用 --tags 参数创建请求的额外 elasticache:AddTagsToResource 策略要求,条件键元素可能需要条件 IfExists。