[bb-kv-store + 10 more] Attach IAM grants to the shared execution role - #356
Open
Simone319 wants to merge 1 commit into
Open
[bb-kv-store + 10 more] Attach IAM grants to the shared execution role#356Simone319 wants to merge 1 commit into
Simone319 wants to merge 1 commit into
Conversation
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 detectedLatest commit: a0933f6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 intomain) 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 intoprocess.envat cold start like every other block) instead of direct handler environment variables; the migration Lambda now maps the shared execution role's ARN.this.handler as lambda.Functioncasts and now-unusedlambdaimports in the auth/data blocks.executionRole(aBlocksRolethe stub handler assumes).Not in scope (deliberately):
handleris not removed here — event/observability blocks (bb-async-job,bb-cron-job,bb-realtime,bb-logger,bb-tracer,bb-dashboard) still use it.bb-traceralso does a compute-specifictracingConfigpoke, so it moves in Track C (C6), not here.Scope.handleris removed last, in C9, once all consumers migrate.Validation
npm run build✓npm run lint— zero blocking errors ✓npm run lint:deps,npm run check:api✓npm run test:e2e:local— 8/8 ✓this.handlerfor IAM after the change.Checklist