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

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

Verwendung von ListInstanceProfiles mit einer CLI

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

CLI
AWS CLI

So listen Sie die Instance-Profile für das Konto auf

Im folgenden Befehl list-instance-profiles werden die Instance-Profile aufgelistet, die dem aktuellen Konto zugeordnet sind.

aws iam list-instance-profiles

Ausgabe:

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

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

PowerShell
Tools für PowerShell V4

Beispiel 1: Dieses Beispiel gibt eine Sammlung der im aktuellen AWS-Konto definierten Instance-Profile zurück.

Get-IAMInstanceProfileList

Ausgabe:

Arn : arn:aws:iam::123456789012:instance-profile/ec2instancerole CreateDate : 2/17/2015 2:49:04 PM InstanceProfileId : HH36PTZQJUR32EXAMPLE1 InstanceProfileName : ec2instancerole Path : / Roles : {ec2instancerole}
  • Weitere API-Informationen finden Sie unter ListInstanceProfiles in der AWS -Tools für PowerShell-Cmdlet-Referenz (V4).

Tools für PowerShell V5

Beispiel 1: Dieses Beispiel gibt eine Sammlung der im aktuellen AWS-Konto definierten Instance-Profile zurück.

Get-IAMInstanceProfileList

Ausgabe:

Arn : arn:aws:iam::123456789012:instance-profile/ec2instancerole CreateDate : 2/17/2015 2:49:04 PM InstanceProfileId : HH36PTZQJUR32EXAMPLE1 InstanceProfileName : ec2instancerole Path : / Roles : {ec2instancerole}
  • Weitere API-Informationen finden Sie unter ListInstanceProfiles in der AWS -Tools für PowerShell-Cmdlet-Referenz (V5).