搭配使用 ListInstanceProfilesForRole 與 CLI - AWS Identity and Access Management

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

搭配使用 ListInstanceProfilesForRole 與 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
Tools for 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}

如需 AWS SDK 開發人員指南和程式碼範例的完整清單,請參閱 將此服務與 AWS SDK 搭配使用。此主題也包含有關入門的資訊和舊版 SDK 的詳細資訊。