gpt4 book ai didi

amazon-web-services - 为什么我在 AWS API 上收到 "not authorized to perform: ecs:ListTasks on resource: *"异常

转载 作者:行者123 更新时间:2023-12-04 00:59:43 31 4
gpt4 key购买 nike

我正在尝试从 AWS API 获取在我的 ECS 环境中运行的任务列表,但我一直遇到相同的错误:

User: arn:aws:iam::[my_id]:user/[username] is not authorized to perform: ecs:ListTasks on resource: *


{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"ecs:RunTask",
"ecs:ListTasks",
"ecs:StartTask",
"ecs:StopTask"
],
"Resource": [
"arn:aws:ecs:us-east-1:[my_id]:task/*",
"arn:aws:ecs:us-east-1:[my_id]:task-definition/*",
"arn:aws:ecs:us-east-1:[my_id]:cluster/*",
"arn:aws:ecs:us-east-1:[my_id]:task-set/*/*/*",
"arn:aws:ecs:us-east-1:[my_id]:container-instance/*",
"arn:aws:ecs:us-east-1:[my_id]:service/*"
]
}
]
}

如您所见,我应该使用所有可用资源访问该操作。
我错过了什么?

谢谢。

最佳答案

listTasks 操作仅支持 container instances 作为资源,而不支持 cluster arncluster arn 只能作为条件添加。
以下政策有效。

{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "ecs:ListTasks",
"Resource": "*",
"Condition": {
"ArnEquals": {
"ecs:cluster": "arn:aws:ecs:ap-southeast-2:[account id]:cluster/MyEcsCluster"
}
}
}
]
}
引用:
Actions defined by Amazon Elastic Container Service
(检查此引用中的 ListTasks 操作)
希望这可以帮助。

关于amazon-web-services - 为什么我在 AWS API 上收到 "not authorized to perform: ecs:ListTasks on resource: *"异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59604987/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com