文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 AWS SDK 範例
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
搭配使用 ListInstanceProfilesForRole 與 CLI
下列程式碼範例示範如何使用 ListInstanceProfilesForRole。
- CLI
-
- AWS CLI
-
若要列出 IAM 角色的執行個體設定檔
下列
list-instance-profiles-for-role命令會列出與角色Test-Role關聯的執行個體設定檔。aws iam list-instance-profiles-for-role \ --role-nameTest-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 Command Reference 中的 ListInstanceProfilesForRole
。
-
- PowerShell
-
- PowerShell V4 的工具
-
範例 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 Cmdlet 參考 (V4) 中的 ListInstanceProfilesForRole。
-
- PowerShell V5 的工具
-
範例 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 Cmdlet 參考 (V5) 中的 ListInstanceProfilesForRole。
-
ListInstanceProfiles
ListMfaDevices