Verwendung von ListInstanceProfilesForRole mit einer CLI - AWS-SDK-Codebeispiele

Weitere AWS-SDK-Beispiele sind im GitHub-Repository Beispiele für AWS Doc SDKs verfügbar.

Verwendung von ListInstanceProfilesForRole mit einer CLI

Die folgenden Code-Beispiele zeigen, wie ListInstanceProfilesForRole verwendet wird.

CLI
AWS CLI

So listen Sie die Instance-Profile für eine IAM-Rolle auf

Mit dem folgenden Befehl list-instance-profiles-for-role werden die Instance-Profile aufgelistet, die der Rolle Test-Role zugeordnet sind.

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

Ausgabe:

{ "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" } ] }

Weitere Informationen finden Sie unter Verwenden von Instance-Profilen im AWS-IAM-Benutzerhandbuch.

PowerShell
Tools für PowerShell V4

Beispiel 1: In diesem Beispiel werden Details des Instance-Profils zurückgegeben, das der Rolle ec2instancerole zugeordnet ist.

Get-IAMInstanceProfileForRole -RoleName ec2instancerole

Ausgabe:

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

Beispiel 1: In diesem Beispiel werden Details des Instance-Profils zurückgegeben, das der Rolle ec2instancerole zugeordnet ist.

Get-IAMInstanceProfileForRole -RoleName ec2instancerole

Ausgabe:

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