View a markdown version of this page

示例:允许为特定键和值添加容量标签 - Amazon Batch
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)。

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

示例:允许为特定键和值添加容量标签

您附加到 IAM 用户或角色的以下基于身份的策略允许委托人创建和更新计算环境以及设置容量标签,但前提是CostCenter标签值为engineering或ops且不使用除和之外的CostCenter标签密钥。Team包含任何其他标签密钥或其他CostCenter值的请求将被拒绝。

{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowComputeEnvironmentManagement", "Effect": "Allow", "Action": [ "batch:CreateComputeEnvironment", "batch:UpdateComputeEnvironment" ], "Resource": "arn:aws:batch:us-east-1:123456789012:compute-environment/*" }, { "Sid": "AllowSetCapacityTagsForApprovedTags", "Effect": "Allow", "Action": "batch:SetCapacityTags", "Resource": "arn:aws:batch:us-east-1:123456789012:compute-environment/*", "Condition": { "StringEquals": { "aws:RequestTag/CostCenter": ["engineering", "ops"] }, "ForAllValues:StringEquals": { "aws:TagKeys": ["CostCenter", "Team"] } } } ] }

要完全拒绝容量标记,同时仍允许创建和更新计算环境,请附上明确说明以下内容Deny的策略:batch:SetCapacityTags

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Deny", "Action": "batch:SetCapacityTags", "Resource": "*" } ] }