文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 AWS SDK 範例
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
搭配使用 GetInstanceProfile
與 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 使用者指南》中的使用執行個體設定檔。
-
如需 API 詳細資訊,請參閱 AWS CLI Command Reference 中的 GetInstanceProfile
。
-
- PowerShell
-
- Tools for 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 Cmdlet Reference 中的 GetInstanceProfile。
-
GetGroupPolicy
GetLoginProfile