AWS文件開發套件範例
搭配使用 ListInstanceProfiles 與 CLI
下列程式碼範例示範如何使用 ListInstanceProfiles。
- CLI
-
- AWS CLI
-
若要列出帳戶的執行個體設定檔
下列
list-instance-profiles命令列出與目前帳戶關聯的執行個體設定檔。aws iam list-instance-profiles輸出:
{ "InstanceProfiles": [ { "Path": "/", "InstanceProfileName": "example-dev-role", "InstanceProfileId": "AIPAIXEU4NUHUPEXAMPLE", "Arn": "arn:aws:iam::123456789012:instance-profile/example-dev-role", "CreateDate": "2023-09-21T18:17:41+00:00", "Roles": [ { "Path": "/", "RoleName": "example-dev-role", "RoleId": "AROAJ52OTH4H7LEXAMPLE", "Arn": "arn:aws:iam::123456789012:role/example-dev-role", "CreateDate": "2023-09-21T18:17:40+00:00", "AssumeRolePolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "ec2.amazonaws.com" }, "Action": "sts:AssumeRole" } ] } } ] }, { "Path": "/", "InstanceProfileName": "example-s3-role", "InstanceProfileId": "AIPAJVJVNRIQFREXAMPLE", "Arn": "arn:aws:iam::123456789012:instance-profile/example-s3-role", "CreateDate": "2023-09-21T18:18:50+00:00", "Roles": [ { "Path": "/", "RoleName": "example-s3-role", "RoleId": "AROAINUBC5O7XLEXAMPLE", "Arn": "arn:aws:iam::123456789012:role/example-s3-role", "CreateDate": "2023-09-21T18:18:49+00:00", "AssumeRolePolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "ec2.amazonaws.com" }, "Action": "sts:AssumeRole" } ] } } ] } ] }如需詳細資訊,請參閱《AWS IAM 使用者指南》中的使用執行個體設定檔。
-
如需 API 詳細資訊,請參閱 AWS CLI Command Reference 中的 ListInstanceProfiles
。
-
- PowerShell
-
- Tools for PowerShell V4
-
範例 1:此範例會傳回目前的 AWS 帳戶中定義的執行個體設定檔集合。
Get-IAMInstanceProfileList輸出:
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)》中的 ListInstanceProfiles。
-
- Tools for PowerShell V5
-
範例 1:此範例會傳回目前的 AWS 帳戶中定義的執行個體設定檔集合。
Get-IAMInstanceProfileList輸出:
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)》中的 ListInstanceProfiles。
-
ListGroupsForUser
ListInstanceProfilesForRole