Amazon Bedrock에서 InvokeModel API를 호출할 때 발생하는 AccessDeniedException 또는 ValidationException 오류를 해결하려고 합니다.
해결 방법
AccessDeniedException 및 ValidationException 오류는 InvokeModel API가 호출하는 기본 모델에 액세스할 수 없을 때 발생합니다. AWS 계정에 작업을 실행하는 데 필요한 AWS Identity and Access Management(IAM) 권한이 없는 경우에도 오류가 발생할 수 있습니다.
모델 액세스 오류
API가 호출하려고 시도한 모델에 액세스할 수 없는 경우 다음 예와 비슷한 오류 메시지가 표시됩니다.
"An error occurred (AccessDeniedException) when calling the InvokeModel operation: Your account is not authorized to invoke this API operation."
-또는-
"An error occurred (AccessDeniedException) when calling the InvokeModel operation: You don't have access to the model with the specified model ID."
이 문제를 해결하려면 다음 구성을 확인하십시오.
IAM 권한 오류
API를 호출한 IAM 사용자 또는 역할에 필요한 권한이 없는 경우 다음 예와 비슷한 오류 메시지가 표시됩니다.
"AccessDeniedException: An error occurred (AccessDeniedException) when calling the InvokeModel operation: User: username is not authorized to perform: bedrock:InvokeModel on resource: resourcename with an explicit deny in an identity-based policy."
-또는-
"AccessDeniedException: An error occurred (AccessDeniedException) when calling the InvokeModel operation: User: username is not authorized to perform: bedrock:InvokeModel on resource: resourcename because no identity-based policy allows the bedrock:InvokeModel action."
이 문제를 해결하려면 API를 호출하는 IAM 사용자 또는 역할에 다음과 같은 필요한 권한이 있는지 확인하십시오.
{ "Version": "2012-10-17",
"Statement": {
"Sid": "AllowInference",
"Effect": "Allow",
"Action": [
"bedrock:InvokeModel",
"bedrock:InvokeModelWithResponseStream"
],
"Resource": "arn:aws:bedrock:*::foundation-model/model-id"
}
}
SCP 오류
서비스 제어 정책(SCP)에 계정에 대한 특정 제한이 있는 경우 다음과 같은 오류 메시지가 표시됩니다.
"User: username is not authorized to perform: bedrock:InvokeModel on resource: username with an explicit deny in a service control policy"
API를 호출한 IAM 역할에 필요한 권한을 제공한 경우에도 위의 오류가 발생합니다. 일반적으로 이 오류는 SCP가 차단한 리전으로 호출을 라우팅하는 교차 리전 간섭을 사용할 때 발생합니다.
문제를 해결하려면 AWS CloudTrail 이벤트에서 해당 API 호출과 해당 호출이 전달되는 리전을 확인하십시오. 그런 다음, SCP가 해당 API 또는 리전에 대한 작업을 제한하는지 확인하십시오. 또한 특정 모델 ID에 대한 제한 등과 같은 기타 SCP 제한 사항도 확인하십시오.
API 작업 오류
잘못된 API 작업을 사용한 경우 다음과 같은 오류 메시지가 표시됩니다.
"ValidationException: An error occurred (ValidationException) when calling the InvokeModel operation: The requested operation is not recognized by the service."
위 오류를 해결하려면 API 호출에서 bedrock-runtime을 서비스로 지정하십시오. 자세한 내용은 Boto3 웹 사이트에서 BedrockRuntime을 참조하십시오.
다음과 같은 오류 메시지가 표시될 수도 있습니다.
"An error occurred (ValidationException) when calling the InvokeModel operation: The provided model identifier is invalid"
-또는-
"ResourceNotFoundException: An error occurred (ResourceNotFoundException) when calling the InvokeModel operation: Could not resolve the foundation model from the provided model identifier."
위 오류는 구성 문제로 인해 발생합니다. 이 문제를 해결하려면 다음 구성을 확인하십시오.
SDK 버전 오류
호환되지 않는 AWS SDK for Python(Boto3) 버전을 사용하여 InvokeModel API를 호출하면 다음과 같은 오류 메시지가 표시됩니다.
"UnknownServiceError: Unknown service: 'bedrock-runtime"
이 문제를 해결하려면 SDK를 최신 버전으로 업그레이드하십시오. 최신 버전의 SDK를 보려면 GitHub 웹 사이트에서 boto3/CHANGELOG.rst를 참조하십시오.
계정 제한 오류
계정에 보안 제한이 있는 경우 다음과 같은 오류 메시지가 표시됩니다.
"An error occurred (ValidationException) when calling the InvokeModel operation: Operation not allowed"
이 문제를 해결하려면 지원 사례를 열어야 합니다.