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使用執行個體設定檔。
-
如需詳API細資訊,請參閱AWS CLI 指令參考ListInstanceProfilesForRole
中的。
-
- 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}
-
如需詳API細資訊,請參閱AWS Tools for PowerShell 指令程ListInstanceProfilesForRole式參考中的。
-
ListInstanceProfiles
ListMfaDevices