Skip to content

[bb-kv-store + 10 more] Attach IAM grants to the shared execution role - #356

Open
Simone319 wants to merge 1 commit into
mainfrom
zimzha/multi-compute-b3-execution-role-grants
Open

[bb-kv-store + 10 more] Attach IAM grants to the shared execution role#356
Simone319 wants to merge 1 commit into
mainfrom
zimzha/multi-compute-b3-execution-role-grants

Conversation

@Simone319

Copy link
Copy Markdown
Contributor

Problem

Building Blocks granted IAM permissions directly on the handler NodejsFunction (this.handler.grant*() / this.handler.addToRolePolicy(...)). That couples every block's IAM wiring to the one concrete Lambda function, which blocks the multi-compute model where a block's permissions must land on a shared role that any compute type can assume.

This PR is Issue B3 of Multi-Compute Phase 1. It depends only on A1 (the shared BlocksRole / Scope.executionRole, already merged into main) and is intentionally standalone — it does not stack on A2/A3.

Changes

Migrate every data, auth, and agent block's CDK layer from granting on the handler function to granting on the shared Blocks execution role (this.executionRole):

  • grant*(this.handler)grant*(this.executionRole)
  • this.handler.addToRolePolicy(...)this.executionRole.addToPrincipalPolicy(...)

Blocks migrated: bb-kv-store, bb-distributed-table, bb-file-bucket, bb-data, bb-app-setting, bb-knowledge-base, bb-email-client, bb-auth-cognito, bb-auth-oidc, bb-distributed-data, bb-agent.

Because the shared role is the same role the handler assumes, effective runtime permissions are identical — this is a behavior-preserving refactor.

Additional notes:

  • bb-distributed-data: the DSQL endpoint and region now flow through the config registry (registerConfig, loaded into process.env at cold start like every other block) instead of direct handler environment variables; the migration Lambda now maps the shared execution role's ARN.
  • Removed dead this.handler as lambda.Function casts and now-unused lambda imports in the auth/data blocks.
  • Test stubs updated to expose executionRole (a BlocksRole the stub handler assumes).

Not in scope (deliberately): handler is not removed here — event/observability blocks (bb-async-job, bb-cron-job, bb-realtime, bb-logger, bb-tracer, bb-dashboard) still use it. bb-tracer also does a compute-specific tracingConfig poke, so it moves in Track C (C6), not here. Scope.handler is removed last, in C9, once all consumers migrate.

Validation

  • npm run build
  • Unit tests for all affected packages pass (kv-store 95, distributed-table 117, file-bucket 92, data 366, app-setting 59, knowledge-base 129, email-client 20, auth-cognito 241, auth-oidc 112, distributed-data 157, agent 78) ✓
  • npm run lint — zero blocking errors ✓
  • npm run lint:deps, npm run check:api
  • npm run test:e2e:local — 8/8 ✓
  • Confirmed no data/auth/agent block references this.handler for IAM after the change.

Checklist

  • PR description included
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)

Migrate every data, auth, and agent block's CDK layer from granting
IAM permissions on the handler function to granting them on the shared
Blocks execution role (this.executionRole). Grants land on the same
role the handler assumes, so effective runtime permissions are
identical — this decouples IAM wiring from the concrete Lambda ahead
of the multi-compute model.

For bb-distributed-data, the DSQL endpoint and region now flow through
the config registry (loaded into process.env at cold start) instead of
direct handler environment variables, and the migration Lambda maps
the shared execution role's ARN.

Test stubs updated to expose executionRole. No behavior change.
@changeset-bot

changeset-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a0933f6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@aws-blocks/bb-kv-store Patch
@aws-blocks/bb-distributed-table Patch
@aws-blocks/bb-file-bucket Patch
@aws-blocks/bb-data Patch
@aws-blocks/bb-app-setting Patch
@aws-blocks/bb-knowledge-base Patch
@aws-blocks/bb-email-client Patch
@aws-blocks/bb-auth-cognito Patch
@aws-blocks/bb-auth-oidc Patch
@aws-blocks/bb-distributed-data Patch
@aws-blocks/bb-agent Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Simone319
Simone319 marked this pull request as ready for review August 13, 2026 14:20
@Simone319
Simone319 requested a review from a team as a code owner August 13, 2026 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant