mirror of
https://github.com/floci-io/floci.git
synced 2026-11-29 00:21:51 -05:00
Derive INFERENCE_PROFILE support from existing system profile routes while preserving regional ON_DEMAND support and request-filter validation. Cover Get and List metadata through raw SDK strings, including profile-only and unavailable regions. Closes #8450
216 lines
12 KiB
Markdown
216 lines
12 KiB
Markdown
# Amazon Bedrock (control plane)
|
|
|
|
**Protocol:** REST-JSON
|
|
**Endpoint:** `http://localhost:4566/guardrails`, `/foundation-models`, `/inference-profiles` (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](bedrock-runtime.md).
|
|
|
|
## Supported Actions
|
|
|
|
<!-- floci:actions:start -->
|
|
| 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 |
|
|
| `ListFoundationModels` | List the catalog's foundation models served in the calling Region, filtered by provider and output modality |
|
|
| `GetFoundationModel` | Read one foundation model by id or ARN |
|
|
| `ListInferenceProfiles` | List system-defined and created application profiles, with `type`, `maxResults` and `nextToken` |
|
|
| `GetInferenceProfile` | Read a system-defined or application profile by id or ARN, including its model destinations |
|
|
| `CreateInferenceProfile` | Create an application profile from a regional foundation model or system-defined profile |
|
|
| `DeleteInferenceProfile` | Delete an application profile by id or ARN |
|
|
| `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 or application inference profile (`POST /tagResource`) |
|
|
| `UntagResource` | Remove tags from a guardrail or application inference profile (`POST /untagResource`) |
|
|
| `ListTagsForResource` | List a guardrail's or application inference profile's tags (`POST /listTagsForResource`) |
|
|
<!-- floci:actions:end -->
|
|
|
|
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`.
|
|
|
|
For guardrails, the three tag actions require a full ARN to match the stored 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](https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-resource-based-policies.html)
|
|
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.
|
|
|
|
## Foundation models and inference profiles
|
|
|
|
`ListFoundationModels` and `GetFoundationModel` read a fixed catalog,
|
|
`bedrock/model-catalog.yaml`. System-defined inference profiles come from the same seed,
|
|
while application inference profiles are created and stored by the Bedrock control plane.
|
|
The catalog is a seed rather than a mirror of AWS: a few real models (Amazon Nova Micro
|
|
and Nova Lite, Titan Text Embeddings V2, Llama 3.1 8B Instruct and Claude Sonnet 4.5)
|
|
with the modalities, streaming support, lifecycle status and Regional availability their
|
|
[model cards](https://docs.aws.amazon.com/bedrock/latest/userguide/model-cards.html) publish,
|
|
and their US and EU system-defined inference profiles.
|
|
|
|
The answers depend on the calling Region, as on AWS:
|
|
|
|
- A model is listed when its card shows it served in that Region, or when one of its
|
|
inference profiles can be called from it. `GetFoundationModel` answers a catalog model
|
|
the Region does not serve, an unknown model id, and an ARN that does not name a
|
|
foundation model in the calling Region and partition with `ValidationException`, as AWS
|
|
does.
|
|
- `byOutputModality` accepts `SPEECH` and `VIDEO` as well as the published `TEXT`,
|
|
`IMAGE` and `EMBEDDING`, as AWS does. No catalog model produces speech or video, so
|
|
those filters return an empty list.
|
|
- A system-defined inference profile is listed only in its source Regions. Its
|
|
`models` are the foundation models in the destination Regions the card gives for
|
|
the calling Region, so `us.amazon.nova-lite-v1:0` called from `us-west-1` routes to four Regions and from
|
|
`us-east-1` to three. `GetInferenceProfile` on a profile the Region cannot use returns
|
|
`ResourceNotFoundException`.
|
|
- `inferenceTypesSupported` includes `ON_DEMAND` where the model is served in the Region
|
|
itself, and `INFERENCE_PROFILE` where a seeded system-defined profile can be called from
|
|
the Region. A model reachable only through a profile reports `INFERENCE_PROFILE` without
|
|
`ON_DEMAND`, so `byInferenceType=ON_DEMAND` leaves those out.
|
|
- `modelArn` is `arn:<partition>:bedrock:<region>::foundation-model/<modelId>`, and
|
|
the system-defined `inferenceProfileArn` carries the calling Region and account.
|
|
`GetInferenceProfile` answers an ARN of another service or without an account with
|
|
`ValidationException`, one of another account with `AccessDeniedException`, and one of another Region,
|
|
partition or resource type with `ResourceNotFoundException`.
|
|
- The error codes and statuses follow AWS; the message text is Floci's own.
|
|
|
|
`CreateInferenceProfile` accepts `modelSource.copyFrom` with a foundation-model ARN served
|
|
in the calling Region, or a system-defined inference-profile ARN available to the calling
|
|
Region and account. It creates a stored `APPLICATION` profile whose `GetInferenceProfile`
|
|
result includes its id, ARN, name, description, models and timestamps. `ListInferenceProfiles`
|
|
includes these profiles alongside the system-defined catalog; `type=APPLICATION` selects
|
|
only the created profiles. An application profile can be deleted by id or ARN and tagged
|
|
through the Bedrock tag actions. Copying an application profile is not supported.
|
|
|
|
Deviations: models that are not in the catalog are not listed, provisioned throughput is
|
|
never reported, and `customizationsSupported` is always empty, so `byCustomizationType`
|
|
and `byInferenceType=PROVISIONED` return no models. `ListInferenceProfiles` pages
|
|
up to 1000 profiles; `maxResults` outside 1 to 1000 is rejected with `ValidationException`.
|
|
|
|
## 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:
|
|
|
|
- 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 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
|
|
|
|
```bash
|
|
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
|
|
|
|
aws bedrock list-foundation-models --by-output-modality EMBEDDING
|
|
|
|
aws bedrock list-inference-profiles --type-equals SYSTEM_DEFINED
|
|
|
|
aws bedrock get-inference-profile --inference-profile-identifier us.amazon.nova-lite-v1:0
|
|
```
|