GetInstanceProfile 사용하기
GetInstanceProfile 사용하기 (CLI)
GetInstanceProfile(인스턴스 프로필 조회) API를 활용하는 방법을 코드 예시로 정리했어요. 각 예시는 어떤 동작을 하는지, 어떤 파라미터를 쓰는지 순서대로 살펴볼 수 있어요.
출처: 문서
본문
다음 코드 예시들은 GetInstanceProfile 를 어떻게 사용하는지 보여줘요.
AWS CLI
인스턴스 프로필 정보 가져오기
aws iam get-instance-profile \
--instance-profile-name ExampleInstanceProfile
다음 get-instance-profile 명령은 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"
}
}
출력:
PowerShell Tools (V4)
예시 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}
PowerShell Tools (V5)
예시 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}