Skip to content

feat(iam): read Bedrock from the generated tables, its routes vendored - #9169

Merged
pgermosen merged 1 commit into
mainfrom
feat/iam-bedrock-routes
Nov 22, 2026
Merged

pgermosen merged 1 commit into
mainfrom
feat/iam-bedrock-routes

Conversation

@pgermosen

@pgermosen pgermosen commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Summary

Bedrock is read from the generated tables now, like S3 since #9155. This removes ResourceArnBuilder's Bedrock branch and the registry's three Bedrock resource-policy rules.

Its routes and the switch have to land together:

  • With Bedrock still built by hand, vendoring its routes would check every route on *, refusing a grant scoped to a guardrail.

  • Without its routes, reading it from the table would lose the resource-policy check the builder makes.

  • Routes. regen_rest_routes.py vendors the bedrock, bedrock-agent and bedrock-runtime models, all signed for the bedrock scope. bedrock-agent is needed because its PutResourcePolicy carries resourceArn in its path, where bedrock's carries it in its body: a member the two clients locate apart, which is read for the client whose route the request matched.

  • Resources.

    • regen_iam_request_resources.py reads bedrock instead of leaving it to the builder: 283 operations join iam-request-resources.json.
    • A guardrail request is checked on the guardrail its path names: GET /guardrails/<id> is arn:aws:bedrock:<region>:<account>:guardrail/<id>, where the builder gave *.
    • A resource-policy request is still checked on the ARN it carries.
    • TagResource, UntagResource and ListTagsForResource are checked on the guardrail or application inference profile ARN in resourceARN. Botocore's pattern for that member makes the account optional, ([0-9]{12}|), and the generator's reader of a pattern's type words only found words directly after a fixed account. It returned custom-model alone, which dropped the other types from the bedrock client's row. It now reads each :word/ alternative after an optional account too. Regenerating changes only these three Bedrock rows.
    • InvokeModel and InvokeModelWithResponseStream are checked on marketplace/model-endpoint/all-access. No generator rule reads the kinds modelId's documentation lists one by one, so the action's one type with no variable of its own is what the table names. The docs say so.
    • The authorized-actions file lists Bedrock's actions with no resource type.
  • Tags.

    • BedrockStoredResourceArns gives IAM the tags Bedrock holds on a guardrail or an application inference profile, for aws:ResourceTag, read in place and matched on the whole ARN.
    • regen_iam_tag_on_create.py reads bedrock instead of listing it as not covered, so a CreateGuardrail or CreateInferenceProfile carrying tags also needs bedrock:TagResource, with aws:RequestTag and aws:TagKeys from those tags.
  • Concurrency. A guardrail's untag now replaces its tag map instead of editing it, so a reader never sees half of one. Both models keep their tag maps volatile.

  • Tests.

    • ResourceArnBuilderTest's Bedrock test goes through the table on matching routes.
    • BedrockResourcePolicyIamEnforcementIntegrationTest adds a Deny on one guardrail refusing its three tag calls and not another's, and a guardrail created with tags refused when bedrock:TagResource is denied.
    • The generator test covers a pattern with an optional account.
    • The existing Bedrock tests pass unchanged.
  • Docs: docs/services/bedrock.md.

Type of change

  • Bug fix (fix:)
  • New feature (feat:)
  • Breaking change (feat!: or fix!:)
  • Docs / chore

AWS Compatibility

Botocore 1.43.118:

  • bedrock's PutResourcePolicy is POST /resource-policy with resourceArn in its body. bedrock-agent's is PUT /resourcepolicy/{resourceArn}, giving resourceArn "location": "uri".
  • GetGuardrail is GET /guardrails/{guardrailIdentifier}.
  • TagResource's resourceARN is TaggableResourcesArn, whose pattern is ...:([0-9]{12}|)((:(fine-tuning-job|model-customization-job|custom-model)/...)|(:guardrail/[a-z0-9]+$)|...|(:(inference-profile|application-inference-profile)/[a-zA-Z0-9-:.]+$)|...).
  • CreateGuardrail and CreateInferenceProfile carry tags, a list of key/value pairs.

