以下策略可实现:
允许创建ECS资源,前提是创建时需给资源绑定标签costcenter:tony
。
允许任何操作,前提是资源携带了标签costcenter:tony
。
允许查看实例的某些信息,前提是该实例携带了标签costcenter:tony
。
禁止管理标签(包括修改、添加、删除等),以防止标签被修改。
{
"Version": "1",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ecs:Run*",
"ecs:Create*",
"ecs:Purchase*",
"ecs:DescribeInstances",
"ecs:List*"
],
"Resource": "*",
"Condition": {
"StringEquals": {
"acs:RequestTag/costcenter": "tony"
}
}
},
{
"Effect": "Allow",
"Action": "*",
"Resource": "*",
"Condition": {
"StringEquals": {
"acs:ResourceTag/costcenter": "tony"
}
}
},
{
"Effect": "Allow",
"Action": [
"ecs:List*",
"ecs:DescribeInstanceStatus",
"ecs:DescribeInstanceVncUrl",
"ecs:DescribeInstanceAutoRenewAttribute",
"ecs:DescribeInstanceRamRole",
"ecs:DescribeInstanceTypeFamilies",
"ecs:DescribeInstanceTypes",
"ecs:DescribeInstanceAttachmentAttributes",
"ecs:DescribeInstancesFullStatus",
"ecs:DescribeInstanceHistoryEvents",
"ecs:DescribeInstanceMonitorData",
"ecs:DescribeInstanceMaintenanceAttributes",
"ecs:DescribeInstanceModificationPrice",
"ecs:DescribeA*",
"ecs:DescribeC*",
"ecs:DescribeD*",
"ecs:DescribeE*",
"ecs:DescribeH*",
"ecs:DescribeIm*",
"ecs:DescribeInv*",
"ecs:DescribeK*",
"ecs:DescribeL*",
"ecs:DescribeM*",
"ecs:DescribeN*",
"ecs:DescribeP*",
"ecs:DescribeR*",
"ecs:DescribeS*",
"ecs:DescribeT*",
"ecs:DescribeZ*",
"vpc:DescribeVpcs",
"vpc:DescribeVSwitches",
"bss:PayOrder"
],
"Resource": "*"
},
{
"Effect": "Deny",
"Action": [
"ecs:RemoveTags",
"ecs:UntagResources",
"ecs:AddTags",
"ecs:TagResources"
],
"Resource": "*"
}
]
}