Files
floci/docs/services/bedrock.md
T
lex00 cae8f9a013 feat(bedrock): add guardrail lifecycle and versions (#3380)
* feat(bedrock): add guardrail lifecycle and versions

Amazon Bedrock control plane over REST JSON: CreateGuardrail through
DeleteGuardrail, CreateGuardrailVersion, ListGuardrails with pagination, and
resource tagging on /tagResource, /untagResource and /listTagsForResource.
Guardrails report READY on the first read, so the Terraform provider's status
poll for aws_bedrock_guardrail completes without a transition.

The control plane and bedrock-runtime both sign as "bedrock". The runtime
descriptor keeps that credential scope, and the new descriptor routes through
its resource class, which ServiceEnabledFilter checks first.

Policy blocks are stored under the read-shape member names, so a *Config
submitted on create or update reads back unsuffixed. ListGuardrails honours
maxResults and nextToken, and DeleteGuardrail rejects a guardrailVersion that
is not a GuardrailNumericalVersion.

* fix(bedrock): enforce guardrail length caps and resolve kmsKeyId to a key ARN

The AWS model caps description at 200 characters and both blockedInputMessaging
and blockedOutputsMessaging at 500, each with a minimum of 1. None of those were
checked, so an over-long value was stored and read back. name was already bounded
by its [0-9a-zA-Z-_]{1,50} pattern.

kmsKeyId on CreateGuardrail and UpdateGuardrail is a KmsKeyId: a key id, a key
ARN, an alias name or an alias ARN. kmsKeyArn on the read shapes is a KmsKeyArn,
which is only ever the full key ARN. The request value was echoed back verbatim,
so a bare key id or an alias produced a response that does not match the shape
GetGuardrail declares. It now resolves through KmsService.describeKey, the same
way RDS, DocDB and ElastiCache already resolve their KmsKeyId, and a key that is
missing, disabled or pending deletion is rejected with ValidationException.

* test(bedrock): drive the guardrail lifecycle from the AWS SDK v2 client

Adds the bedrock SDK module to the compatibility project, a BedrockClient
factory on TestFixtures, and a BedrockGuardrailTest covering create, read,
update, versioning, listing, tagging and delete. The test also submits kmsKeyId
as a bare key id and as an alias and asserts both read back as the same full KMS
key ARN.

* fix(bedrock): enforce the guardrail tag caps from the AWS model

The AWS model gives TagList a max of 200 items, and that shape backs the tags
member of both CreateGuardrail and TagResource. TooManyTagsException, declared
on both operations, documents a separate limit of 50 tags per resource counted
over the tags already on the resource together with the ones in the request.

parseTagList now rejects an array over 200 items with ValidationException, and
it moved to BedrockService so both entry points share it. CreateGuardrail and
TagResource raise TooManyTagsException once the total the guardrail would be
left holding passes 50, carrying resourceName as the model declares.
2026-09-11 20:36:45 -04:00

4.9 KiB

Amazon Bedrock (control plane)

Protocol: REST-JSON Endpoint: http://localhost:4566/guardrails (SigV4 service bedrock)

This page covers the Bedrock control plane. Model invocation is a separate service that shares the same signing name: see Bedrock Runtime.

Supported Actions

Action Description
CreateGuardrail Create a guardrail; returns the DRAFT version, READY immediately
GetGuardrail Read a guardrail by id or ARN, at DRAFT or a numbered guardrailVersion
UpdateGuardrail Replace the DRAFT configuration
CreateGuardrailVersion Snapshot the DRAFT under the next numerical version
DeleteGuardrail Delete one numerical version, or the guardrail and all its versions
ListGuardrails List every guardrail's DRAFT, or every version of one guardrail
TagResource Tag a guardrail (POST /tagResource)
UntagResource Remove tags from a guardrail (POST /untagResource)
ListTagsForResource List a guardrail's tags (POST /listTagsForResource)

Guardrails are versioned. The working copy is DRAFT, and GetGuardrail without a guardrailVersion query parameter returns it. CreateGuardrailVersion copies the current DRAFT to 1, 2 and so on. Those snapshots are immutable, because UpdateGuardrail only ever writes DRAFT.

GuardrailStatus is READY from the first read, so aws_bedrock_guardrail's status poll completes without a transition. Policy blocks are submitted as the *Config shapes (topicPolicyConfig, contentPolicyConfig and the rest) and read back under their unsuffixed names (topicPolicy.topics, contentPolicy.filters), matching the AWS model.

ListGuardrails returns one DRAFT summary per guardrail. Passing guardrailIdentifier returns every version of that one guardrail instead. Both forms honour maxResults and nextToken.

DeleteGuardrail takes a GuardrailNumericalVersion, so a version query parameter of DRAFT is rejected with ValidationException. Omit the parameter to delete the guardrail and all of its versions.

Both an id (abc123def456) and a full ARN are accepted wherever the API takes a guardrailIdentifier or a resourceARN.

kmsKeyId on CreateGuardrail and UpdateGuardrail is a KmsKeyId: a key id, a key ARN, an alias name or an alias ARN. kmsKeyArn on the read shapes is a KmsKeyArn, which is only ever the full key ARN, so every accepted form is resolved through KMS to that one shape. A key that does not exist, is disabled, or is pending deletion is rejected with ValidationException.

The AWS model's length constraints are enforced: name is 1 to 50 characters matching [0-9a-zA-Z-_]+, description is 1 to 200, and blockedInputMessaging and blockedOutputsMessaging are 1 to 500 each. A value outside those bounds is rejected with ValidationException.

The model's tag limits are enforced as well. A TagList holds at most 200 items on one request, and a longer array is rejected with ValidationException. A guardrail holds at most 50 tags, counted over the tags already on it together with the tags in the current request, so CreateGuardrail and TagResource both raise TooManyTagsException once the resulting total would pass 50. Replacing the value of a tag key the guardrail already carries does not add to that total.

Not implemented

The rest of the Bedrock control plane is absent rather than stubbed, because emulating it faithfully would require behaviour Floci has no way to model:

  • ListFoundationModels and GetFoundationModel. The AWS service model carries no enumeration of foundation model ids, so any catalogue would be invented data.
  • Custom model, model customization, model import and distillation jobs. These depend on real training runs.
  • Model evaluation and evaluation jobs. These depend on real inference.
  • Provisioned throughput, inference profiles and prompt routers. These describe real capacity reservations and routing.
  • Model invocation logging, batch inference and async invoke. These are data-plane operations backed by real model execution.

Configuration

Variable Default Description
FLOCI_SERVICES_BEDROCK_ENABLED true Enable or disable the service

Examples

export AWS_ENDPOINT_URL=http://localhost:4566

aws bedrock create-guardrail \
  --name my-guardrail \
  --blocked-input-messaging "Blocked." \
  --blocked-outputs-messaging "Blocked." \
  --content-policy-config '{"filtersConfig":[{"type":"HATE","inputStrength":"HIGH","outputStrength":"HIGH"}]}'

aws bedrock get-guardrail --guardrail-identifier abc123def456

aws bedrock create-guardrail-version --guardrail-identifier abc123def456

aws bedrock list-guardrails

aws bedrock tag-resource \
  --resource-arn arn:aws:bedrock:us-east-1:000000000000:guardrail/abc123def456 \
  --tags key=team,value=ai

aws bedrock delete-guardrail --guardrail-identifier abc123def456