搭ListInstanceProfilesForRole配 AWS SDK或使用 CLI - AWS SDK 程式碼範例

AWS 文檔 AWS SDK示例 GitHub 回購中有更多SDK示例

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

ListInstanceProfilesForRole配 AWS SDK或使用 CLI

下列程式碼範例會示範如何使用ListInstanceProfilesForRole

CLI
AWS CLI

列出IAM角色的執行個體設定檔

下列list-instance-profiles-for-role命令會列出與角色相關聯的執行個體設定檔Test-Role

aws iam list-instance-profiles-for-role \ --role-name Test-Role

輸出:

{ "InstanceProfiles": [ { "InstanceProfileId": "AIDGPMS9RO4H3FEXAMPLE", "Roles": [ { "AssumeRolePolicyDocument": "<URL-encoded-JSON>", "RoleId": "AIDACKCEVSQ6C2EXAMPLE", "CreateDate": "2013-06-07T20:42:15Z", "RoleName": "Test-Role", "Path": "/", "Arn": "arn:aws:iam::123456789012:role/Test-Role" } ], "CreateDate": "2013-06-07T21:05:24Z", "InstanceProfileName": "ExampleInstanceProfile", "Path": "/", "Arn": "arn:aws:iam::123456789012:instance-profile/ExampleInstanceProfile" } ] }

如需詳細資訊,請參閱使用指南中的AWS IAM使用執行個體設定檔

PowerShell
用於的工具 PowerShell

範例 1:此範例會傳回與角色相關聯之執行個體設定檔的詳細資訊ec2instancerole

Get-IAMInstanceProfileForRole -RoleName ec2instancerole

輸出:

Arn : arn:aws:iam::123456789012:instance-profile/ec2instancerole CreateDate : 2/17/2015 2:49:04 PM InstanceProfileId : HH36PTZQJUR32EXAMPLE1 InstanceProfileName : ec2instancerole Path : / Roles : {ec2instancerole}