搭GetInstanceProfile配 AWS SDK或使用 CLI - AWS SDK 程式碼範例

AWS 文檔 AWS SDK示例 GitHub 回購中有更多SDK示例

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

GetInstanceProfile配 AWS SDK或使用 CLI

下列程式碼範例會示範如何使用GetInstanceProfile

CLI
AWS CLI

取得執行個體設定檔的相關資訊

下列get-instance-profile命令會取得名為之執行個體設定檔的相關資訊ExampleInstanceProfile

aws iam get-instance-profile \ --instance-profile-name ExampleInstanceProfile

輸出:

{ "InstanceProfile": { "InstanceProfileId": "AID2MAB8DPLSRHEXAMPLE", "Roles": [ { "AssumeRolePolicyDocument": "<URL-encoded-JSON>", "RoleId": "AIDGPMS9RO4H3FEXAMPLE", "CreateDate": "2013-01-09T06:33:26Z", "RoleName": "Test-Role", "Path": "/", "Arn": "arn:aws:iam::336924118301:role/Test-Role" } ], "CreateDate": "2013-06-12T23:52:02Z", "InstanceProfileName": "ExampleInstanceProfile", "Path": "/", "Arn": "arn:aws:iam::336924118301:instance-profile/ExampleInstanceProfile" } }

如需詳細資訊,請參閱使用指南中的AWS IAM使用執行個體設定檔

PowerShell
用於的工具 PowerShell

範例 1:此範例會傳回目前 AWS 帳戶中定義的名稱為ec2instancerole之執行個體設定檔的詳細資訊。

Get-IAMInstanceProfile -InstanceProfileName 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 指令程GetInstanceProfile式參考中的。