The Service Reference gives bedrock:GetGuardrail the guardrail type, arn:${Partition}:bedrock:${Region}:${Account}:guardrail/${GuardrailId}.

Checklist

  • ./mvnw test passes locally (ran ResourceArnBuilderTest, IamRestRouteCoverageTest, IamActionRegistryTest, RequestResourceMembersTest, RequestResourcesTest, IamRestRoutesTest, IamAuthorizedActionsTest TagOnCreateTest, TagOnCreateMembersTest, TagOnCreateNamespacesIntegrationTest, RequestResourceNamespacesIntegrationTest and Bedrock's and Bedrock Runtime's 18 test classes, not the whole suite)
  • New or updated integration test added
  • Commit messages follow Conventional Commits
  • I have no more than 2 open, non-draft pull requests and no more than 4 open pull requests in total (drafts included) in this repository (maintainers and dependency bots are exempt).

@pgermosen pgermosen added bedrock Amazon Bedrock Runtime enhancement New feature or request iam AWS Identity and Access Management (IAM) labels Nov 22, 2026
@qodo-code-review

qodo-code-review Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Authorize Bedrock requests using generated IAM resource tables

✨ Enhancement 🕐 40+ Minutes

Grey Divider

AI Description

• Move Bedrock authorization from hand-built rules to generated routes and resource tables, enabling
 resource-scoped grants.
• Resolve stored Bedrock tags for IAM conditions and make tag reads consistent during untagging.
• Update Bedrock documentation and test guardrail and resource-policy ARN resolution.
Merge Risk 🟡 Medium

Blast radius 🟡 Medium 💥 2 capabilities

  • 2 affected capabilities within one bounded functional scope: bedrock_iam_integration.
  • This is one bounded integration: Bedrock request dispatch, IAM action selection, and resource-policy evaluation.
  • The route tables, action registry, and resource builder are propagation hops for the same authorization outcome, not independent capabilities.
  • Guardrail and application inference profile tagging are distinct user-visible operations within the same bounded Bedrock IAM integration.
  • The service mutation, model field, and IAM stored-tag reader are producer/storage/consumer hops for those tag-management outcomes.
Sources

