AWS IAM Identity Center 사용자를 위한 임시 자격 증명을 받고 싶습니다.
간략한 설명
임시 자격 증명을 생성하려면 get-role-credentials 명령을 실행해야 합니다. IAM Identity Center를 사용하도록 명명된 프로필을 구성하면 AWS Command Line Interface(AWS CLI)가 cd ~/.aws/sso/cache 디렉터리에 JSON 파일을 생성합니다. JSON 파일에는 get-role-credentials 명령을 사용하여 임시 보안 자격 증명을 가져오는 데 사용되는 JSON 웹 토큰(JWT)이 포함되어 있습니다. 액세스 토큰은 8시간 동안 유효합니다. JSON 파일의 expiresAt 타임스탬프는 만료 시간을 보여줍니다.
해결 방법
참고: AWS CLI 명령을 실행할 때 오류가 발생하면 AWS CLI의 오류 해결을 참조하십시오. 또한 최신 AWS CLI 버전을 사용하고 있는지 확인하십시오.
임시 자격 증명 가져오기
다음 단계를 완료하십시오.
-
다음 JSON 파일을 열고 액세스 토큰을 찾습니다.
cat 535a8450b05870c9045c8a7b95870.json
{"startUrl": "https://my-sso-portal.awsapps.com/start", "region": "us-east-1", "accessToken": "eyJlbmMiOiJBM….", "expiresAt": "2020-06-17T10:02:08UTC"}
-
accessToken 값을 복사합니다.
-
다음 get-role-credentials 명령을 실행하여 Identity Center 사용자의 자격 증명을 가져옵니다.
aws sso get-role-credentials --account-id 123456789012 --role-name permission-set-name --access-token eyJlbmMiOiJBM…. --region enter_the_same_sso_region_same_in_the_JSON_file
참고: enter_the_same_sso_region_same_in_the_JSON_file을 JSON 파일의 AWS 리전으로 바꾸고 permission-set-name을 역할 이름으로 바꾸십시오. 잘못된 역할 이름을 사용하는 경우 “An error occurred (ForbiddenException) when calling the GetRoleCredentials operation: No access."라는 오류가 발생합니다. 세션 토큰 또는 리전이 JSON 파일 출력과 일치하지 않는 경우 "An error occurred (UnauthorizedException) when calling the GetRoleCredentials operation: Session token not found or invalid."라는 오류가 발생합니다.
출력 예시:
{ "roleCredentials": {
"accessKeyId": "ASIA*************",
"secretAccessKey": "**********************************",
"sessionToken": "****************************************",
"expiration": 1592362463000
}
}
-
자격 증명을 환경 변수로 구성합니다.
관련 정보
IAM Identity Center 권한 세트를 사용하려면 어떻게 해야 하나요?