我正在尝试运行 New-EC2Tag,出现以下错误:
New-EC2Tag : You are not authorized to perform this operation.
用户政策如下:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["ec2:DescribeInstances","ec2:CreateTags"],
"Resource": "arn:aws:ec2:ap-southeast-2:<my_account_id>:instance/*",
"Condition": {
"StringEquals": {
"ec2:ResourceTag/OctopusTentacle": "yes"
}
}
}
]
}
如上所述,它在策略模拟器中运行良好。
如果我删除条件并将 Resource 设置为 * 它会起作用。单独删除条件或将 Resource 设置为 * 不起作用。我在实例上以本地管理员身份运行它。
New-EC2Tag 访问/执行的还有哪些我需要授予访问权限?
最佳答案
如果 New-EC2Tag
在清除 Condition
和通配符 Resource
时有效,那么我们应该检查这两者。
根据一些调查,New-EC2Tag
的相关 API 操作是 CreateTags .根据Supported Resources and Conditions for Amazon EC2 API Actions ,某些 API 操作不支持 ARN。 CreateTags
似乎就是这种情况,因为它要求您改为指定资源 ID。我在上面链接的“支持的资源...”文档也证实了这一点,该文档没有将 CreateTags 列为支持 arns。
在这种情况下,文档建议您这样设置策略:
If the API action does not support ARNs, use the * wildcard to specify that all resources can be affected by the action.
这样就留下了条件……标签。您用作条件的标签需要已经存在于实例上才能按预期应用策略。来自策略模拟器的示例,其中标记已存在:
另一个考虑因素是该操作可能同样不支持条件,但我还没有找到任何支持它的东西。
关于powershell - 从 Powershell 运行 New-EC2Tag 需要对哪些资源执行哪些政策操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23404326/