AWS lets a system-defined guardrail profile carry a resource-based
policy as well as a guardrail, and a guardrail with cross-Region
inference is shared only once each destination-Region profile ARN
carries one. The policy is stored in the Region whose endpoint
received PutResourcePolicy, under the ARN passed, so GetResourcePolicy
on a profile ARN through an endpoint that stored nothing returns {}.
A profile policy may allow only bedrock:ApplyGuardrail:
https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-resource-based-policies.html
PutResourcePolicy, GetResourcePolicy and DeleteResourcePolicy now
accept a guardrail-profile ARN. Its policy is stored per calling Region
and profile ARN, GetResourcePolicy returns {} when that pair holds
none, and DeleteResourcePolicy clears only that pair. PutResourcePolicy
holds the policy to the guardrail language with bedrock:ApplyGuardrail
as the only action. A profile ARN of another account or partition, or
whose profile id is not of the form <prefix>.guardrail.v<N>:<M>, is
ResourceNotFoundException. Which destination Regions are valid for the
calling Region is not checked, and the policy is not evaluated against
callers.
Closes #6671
8.2 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 |
PutResourcePolicy |
Attach a resource-based policy to a guardrail or a guardrail profile (POST /resource-policy) |
GetResourcePolicy |
Read the resource-based policy of a guardrail or a guardrail profile |
DeleteResourcePolicy |
Remove the resource-based policy of a guardrail or a guardrail profile |
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.
The three tag actions require a full ARN to match the stored guardrail ARN exactly,
including partition, service, Region, account, and resource type. An ARN that only
shares the guardrail ID returns ResourceNotFoundException (HTTP 404) without changing tags.
The existing bare-ID form remains accepted.
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.
A resource-based policy is attached to a guardrail or a system-defined guardrail profile
by its full ARN. The policy is held to the restricted language the
Bedrock user guide
documents, and anything else is rejected with ValidationException: it is one JSON object
of 1 to 20480 characters with nothing after it, every statement is an Allow on the ARN the policy is attached to,
its actions are bedrock:ApplyGuardrail and bedrock:GetGuardrail (only
bedrock:ApplyGuardrail on a guardrail profile), and its principal is either the
account root ({"AWS": "arn:aws:iam::<account>:root"} and no other principal) or * under a StringEquals condition on
aws:PrincipalOrgID. The only conditions accepted are that one and
ForAnyValue:StringLike on aws:PrincipalOrgPaths, each with a string or an array of strings. The policy is stored as given; it is
not evaluated against callers.
A guardrail's policy lives on the guardrail. GetResourcePolicy on a guardrail with no
policy returns a response without resourcePolicy, and deleting the guardrail deletes
its policy. An ARN that names no guardrail of the caller's account and Region returns
ResourceNotFoundException. A guardrail profile has one ARN per destination Region, and
its policy is stored under the Region whose endpoint received PutResourcePolicy, as
AWS stores it, so the same profile ARN can hold a different policy in each calling
Region. GetResourcePolicy on a profile ARN that holds no policy in the calling Region
returns the empty policy {}. A profile ARN of another account or partition returns
ResourceNotFoundException; whether the profile's Region is a destination of the
calling Region is not checked.
With IAM enforcement on, PutResourcePolicy, GetResourcePolicy and
DeleteResourcePolicy are authorized as bedrock:PutResourcePolicy,
bedrock:GetResourcePolicy and bedrock:DeleteResourcePolicy on the ARN the request
names.
Guardrails are listed by the Resource Groups Tagging API (resource type bedrock:guardrail)
and Resource Explorer with their own tags, and TagResources / UntagResources there change
those tags, as TagResource and UntagResource do.
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:
ListFoundationModelsandGetFoundationModel. 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 put-resource-policy \
--resource-arn arn:aws:bedrock:us-east-1:000000000000:guardrail/abc123def456 \
--resource-policy '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"AWS":"arn:aws:iam::000000000000:root"},"Action":["bedrock:ApplyGuardrail","bedrock:GetGuardrail"],"Resource":"arn:aws:bedrock:us-east-1:000000000000:guardrail/abc123def456"}]}'
aws bedrock get-resource-policy \
--resource-arn arn:aws:bedrock:us-east-1:000000000000:guardrail/abc123def456
aws bedrock delete-guardrail --guardrail-identifier abc123def456