列出具有特定标签条件的所有实例
List all instances with condition of a specific tag
我的VPC有一些实例,用标签“Dept”(部门)分隔。然后我编写了一个小的 iam 策略来列出共享相同标签(部门:销售)的所有实例。但是,它导致 EC2 仪表板中所有资源出现“API 错误”。
我也尝试使用 aws:RequestTag、aws:ResourceTag(全局条件“aws”前缀),但问题仍然存在。
如果满足以下条件,我可以列出实例:
(1) 我使用了其他操作(例如:ec2:StartInstances 或 ec2:StopInstances)。
(2) 将条件运算符从“StringEquals”更改为“StringNotEquals”=> 结果:OK。由此,我了解到 IAM 请求包含“ResourceTag”。
能否请您解释一下我如何列出共享特定标签的实例?
谢谢
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:Describe*",
"ec2:Get*"
],
"Resource": "*",
"Condition": {
"StringEquals": {
"ec2:ResourceTag/Dept": "Sales"
}
}
}
}
条件中有一些 API 不能与 ec2:ResourceTag/tag 一起使用的操作和资源。
对于describe*
:
Note that the Describe actions do not support resource-level
permissions, so you must specify them in a separate statement without
conditions. https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/control-access-with-tags.html
要了解 Amazon EC2 API 操作是否支持标记,see Actions, resources, and condition keys for Amazon EC2.
我的VPC有一些实例,用标签“Dept”(部门)分隔。然后我编写了一个小的 iam 策略来列出共享相同标签(部门:销售)的所有实例。但是,它导致 EC2 仪表板中所有资源出现“API 错误”。
我也尝试使用 aws:RequestTag、aws:ResourceTag(全局条件“aws”前缀),但问题仍然存在。
如果满足以下条件,我可以列出实例: (1) 我使用了其他操作(例如:ec2:StartInstances 或 ec2:StopInstances)。 (2) 将条件运算符从“StringEquals”更改为“StringNotEquals”=> 结果:OK。由此,我了解到 IAM 请求包含“ResourceTag”。
能否请您解释一下我如何列出共享特定标签的实例? 谢谢
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:Describe*",
"ec2:Get*"
],
"Resource": "*",
"Condition": {
"StringEquals": {
"ec2:ResourceTag/Dept": "Sales"
}
}
}
}
条件中有一些 API 不能与 ec2:ResourceTag/tag 一起使用的操作和资源。
对于describe*
:
Note that the Describe actions do not support resource-level permissions, so you must specify them in a separate statement without conditions. https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/control-access-with-tags.html
要了解 Amazon EC2 API 操作是否支持标记,see Actions, resources, and condition keys for Amazon EC2.