powershell - 从 Powershell 运行 New-EC2Tag 需要对哪些资源执行哪些政策操作?

标签 powershell amazon-web-services amazon-ec2 amazon-iam aws-powershell

我正在尝试运行 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.

这样就留下了条件……标签。您用作条件的标签需要已经存在于实例上才能按预期应用策略。来自策略模拟器的示例,其中标记已存在:

DescribeTags and DescribeInstances are allowed.

另一个考虑因素是该操作可能同样不支持条件,但我还没有找到任何支持它的东西。

关于powershell - 从 Powershell 运行 New-EC2Tag 需要对哪些资源执行哪些政策操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23404326/

相关文章:

powershell - 我可以将PowerShell 'Start-Job'设置为低优先级吗?

Powershell 5 : documentation support via comments for classes and enums members

amazon-web-services - Docker和AMI之间的区别

testing - 使用 EC2 进行验证测试

powershell - Azure Runbook - GetAzurermlog

powershell - 将分钟四舍五入到最接近的 10 分钟

amazon-web-services - 将 key 对导入 Amazon AWS - 指纹错误?

node.js - 文件下载在 Nodejs 中给出损坏的文件

php - 在 Amazon EC2 上安装 php-dom 扩展

node.js - AWS EC2 错误 : The site can't be reached - ec2. us-west-1.compute.amazonaws.com 来不及响应。部署 Node.js