feat(neptune)!: migrate cluster access to consumer-side grants - #420
Open
laazyj wants to merge 2 commits into
Open
feat(neptune)!: migrate cluster access to consumer-side grants#420laazyj wants to merge 2 commits into
laazyj wants to merge 2 commits into
Conversation
Split allowAccessFrom's two halves so each is declared where its dependency points (ADR-0013). The IAM half becomes clusterGrants.connect/dataAccess, declared on the grantee and applied during its own build; the security-group rule stays on the cluster, whose own group it writes into, renamed allowDefaultPortFrom to match createInterfaceEndpointBuilder and now taking a plain IConnectable plus an optional rule description. BREAKING CHANGE: allowAccessFrom is removed. Use allowDefaultPortFrom(peer) for the network path and clusterGrants.connect(ref(...)) on the grantee for the IAM half. The ClusterAccessor type is removed; allowDefaultPortFrom takes an IConnectable. Closes #372
Drop the speculative clusterGrants.dataAccess escape hatch — a variadic action list no sibling capability namespace has, unused by the example and the docs, and permanent public API once published. connect delegates to the cluster's native grantConnect, which is what ADR-0013 named. Hoist isolatedVpc into a shared test helper, fold the network-access tests into one parameterised pair, scope the "no IAM grant here" assertion to the policies themselves, and trim the duplicated rationale from the README and the example's jsdoc.
Contributor
CoverageOverall line coverage: 99.40% across 24 package(s).
|
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.
What & why
Closes #372.
ADR-0013 deferred Neptune because
allowAccessFromcoupled two things that belong on opposite sides of the same edge: an IAM grant and a security-group rule. This splits them, and each half now sits where its dependency already points.The IAM half →
clusterGrants.connect(...)(newpackages/neptune/src/grants.ts). It delegates to the cluster's nativegrantConnect, is declared on the grantee builder, and is applied during that builder's ownbuild()— so the edge runs consumer → cluster, like every other grant in the library.The network half stays on the cluster, whose own security group the ingress rule is written into, renamed
allowDefaultPortFrom(peer, description?)to matchcreateInterfaceEndpointBuilder. It now takes a plainIConnectableand gained the optional rule description its sibling already had. Keeping the old name would have promised the IAM grant it no longer makes.The old shape forced the cluster to depend on its own consumer — the exact reverse edge (and latent cycle) the ADR exists to prevent. The example stack shows the fix:
graphnow depends onbastionSg, and a newbastionRolecomponent carries the grant and depends ongraph.Breaking change
allowAccessFromand the exportedClusterAccessortype are removed. Migration, also documented in the package README:The grantee must be a builder that accepts grants, so where the old call granted a construct that owns a role (an EC2 instance), that construct now takes an explicit role component. The deployed permissions are unchanged: the bastion role still gets
neptune-db:*plusAmazonSSMManagedInstanceCore, and the same ingress rule is emitted — only the logical IDs move, visible in the updated snapshot.Also updated: ADR-0013's out-of-scope bullet records the resolution in place (the precedent its API Gateway entry set), the
iamAuthenticationdefault's doc comment, and the examples README row plus the smoke test's description of what it proves.Notes for review
connectis exported. A variadicdataAccess(cluster, ...actions)was written and then dropped: no sibling namespace takes raw action strings, nothing in the repo used it, and it is permanent public API once published. A principal wanting less thanneptune-db:*writes a narrower policy of its own; named capabilities can be added later without a break.ec2.InstanceimplementsIGrantableandInstanceBuilderalready accepts arole, soInstanceBuildercould become a grantee (GrantQueue+.grant(), ~15 lines) and the example's explicitbastionRolewould collapse back into the instance. That is an@composurecdk/ec2feature rather than this migration, so it stayed out.Checklist
npm run verifypasses locallyGenerated by Claude Code