Skip to content

bedrock cross region batch inference API calling error

0

Hello, I has an error below when calling batch inference: An error occurred (ValidationException) when calling the CreateModelInvocationJob operation: The provided ARN is invalid for the service region

This is the code I used

import boto3

bedrock = boto3.client(service_name="bedrock")

inputDataConfig=({
    "s3InputDataConfig": {
        "s3Uri": "s3://test/input/test.jsonl"
    }
})

outputDataConfig=({
    "s3OutputDataConfig": {
        "s3Uri": "s3://test/output/"
    }
})

response=bedrock.create_model_invocation_job(
    roleArn="arn:aws:iam::{accountID}:role/BedRock-Batch-Inference",
    modelId="arn:aws:bedrock:eu-west-3:{accountID}:inference-profile/eu.anthropic.claude-3-5-sonnet-20240620-v1:0",
    jobName="test",
    inputDataConfig=inputDataConfig,
    outputDataConfig=outputDataConfig
)

jobArn = response.get('jobArn')

I already added below policy to my roleArn

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "CrossRegionInference",
            "Effect": "Allow",
            "Action": [
                "bedrock:InvokeModel*"
            ],
            "Resource": [
                "arn:aws:bedrock:*::foundation-model/*",
                "arn:aws:bedrock:*:814089719562:inference-profile/*"
            ]
        }
    ]
}

Does anyone know how to resolve this problem? Thanks.

1 Answer
0

The error you're encountering suggests there's a mismatch between the region specified in your ARN and the region where you're making the API call. Here are a few things to check and adjust:

  1. Ensure that the region in your boto3 client matches the region in your model ARN. In your code, you're using an ARN for eu-west-3, so make sure your boto3 client is also configured for eu-west-3.

  2. For cross-region inference, you need to use an inference profile instead of directly specifying the model ID. The ARN you're using in the modelId parameter appears to be for an inference profile, which is correct. However, make sure this inference profile exists and is correctly set up in your account.

  3. Verify that the inference profile you're using includes both the source region (where you're making the API call) and the target region (where the model is hosted).

  4. Double-check that you have the necessary permissions to use cross-region inference and that you've been granted access to the specific model you're trying to use.

  5. Ensure that batch inference is supported for the specific model and regions you're working with. Some models or regions might have limitations or might not support batch inference.

If you've confirmed all these points and are still facing issues, you may need to contact AWS support for further assistance, as there could be a specific configuration or account-level issue that needs to be addressed.
Sources
Bedrock Batch Inference with Claude | AWS re:Post
Bedrock API invocation error - on demand throughput isn's supported | AWS re:Post
Bedrock API with Cross Region Inference is not working | AWS re:Post

answered 8 months ago
AWS
EXPERT
reviewed 8 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.