[アップデート] Amazon Bedrock Guardrails がクロスリージョン推論をサポートしました

[アップデート] Amazon Bedrock Guardrails がクロスリージョン推論をサポートしました

Clock Icon2025.05.15

こんにちは!クラウド事業本部コンサルティング部のたかくに(@takakuni_)です。

Amazon Bedrock Guardrails がクロスリージョン推論をサポートしました。

https://aws.amazon.com/about-aws/whats-new/2025/05/amazon-bedrock-guardrails-cross-region-inference/

アップデート内容

今までの Amazon Bedrock Guardrails では、シングルリージョンにホストされるモデルを利用して、入出力データのチェックを行うパターンが用意されていました。各リージョンごとの、ApplyGuardrails API のクォータを意識して、チェックする必要があります。

たとえば、東京リージョンの場合、デフォルトの ApplyGuardrails API は秒間 25 リクエストまで受け付けられます。

2025-05-15 at 17.03.34-クォータリスト - Amazon Bedrock  AWS Service Quotas.png

そもそもが、非常に大きいリクエストが受け付けられそうですが、生成 AI の利用が加速してくると、複数のモデルを組み合わせて多くのリクエストが今後飛んでくる可能性があります。

各モデルはモデル ID 単位で、クォータが設定されていますが、ApplyGuardrails API はクォータを共有しています。

このクォータ制限を回避するために、クロスリージョン推論を利用します。(私個人としてはまだこの仕様に引っ掛かるほど使えていないですが)

ガードレールプロファイル

クロスリージョン推論の推論プロファイルと同じように、ガードレールプロファイルというものが用意されています。

現在、以下のセットが用意されています。

  • US Guardrail v1:0
  • US-GOV Guardrail v1:0
  • EU Guardrail v1:0
  • APAC Guardrail v1:0

利用イメージは、ガードレールの設定値の中で、ガードレールプロファイルを利用する/しないを選ぶイメージです。

東京リージョン(ap-northeast-1)で APAC Guardrail v1:0 を利用する場合、次のリージョンの中で処理が行われます。

  • ap-south-1(ムンバイ)
  • ap-northeast-1(東京)
  • ap-northeast-2(ソウル)
  • ap-northeast-3(大阪)
  • ap-southeast-1(シンガポール)
  • ap-southeast-2(シドニー)

https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-cross-region-support.html

諸注意

ガードレールプロファイルを利用する場合は、ガードレールの設定自体は送信元リージョンのみに保持されますが、入力プロンプトと出力結果はプライマリーリージョンの外に移動する可能性があります。

たとえば、東京リージョンからガードレールプロファイルを利用して、大阪リージョンでチェックされたとします。入出力データは大阪リージョン内で利用されます。

Cross-Region inference requests are kept within the Regions that are part of the geography where the data originally resides. For example, a request made in the US is kept within Regions in the US. Although your guardrail configuration remains stored only in the primary Region, your input prompts and output results might move outside of your primary Region when using cross-Region inference. All data is transmitted encrypted within Amazon's secure network.

https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-cross-region.html

やってみる

それでは、Amazon Bedrock Guardrails でクロスリージョン推論を利用してみます。

Cross-Region Inference の項目が増えていますね。ガードレールプロファイルを選択しましょう。

2025-05-15 at 18.31.57-Amazon Bedrock  ap-northeast-1.png

今回はプロンプト攻撃を設定しました。

2025-05-15 at 18.32.13-Amazon Bedrock  ap-northeast-1.png

ApplyGuardrail API を実行してみました。うまく動いていますね。

2025-05-15 at 18.34.04-Amazon Bedrock  ap-northeast-1.png

並列で動かしてみました。

app.py
import sys
import json
import boto3
import concurrent.futures

GURADRAIL_ID = 'uwqz28ftp6h1'
NUM_RUNS = 1000
MAX_PARALLEL = 100


def main(input: str):
    client = boto3.client('bedrock-runtime')
    response = json.dumps(client.apply_guardrail(
        guardrailIdentifier=GURADRAIL_ID,
        guardrailVersion='DRAFT',
        source='INPUT',
        content=[
            {
                'text': {
                    'text': str(input)
                }
            }
        ]
    ), indent=2, ensure_ascii=False)
    print(response)


if __name__ == "__main__":
    if len(sys.argv) < 2:
        print("Usage: python app.py <input>")
        sys.exit(1)
    input_value = sys.argv[1]
    with concurrent.futures.ThreadPoolExecutor(max_workers=MAX_PARALLEL) as executor:
        futures = [executor.submit(main, input_value) for _ in range(NUM_RUNS)]
        for i, future in enumerate(concurrent.futures.as_completed(futures), 1):
            try:
                future.result()
            except Exception as e:
                print(f"Run {i} Exception: {e}")

以下の結果が返ってきていました。うまく実行はできてそうです。

{
  "ResponseMetadata": {
    "RequestId": "1ec9eb59-124d-411f-8fb5-e7919ad52004",
    "HTTPStatusCode": 200,
    "HTTPHeaders": {
      "date": "Thu, 15 May 2025 11:48:55 GMT",
      "content-type": "application/json",
      "content-length": "699",
      "connection": "keep-alive",
      "x-amzn-requestid": "1ec9eb59-124d-411f-8fb5-e7919ad52004"
    },
    "RetryAttempts": 0
  },
  "usage": {
    "topicPolicyUnits": 0,
    "contentPolicyUnits": 1,
    "wordPolicyUnits": 0,
    "sensitiveInformationPolicyUnits": 0,
    "sensitiveInformationPolicyFreeUnits": 0,
    "contextualGroundingPolicyUnits": 0,
    "contentPolicyImageUnits": 0
  },
  "action": "NONE",
  "actionReason": "No action.",
  "outputs": [],
  "assessments": [
    {
      "invocationMetrics": {
        "guardrailProcessingLatency": 176,
        "usage": {
          "topicPolicyUnits": 0,
          "contentPolicyUnits": 1,
          "wordPolicyUnits": 0,
          "sensitiveInformationPolicyUnits": 0,
          "sensitiveInformationPolicyFreeUnits": 0,
          "contextualGroundingPolicyUnits": 0,
          "contentPolicyImageUnits": 0
        },
        "guardrailCoverage": {
          "textCharacters": {
            "guarded": 22,
            "total": 22
          }
        }
      }
    }
  ],
  "guardrailCoverage": {
    "textCharacters": {
      "guarded": 22,
      "total": 22
    }
  }
}

並列で動かしすぎたため、スロットリングが何回か発生していました。

Run 769 Exception: An error occurred (ThrottlingException) when calling the ApplyGuardrail operation (reached max retries: 4): Too many requests sent to ApplyGuardrail: On-demand ApplyGuardrail requests per second limit exceeded.

注意事項

クロスリージョン推論の場合、モデルの実行ログ(CloudWatch Logs, S3)から推論先のリージョンを知ることができます。

ただし、ガードレールプロファイルの場合、モデルの実行ログは記録されないです。

CloudWatch Metrics, CloudTrail のデータイベントを探してみたものの、どのリージョンで動いたのか確認する術は、今のところなさそうでした。

まとめ

以上、「Amazon Bedrock Guardrails がクロスリージョン推論をサポートしました。」でした。

あまり、ガードレール自体をクロスリージョン推論してこなかったですが、今後利用が進むとボトルネックになりそうで、良い印象を持ちました。

クラウド事業本部コンサルティング部のたかくに(@takakuni_)でした!

Share this article

facebook logohatena logotwitter logo

© Classmethod, Inc. All rights reserved.