首页 文章

哪个角色附加到实例

提问于
浏览
2

如何 check which IAM roles and it's policy json, are attached to the running EC2 实例?

是否可以通过AWS CLI?

这里响应aws ec2 ddescribe-instances
enter image description here

我尝试触发命令 - aws iam list-instance-profiles
它给了我以下错误 -

调用ListInstanceProfiles操作时发生错误(AccessDenied):用户:无权执行:iam:资源上的ListInstanceProfiles:

1 回答

  • 1

    是 . 如果查看aws ec2 describe-instances命令生成的响应,您会注意到生成的JSON数据有

    IamInstanceProfile - >(结构)与实例关联的IAM实例配置文件(如果适用) . Arn - >(字符串)实例配置文件的Amazon资源名称(ARN) . Id - >(字符串)实例配置文件的ID .

    稍后,您可以使用iam cli interface获取策略/角色详细信息 .

    aws iam get-instance-profile --instance-profile-name <name here>
    

相关问题