src/main/resources/aws/rest-routes.json[315-318]

    "bedrock": {
      "credentialScope": "bedrock",
      "apiVersion": "2023-04-20",
      "accessDeniedStatus": 403,

src/main/java/io/floci/aws/services/bedrock/BedrockStoredResourceArns.java[48-57]

    public Map<String, String> storedTags(String arn) {
        if (!AwsArnUtils.isArnFor(arn, NAMESPACE)) {
            return Map.of();
        }
        AwsArnUtils.Arn parsed = AwsArnUtils.parse(arn);
        String account = regionResolver.getAccountId();
        if (!parsed.accountId().equals(account) || parsed.region().isBlank()) {
            return Map.of();
        }
        return StoredResourceArns.withEmptyValues(bedrock.tagsInAccount(account, arn));
Behavioral complexity 🟡 Medium 🧩 Interacting branches, Compatibility cases

  • Before: Bedrock resource-policy authorization used a small hand-built path/body special case, while most Bedrock requests were not represented by generated request-resource metadata.
  • After: generated tables cover multiple Bedrock endpoint namespaces and combine REST route labels, path ARN segments, JSON body members, modeled resource types, wildcard fallback, and tag-on-create checks.
  • New correctness conditions are that the dispatched operation, endpoint namespace, route labels, body members, and resource ARN format remain aligned across those representations, including mixed old/new policy clients.
  • The generic ResourceArnBuilder branch itself is straightforward delegation; the added complexity comes from the introduced compatibility cases and their interactions, not from merely reusing RequestResources.
Sources

src/main/resources/aws/rest-routes.json[315-318]

    "bedrock": {
      "credentialScope": "bedrock",
      "apiVersion": "2023-04-20",
      "accessDeniedStatus": 403,
Potential damage 🔴 High 🩹 Confidentiality

  • If a resource-scoped deny or allow is evaluated against the wrong resource, an identity could be authorized for a Bedrock resource it should not access, or a deny could fail to protect that resource.
  • The same fault can also cause broad request refusal.
  • The confidentiality/integrity impact is limited to Bedrock operations and policies reaching the faulty mapping; no source evidence shows propagation to unrelated AWS services.
  • Reverting the code restores the previous authorization implementation, but requests made while the faulty mapping was active may have exposed or changed Bedrock-managed state and require policy review or external compensation.
  • Denied requests recover after deployment rollback; unauthorized successful requests are not automatically reversible.
Sources

src/main/resources/aws/rest-routes.json[315-318]

    "bedrock": {
      "credentialScope": "bedrock",
      "apiVersion": "2023-04-20",
      "accessDeniedStatus": 403,
Assessed commit e428430
Diagram

graph TD
  Routes["Vendored routes"] --> Registry["Action registry"] --> Builder["Resource builder"] --> Table["Request resources"] --> IAM["IAM evaluation"]
  Builder --> Tags["Stored tag adapter"] --> Bedrock["Bedrock storage"]
  Tags --> IAM
Loading
High-Level Assessment

Keep the generated-table approach and land the routes with it. Retaining hand-built Bedrock logic would perpetuate wildcard authorization for guardrails, while switching tables without vendoring routes would lose reliable operation and request-member matching.

Files changed (13) +704 / -53

Enhancement (9) +675 / -10
BedrockService.javaExpose stored tags and replace guardrail tags atomically +28/-2

Expose stored tags and replace guardrail tags atomically

• Adds an account-aware lookup for guardrail and application inference profile tags that verifies the stored ARN. Guardrail untagging now publishes a replacement map instead of mutating the existing one.

src/main/java/io/floci/aws/services/bedrock/BedrockService.java

BedrockStoredResourceArns.javaProvide Bedrock resource tags to IAM +59/-0

Provide Bedrock resource tags to IAM

• Adds a StoredResourceArns implementation for the bedrock namespace. It returns tags for supported resources only when the ARN belongs to the request account and identifies a stored resource.

src/main/java/io/floci/aws/services/bedrock/BedrockStoredResourceArns.java

ApplicationInferenceProfile.javaPublish inference profile tag maps safely +1/-1

Publish inference profile tag maps safely

• Marks the tag map volatile so IAM readers can observe replacement maps across threads.

src/main/java/io/floci/aws/services/bedrock/model/ApplicationInferenceProfile.java

Guardrail.javaPublish guardrail tag maps safely +1/-1

Publish guardrail tag maps safely

• Marks the tag map volatile to support consistent cross-thread reads of replacement maps.

src/main/java/io/floci/aws/services/bedrock/model/Guardrail.java

iam-authorized-actions.jsonList Bedrock actions without resource types +68/-0

List Bedrock actions without resource types

• Adds generated Bedrock action names that the service reference identifies as having no resource type.

src/main/resources/aws/iam-authorized-actions.json

iam-request-resources.jsonAdd generated Bedrock operation resources +287/-4

Add generated Bedrock operation resources

• Moves Bedrock out of hand-built namespaces and adds 283 operation entries across its API models. Entries describe actions, resource types, request members, and route-specific locations, including the two PutResourcePolicy forms.

src/main/resources/aws/iam-request-resources.json

rest-routes.jsonVendor Bedrock REST operation routes +226/-0

Vendor Bedrock REST operation routes

• Adds Bedrock, Bedrock Agent, and Bedrock Runtime routes under the bedrock credential scope. These routes let IAM distinguish operations and locate path members.

src/main/resources/aws/rest-routes.json

regen_iam_request_resources.pyGenerate Bedrock request-resource entries +2/-2

Generate Bedrock request-resource entries

• Adds Bedrock to generated namespaces and removes it from the hand-built list, keeping regeneration aligned with the checked-in table.

tools/aws/regen_iam_request_resources.py

regen_rest_routes.pyGenerate routes for three Bedrock API models +3/-0

Generate routes for three Bedrock API models

• Includes bedrock, bedrock-agent, and bedrock-runtime models in REST-route generation, all mapped to the bedrock credential scope.

tools/aws/regen_rest_routes.py

Refactor (2) +0 / -27
IamActionRegistry.javaRemove Bedrock resource-policy route overrides +0/-5

Remove Bedrock resource-policy route overrides

• Deletes three manually registered Bedrock resource-policy rules so operation identification can use vendored REST routes.

src/main/java/io/floci/aws/services/iam/IamActionRegistry.java

ResourceArnBuilder.javaRemove hand-built Bedrock ARN resolution +0/-22

Remove hand-built Bedrock ARN resolution

• Removes Bedrock-specific resource-policy parsing and the Bedrock switch branch. Bedrock targets now follow the shared generated-table path.

src/main/java/io/floci/aws/services/iam/ResourceArnBuilder.java

Tests (1) +25 / -13
ResourceArnBuilderTest.javaTest table-driven Bedrock target resolution +25/-13

Test table-driven Bedrock target resolution

• Changes the Bedrock test to resolve resources through matched routes and generated operation entries. It checks encoded resource-policy ARNs, body-carried ARNs, invalid values, and a path-named guardrail.

src/test/java/io/floci/aws/services/iam/ResourceArnBuilderTest.java

Documentation (1) +4 / -3
bedrock.mdDocument resource-scoped Bedrock IAM checks +4/-3

Document resource-scoped Bedrock IAM checks

• Explains that Bedrock and Bedrock Runtime requests use generated action and resource data, including guardrail path identifiers and resource-policy ARNs.

docs/services/bedrock.md

@qodo-code-review

qodo-code-review Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Tagged creates bypass tagging permission ✓ Resolved

Resolving commit: e428430

Resolution reason
Adds Bedrock create operations (including CreateGuardrail and CreateInferenceProfile) to the
tag-on-create authorization table with bedrock:TagResource as the dependent tagging action and
requestTags enabled, plus a test that a tagged create is denied when TagResource is denied.
Description
CreateGuardrail and CreateInferenceProfile accept and persist creation tags, but the newly
routed operations have no Bedrock entries in the tag-on-create authorization table. A caller
permitted to create either resource but denied bedrock:TagResource can attach tags during creation
without the dependent action or request-tag conditions being checked.

2. Model calls check an unrelated endpoint ✗ Dismissed
Description
The generated InvokeModel resource row contains only an unfilled marketplace endpoint type,
producing its fixed all-access ARN instead of using the route's modelId. A request invoking a
different model is therefore affected by permissions on that marketplace endpoint, while permissions
scoped to the model named in the path are not evaluated against it.

3. Guardrail tag restrictions can be bypassed ✓ Resolved

Resolving commit: e428430

Resolution reason
The commit rewrites the TagResource, UntagResource and ListTagsForResource rows so their resource
rules include a "bedrock" endpoint rule with types application-inference-profile, guardrail, etc.,
using arn "resourceARN" (previously only custom-model had that rule). This makes IAM read the
resourceARN body member for guardrail and application-inference-profile tagging requests. It also
adds bedrock tag-on-create rules for CreateGuardrail/CreateInferenceProfile and integration tests
that deny tagging actions on one guardrail and verify refusal, covering the
aws:ResourceTag/resource-specific deny scenario. The generator is changed to find taggable ARN type
words, and the table is regenerated rather than the generator being directly taught the rule, so the
approach differs from the suggested fix in detail but addresses the same gap.
Description
The generated TagResource, UntagResource, and ListTagsForResource rows list guardrails and
application inference profiles as possible types but contain no resource rule that reads their
resourceARN body member. When an allow on * is paired with a resource-specific deny or
aws:ResourceTag restriction, IAM evaluates no target ARN or stored tags for these requests even
though the Bedrock handlers act on the named resource.


Informational

4. Profile reads ignore scoped permissions 🐞 Bug ≡ Correctness
Description
The generated GetInferenceProfile row declares profile resource types but has an empty resource
list, so resource construction falls back to *. The handler resolves an individual application or
system profile from inferenceProfileIdentifier; an allow scoped to that profile cannot authorize
the read, and a deny scoped to it does not match.
Code

src/main/resources/aws/iam-request-resources.json[385]

+    "bedrock:GetInferenceProfile": {"action": "bedrock:GetInferenceProfile", "types": ["application-inference-profile", "inference-profile"], "resources": []},
Relevance

● Weak

Closest precedent: dismissed as intentional, glue:GetWorkflowRun has an empty resource extractor so
scoped allows/denies never apply. Same pattern here.

PR-#8529

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The added table entry provides no resource rule, which makes the builder use *, whereas the
controller and service identify a specific profile for the same request.

src/main/resources/aws/iam-request-resources.json[385-385]
src/main/java/io/floci/aws/services/bedrock/BedrockController.java[200-214]
src/main/java/io/floci/aws/services/bedrock/BedrockService.java[416-433]
src/main/java/io/floci/aws/services/iam/ResourceArnBuilder.java[170-189]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
GetInferenceProfile is newly read from the generated table but names no IAM resource despite receiving a profile identifier.
## Fix Focus Areas
- src/main/resources/aws/iam-request-resources.json[385-385]
- src/main/java/io/floci/aws/services/bedrock/BedrockController.java[200-214]
- tools/aws/regen_iam_request_resources.py[307-310]
## Recommended Fix
Resolve `inferenceProfileIdentifier` to the application or system profile ARN, handling both identifiers and ARN inputs, and generate or implement the corresponding resource mapping. Test scoped allow and deny policies for both profile kinds.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


Grey Divider

Context sources
✅ Linked PRs:
  🌐 PR #9155
✅ Compliance rules (platform): 21 rules
✅ Cross-repo context — repo relationships
  Explored: repo: floci-io/testcontainers-floci (sha: e900a79e) — View relationship
  Explored: repo: floci-io/floci-ui (sha: 2170f6d7) — View relationship
Review mode: Auto: ⚖️ Balanced: Downgraded extended -> standard: change is below the extended eligibility bar (hunks 17/18, lines 757/200; both must reach the floor). Router rationale: Cross-cutting IAM, routing, ARN, tagging changes create independent defect risks.

Grey Divider

Tip of the day
💡 Did you know, you can route each severity your way: inline, summary, both, or drop

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread src/main/resources/aws/rest-routes.json Resolved
Bedrock leaves ResourceArnBuilder's own branch and the registry's three resource-policy rules: its
requests are matched on their botocore routes and checked on the resources the request-resources table
reads. regen_rest_routes.py vendors the bedrock, bedrock-agent and bedrock-runtime models, all signed
for the bedrock scope; bedrock-agent's are needed because its PutResourcePolicy carries resourceArn in
its path where bedrock's carries it in its body, a member the two clients locate apart.
regen_iam_request_resources.py reads bedrock instead of leaving it to the builder, so a guardrail
request is checked on the guardrail its path names and a resource-policy request on the ARN it carries.
The generator's reader of an ARN pattern's type words also reads one whose account is optional, so the
tag actions are checked on the guardrail or application inference profile ARN they carry, and
regen_iam_tag_on_create.py reads bedrock, so a create carrying tags also needs bedrock:TagResource.

BedrockStoredResourceArns gives IAM the tags Bedrock holds on a guardrail or an application inference
profile, for aws:ResourceTag, read in place and matched on the whole ARN; a guardrail's untag now
replaces its tag map rather than editing it, so a reader never sees half of one, and both models keep
their tags volatile.
@pgermosen
pgermosen force-pushed the feat/iam-bedrock-routes branch from e168232 to e428430 Compare November 22, 2026 03:02
@pgermosen
pgermosen merged commit 5b4bc0e into main Nov 22, 2026
26 checks passed
@pgermosen
pgermosen deleted the feat/iam-bedrock-routes branch November 22, 2026 04:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bedrock Amazon Bedrock Runtime enhancement New feature or request iam AWS Identity and Access Management (IAM)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant