简体   繁体   English

aws cli 无法返回角色策略

[英]aws cli fails to return a role policy

I am copying the name of a policy a created (and attached to a role) and running the following command:我正在复制创建的策略名称(并附加到角色)并运行以下命令:

▶ aws iam get-role-policy --role-name MyRole  --policy-name MyPolicy

however I am getting:但是我得到:

An error occurred (NoSuchEntity) when calling the GetRolePolicy operation: The role policy with name MyPolicy cannot be found.

The policy is right there, I am copying the name from the AWS console.政策就在那里,我正在从 AWS 控制台复制名称。

What is the issue here?这里的问题是什么?

I have also tried the following, that does list the policy我也试过以下,确实列出了政策

$ aws iam list-attached-role-policies --role-name MyRole

{
    "AttachedPolicies": [
        {
            "PolicyName": "MyPolicy",
            "PolicyArn": "arn:aws:iam::123456789:policy/MyPolicy"
        }
    ]
}
(END)

list-attached-role-policies lists all managed policies attached to a role and get-role-policy retrieves an inline policy. list-attached-role-policies列出附加到角色的所有托管策略, get-role-policy检索内联策略。 In order to retrieve a managed policy you'll want to use get-policy , get the policy version from there and retrieve it using get-policy-version .为了检索托管策略,您需要使用get-policy ,从那里获取策略版本并使用get-policy-version检索它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM