@composurecdk/neptune 0.9.4 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +26 -11
- package/dist/commonjs/cluster-builder.d.ts +31 -31
- package/dist/commonjs/cluster-builder.d.ts.map +1 -1
- package/dist/commonjs/cluster-builder.js +25 -27
- package/dist/commonjs/cluster-builder.js.map +1 -1
- package/dist/commonjs/cluster-defaults.d.ts.map +1 -1
- package/dist/commonjs/cluster-defaults.js +3 -2
- package/dist/commonjs/cluster-defaults.js.map +1 -1
- package/dist/commonjs/grants.d.ts +34 -0
- package/dist/commonjs/grants.d.ts.map +1 -0
- package/dist/commonjs/grants.js +37 -0
- package/dist/commonjs/grants.js.map +1 -0
- package/dist/commonjs/index.d.ts +2 -1
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +3 -1
- package/dist/commonjs/index.js.map +1 -1
- package/dist/esm/cluster-builder.d.ts +31 -31
- package/dist/esm/cluster-builder.d.ts.map +1 -1
- package/dist/esm/cluster-builder.js +25 -27
- package/dist/esm/cluster-builder.js.map +1 -1
- package/dist/esm/cluster-defaults.d.ts.map +1 -1
- package/dist/esm/cluster-defaults.js +3 -2
- package/dist/esm/cluster-defaults.js.map +1 -1
- package/dist/esm/grants.d.ts +34 -0
- package/dist/esm/grants.d.ts.map +1 -0
- package/dist/esm/grants.js +34 -0
- package/dist/esm/grants.js.map +1 -0
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/package.json +10 -9
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jason Duffett
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -103,30 +103,45 @@ Both the key and the encryption setting are fixed at creation: Neptune cannot en
|
|
|
103
103
|
|
|
104
104
|
Audit log _export_ only emits data once audit logging is _enabled_ in the cluster parameter group. So the builder auto-creates a cluster parameter group with `neptune_enable_audit_log = "1"` (parallel to how `createVpcBuilder` auto-creates a flow-log group), with the family derived from the configured engine version. Add or override parameters with `.clusterParameters({...})`, or supply your own group with `.clusterParameterGroup(myGroup)` (mutually exclusive with `.clusterParameters()`).
|
|
105
105
|
|
|
106
|
-
## Granting access
|
|
106
|
+
## Granting access
|
|
107
107
|
|
|
108
|
-
Because IAM authentication is on by default, a principal needs
|
|
108
|
+
Because IAM authentication is on by default, a principal needs two things to reach the cluster, and each is declared where its dependency already points ([ADR-0013](../../docs/adr/0013-consumer-side-grants.md)). The **network path** is a rule in the cluster's own security group, so it stays on the cluster — `allowDefaultPortFrom(peer)`, the same method `createInterfaceEndpointBuilder` exposes. The **IAM grant** lands on the consumer's principal, so it is declared on the grantee builder, pointing back at the cluster via a `ref`:
|
|
109
109
|
|
|
110
110
|
```ts
|
|
111
|
-
import {
|
|
111
|
+
import { clusterGrants, type ClusterBuilderResult } from "@composurecdk/neptune";
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
compose(
|
|
114
114
|
{
|
|
115
|
-
network: createVpcBuilder().maxAzs(2),
|
|
116
|
-
bastion: createInstanceBuilder().vpc(ref("network").get("vpc")).instanceType(/* ... */),
|
|
117
115
|
graph: createClusterBuilder()
|
|
118
|
-
.vpc(ref("network").get("vpc"))
|
|
116
|
+
.vpc(ref<VpcBuilderResult>("network").get("vpc"))
|
|
119
117
|
.instanceType(InstanceType.SERVERLESS)
|
|
120
118
|
.serverlessScalingConfiguration({ minCapacity: 1, maxCapacity: 8 })
|
|
121
|
-
.
|
|
119
|
+
.allowDefaultPortFrom(
|
|
120
|
+
ref<SecurityGroupBuilderResult>("bastionSg").get("securityGroup"),
|
|
121
|
+
"Bastion to Neptune",
|
|
122
|
+
),
|
|
123
|
+
|
|
124
|
+
bastion: createInstanceBuilder()
|
|
125
|
+
.vpc(ref<VpcBuilderResult>("network").get("vpc"))
|
|
126
|
+
.securityGroup(ref<SecurityGroupBuilderResult>("bastionSg").get("securityGroup"))
|
|
127
|
+
.grant(clusterGrants.connect(ref<ClusterBuilderResult>("graph").get("cluster"))),
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
graph: ["network", "bastionSg"], // cluster → the SG its ingress rule names
|
|
131
|
+
bastion: ["network", "bastionSg", "graph"], // consumer → resource; no reverse edge, no cycle
|
|
122
132
|
},
|
|
123
|
-
{ network: [], bastion: ["network"], graph: ["network", "bastion"] },
|
|
124
133
|
);
|
|
125
134
|
```
|
|
126
135
|
|
|
127
|
-
|
|
136
|
+
`clusterGrants.connect(cluster)` delegates to the cluster's native `grantConnect`, which grants the whole `neptune-db:*` namespace on the cluster's ARN. A principal that needs less wants a narrower policy of its own over the [data-plane actions](https://docs.aws.amazon.com/neptune/latest/userguide/iam-dp-actions.html).
|
|
137
|
+
|
|
138
|
+
The grant goes on any builder that accepts one — an `InstanceBuilder`, a `FunctionBuilder`, or a `RoleBuilder` where the principal is a role you own. Each routes the policy onto whichever role the component runs as, so no separate role component is needed to hold it.
|
|
139
|
+
|
|
140
|
+
`allowDefaultPortFrom(peer)` takes any `IConnectable` — a security group, an EC2 instance, a VPC-attached Lambda function — and applies `cluster.connections.allowDefaultPortFrom(peer, description)`, opening ingress on the cluster's SG and the matching egress on the peer's. Prefer the peer's _security group_ over the peer itself: naming a compute component makes the cluster depend on it, the reverse edge consumer-side grants exist to avoid.
|
|
141
|
+
|
|
142
|
+
If you disable IAM authentication (`.iamAuthentication(false)`), the network path is the whole grant — the alpha L2 then rejects a data-plane grant at synth rather than emitting an inert policy, so drop the `clusterGrants` call along with IAM auth.
|
|
128
143
|
|
|
129
|
-
|
|
144
|
+
For a worked example, see the [Neptune graph stack](../examples/src/neptune-graph-app.ts).
|
|
130
145
|
|
|
131
146
|
## Recommended Alarms
|
|
132
147
|
|
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
import { type Alarm } from "aws-cdk-lib/aws-cloudwatch";
|
|
2
|
-
import { type IConnectable
|
|
3
|
-
import { type IGrantable } from "aws-cdk-lib/aws-iam";
|
|
2
|
+
import { type IConnectable } from "aws-cdk-lib/aws-ec2";
|
|
4
3
|
import { DatabaseCluster, type DatabaseClusterProps, type IClusterParameterGroup, type IDatabaseCluster, type ISubnetGroup } from "@aws-cdk/aws-neptune-alpha";
|
|
5
4
|
import { type IConstruct } from "constructs";
|
|
6
5
|
import { COPY_STATE, type Lifecycle, type Resolvable } from "@composurecdk/core";
|
|
7
6
|
import { type ITaggedBuilder } from "@composurecdk/cloudformation";
|
|
8
7
|
import { AlarmDefinitionBuilder } from "@composurecdk/cloudwatch";
|
|
9
8
|
import type { NeptuneClusterAlarmConfig } from "./cluster-alarm-config.js";
|
|
10
|
-
/**
|
|
11
|
-
* A principal that can be granted access to a Neptune cluster via
|
|
12
|
-
* {@link IClusterBuilder.allowAccessFrom}. Must be both an {@link IConnectable}
|
|
13
|
-
* (so its security group can be opened to the cluster's port) and an
|
|
14
|
-
* {@link IGrantable} (so it can be granted IAM `connect`). EC2 instances,
|
|
15
|
-
* Lambda functions, and Fargate tasks all satisfy this.
|
|
16
|
-
*/
|
|
17
|
-
export type ClusterAccessor = IConnectable & IGrantable;
|
|
18
9
|
/**
|
|
19
10
|
* Configuration properties for the Neptune cluster builder.
|
|
20
11
|
*
|
|
@@ -25,21 +16,25 @@ export type ClusterAccessor = IConnectable & IGrantable;
|
|
|
25
16
|
*
|
|
26
17
|
* - `vpc` is supplied via the dedicated {@link IClusterBuilder.vpc | .vpc()}
|
|
27
18
|
* method (it is required).
|
|
28
|
-
* - `securityGroups` accepts `Resolvable
|
|
19
|
+
* - `securityGroups` accepts `Resolvable` entries.
|
|
29
20
|
* - `kmsKey` accepts a `Resolvable` key.
|
|
30
21
|
*
|
|
31
22
|
* It also adds builder-specific options for the auto-created cluster
|
|
32
23
|
* parameter group and recommended alarms.
|
|
24
|
+
*
|
|
25
|
+
* Each re-declared prop reads its inner type from CDK's own prop rather than
|
|
26
|
+
* naming an interface, so it keeps tracking the installed `aws-cdk-lib` as CDK
|
|
27
|
+
* moves its prop types (ADR-0018).
|
|
33
28
|
*/
|
|
34
29
|
export interface ClusterBuilderProps extends Omit<DatabaseClusterProps, "vpc" | "securityGroups" | "kmsKey"> {
|
|
35
30
|
/**
|
|
36
|
-
* Security groups to attach to the cluster. Accepts concrete
|
|
37
|
-
*
|
|
38
|
-
*
|
|
31
|
+
* Security groups to attach to the cluster. Accepts concrete security
|
|
32
|
+
* groups or {@link Ref}s that resolve to them at build time (e.g. a sibling
|
|
33
|
+
* `SecurityGroupBuilder`).
|
|
39
34
|
*
|
|
40
35
|
* @default - CDK creates a security group for the cluster.
|
|
41
36
|
*/
|
|
42
|
-
securityGroups?: readonly Resolvable<
|
|
37
|
+
securityGroups?: readonly Resolvable<NonNullable<DatabaseClusterProps["securityGroups"]>[number]>[];
|
|
43
38
|
/**
|
|
44
39
|
* The customer-managed KMS key used to encrypt the cluster's storage at
|
|
45
40
|
* rest.
|
|
@@ -149,30 +144,35 @@ declare class ClusterBuilder implements Lifecycle<ClusterBuilderResult> {
|
|
|
149
144
|
#private;
|
|
150
145
|
props: Partial<ClusterBuilderProps>;
|
|
151
146
|
/**
|
|
152
|
-
* Sets the VPC the cluster runs in. Required. Accepts a concrete
|
|
153
|
-
* {@link
|
|
154
|
-
*
|
|
147
|
+
* Sets the VPC the cluster runs in. Required. Accepts a concrete VPC or a
|
|
148
|
+
* {@link Ref} that resolves to one at build time — the standard
|
|
149
|
+
* cross-component wiring path (e.g. to a sibling `VpcBuilder`).
|
|
155
150
|
*
|
|
156
151
|
* @param vpc - The VPC or a Ref to one.
|
|
157
152
|
* @returns This builder for chaining.
|
|
158
153
|
*/
|
|
159
|
-
vpc(vpc: Resolvable<
|
|
154
|
+
vpc(vpc: Resolvable<NonNullable<DatabaseClusterProps["vpc"]>>): this;
|
|
160
155
|
/**
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
156
|
+
* Opens the cluster's port to `peer` via CDK's
|
|
157
|
+
* `cluster.connections.allowDefaultPortFrom(peer)` — ingress on the
|
|
158
|
+
* cluster's security group from the peer's, and the matching egress back on
|
|
159
|
+
* the peer's.
|
|
160
|
+
*
|
|
161
|
+
* This is the **network** half of reaching the cluster. Because IAM
|
|
162
|
+
* authentication is on by default, the peer's principal also needs the
|
|
163
|
+
* data-plane grant, declared on that principal's own builder:
|
|
164
|
+
* `role.grant(clusterGrants.connect(ref("graph", (r) => r.cluster)))` — the
|
|
165
|
+
* consumer-side shape every grant in the library follows (ADR-0013).
|
|
167
166
|
*
|
|
168
|
-
* Accepts a concrete {@link
|
|
169
|
-
*
|
|
170
|
-
* `afterBuild` hook.
|
|
167
|
+
* Accepts a concrete {@link IConnectable} (a `SecurityGroup`, an `Instance`,
|
|
168
|
+
* a `Function` in a VPC, …) or a {@link Ref} to one, so the rule can be
|
|
169
|
+
* declared inside `compose()` rather than wired up in an `afterBuild` hook.
|
|
171
170
|
*
|
|
172
|
-
* @param peer - The
|
|
171
|
+
* @param peer - The connectable to open the port to, or a Ref to one.
|
|
172
|
+
* @param description - Optional description recorded on the ingress rule.
|
|
173
173
|
* @returns This builder for chaining.
|
|
174
174
|
*/
|
|
175
|
-
|
|
175
|
+
allowDefaultPortFrom(peer: Resolvable<IConnectable>, description?: string): this;
|
|
176
176
|
/**
|
|
177
177
|
* Adds a custom CloudWatch alarm to be created alongside the recommended
|
|
178
178
|
* alarms. The callback receives an {@link AlarmDefinitionBuilder} scoped to
|
|
@@ -194,7 +194,7 @@ declare class ClusterBuilder implements Lifecycle<ClusterBuilderResult> {
|
|
|
194
194
|
* This is the entry point for defining a Neptune component. The returned
|
|
195
195
|
* builder exposes every {@link ClusterBuilderProps} property as a fluent
|
|
196
196
|
* setter/getter, plus {@link IClusterBuilder.vpc | .vpc()} and
|
|
197
|
-
* {@link IClusterBuilder.
|
|
197
|
+
* {@link IClusterBuilder.allowDefaultPortFrom | .allowDefaultPortFrom()} for
|
|
198
198
|
* cross-component wiring with Ref support. It implements {@link Lifecycle}
|
|
199
199
|
* for use with {@link compose}.
|
|
200
200
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cluster-builder.d.ts","sourceRoot":"","sources":["../../src/cluster-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,KAAK,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"cluster-builder.d.ts","sourceRoot":"","sources":["../../src/cluster-builder.ts"],"names":[],"mappings":"AAAA,O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
#customAlarms = [];
|
|
14
|
-
#
|
|
14
|
+
#access = [];
|
|
15
15
|
#vpc;
|
|
16
16
|
/**
|
|
17
|
-
* Sets the VPC the cluster runs in. Required. Accepts a concrete
|
|
18
|
-
* {@link
|
|
19
|
-
*
|
|
17
|
+
* Sets the VPC the cluster runs in. Required. Accepts a concrete VPC or a
|
|
18
|
+
* {@link Ref} that resolves to one at build time — the standard
|
|
19
|
+
* cross-component wiring path (e.g. to a sibling `VpcBuilder`).
|
|
20
20
|
*
|
|
21
21
|
* @param vpc - The VPC or a Ref to one.
|
|
22
22
|
* @returns This builder for chaining.
|
|
@@ -26,22 +26,27 @@ class ClusterBuilder {
|
|
|
26
26
|
return this;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* (granting the IAM `connect` action required by the cluster's
|
|
34
|
-
* IAM-authentication default).
|
|
29
|
+
* Opens the cluster's port to `peer` via CDK's
|
|
30
|
+
* `cluster.connections.allowDefaultPortFrom(peer)` — ingress on the
|
|
31
|
+
* cluster's security group from the peer's, and the matching egress back on
|
|
32
|
+
* the peer's.
|
|
35
33
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
34
|
+
* This is the **network** half of reaching the cluster. Because IAM
|
|
35
|
+
* authentication is on by default, the peer's principal also needs the
|
|
36
|
+
* data-plane grant, declared on that principal's own builder:
|
|
37
|
+
* `role.grant(clusterGrants.connect(ref("graph", (r) => r.cluster)))` — the
|
|
38
|
+
* consumer-side shape every grant in the library follows (ADR-0013).
|
|
39
39
|
*
|
|
40
|
-
*
|
|
40
|
+
* Accepts a concrete {@link IConnectable} (a `SecurityGroup`, an `Instance`,
|
|
41
|
+
* a `Function` in a VPC, …) or a {@link Ref} to one, so the rule can be
|
|
42
|
+
* declared inside `compose()` rather than wired up in an `afterBuild` hook.
|
|
43
|
+
*
|
|
44
|
+
* @param peer - The connectable to open the port to, or a Ref to one.
|
|
45
|
+
* @param description - Optional description recorded on the ingress rule.
|
|
41
46
|
* @returns This builder for chaining.
|
|
42
47
|
*/
|
|
43
|
-
|
|
44
|
-
this.#
|
|
48
|
+
allowDefaultPortFrom(peer, description) {
|
|
49
|
+
this.#access.push({ peer, description });
|
|
45
50
|
return this;
|
|
46
51
|
}
|
|
47
52
|
/**
|
|
@@ -61,7 +66,7 @@ class ClusterBuilder {
|
|
|
61
66
|
[core_1.COPY_STATE](target) {
|
|
62
67
|
target.#vpc = this.#vpc;
|
|
63
68
|
target.#customAlarms.push(...this.#customAlarms);
|
|
64
|
-
target.#
|
|
69
|
+
target.#access.push(...this.#access);
|
|
65
70
|
}
|
|
66
71
|
build(scope, id, context) {
|
|
67
72
|
const resolvedVpc = this.#vpc ? (0, core_1.resolve)(this.#vpc, context) : undefined;
|
|
@@ -94,15 +99,8 @@ class ClusterBuilder {
|
|
|
94
99
|
...(kmsKey !== undefined ? { kmsKey: (0, core_1.resolve)(kmsKey, context) } : {}),
|
|
95
100
|
};
|
|
96
101
|
const cluster = new aws_neptune_alpha_1.DatabaseCluster(scope, id, mergedProps);
|
|
97
|
-
for (const
|
|
98
|
-
|
|
99
|
-
cluster.connections.allowDefaultPortFrom(peer);
|
|
100
|
-
// The IAM `connect` grant is only meaningful when IAM authentication is
|
|
101
|
-
// enabled (the default). If a user has turned it off, opening the
|
|
102
|
-
// network path is the whole grant — a grantConnect policy would be inert.
|
|
103
|
-
if (mergedProps.iamAuthentication !== false) {
|
|
104
|
-
cluster.grantConnect(peer);
|
|
105
|
-
}
|
|
102
|
+
for (const rule of this.#access) {
|
|
103
|
+
cluster.connections.allowDefaultPortFrom((0, core_1.resolve)(rule.peer, context), rule.description);
|
|
106
104
|
}
|
|
107
105
|
const alarms = (0, cluster_alarms_js_1.createClusterAlarms)(scope, id, cluster, alarmConfig, mergedProps.serverlessScalingConfiguration, this.#customAlarms);
|
|
108
106
|
return { cluster, subnetGroup: cluster.subnetGroup, clusterParameterGroup, alarms };
|
|
@@ -115,7 +113,7 @@ class ClusterBuilder {
|
|
|
115
113
|
* This is the entry point for defining a Neptune component. The returned
|
|
116
114
|
* builder exposes every {@link ClusterBuilderProps} property as a fluent
|
|
117
115
|
* setter/getter, plus {@link IClusterBuilder.vpc | .vpc()} and
|
|
118
|
-
* {@link IClusterBuilder.
|
|
116
|
+
* {@link IClusterBuilder.allowDefaultPortFrom | .allowDefaultPortFrom()} for
|
|
119
117
|
* cross-component wiring with Ref support. It implements {@link Lifecycle}
|
|
120
118
|
* for use with {@link compose}.
|
|
121
119
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cluster-builder.js","sourceRoot":"","sources":["../../src/cluster-builder.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"cluster-builder.js","sourceRoot":"","sources":["../../src/cluster-builder.ts"],"names":[],"mappings":";;AAsVA,oDAEC;AAtVD,kEAOoC;AAEpC,6CAA0F;AAC1F,iEAAkF;AAClF,yDAAkE;AAClE,+DAAyD;AACzD,+FAG+C;AAE/C,2DAA0D;AA2J1D,MAAM,cAAc;IAClB,KAAK,GAAiC,EAAE,CAAC;IAChC,aAAa,GAA+C,EAAE,CAAC;IAC/D,OAAO,GAAiB,EAAE,CAAC;IACpC,IAAI,CAAwD;IAE5D;;;;;;;OAOG;IACH,GAAG,CAAC,GAAyD;QAC3D,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,oBAAoB,CAAC,IAA8B,EAAE,WAAoB;QACvE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;QACzC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;OAQG;IACH,QAAQ,CACN,GAAW,EACX,SAE6C;QAE7C,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,I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AC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,SAAgB,oBAAoB;IAClC,OAAO,IAAA,8BAAa,EAAsC,cAAc,CAAC,CAAC;AAC5E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cluster-defaults.d.ts","sourceRoot":"","sources":["../../src/cluster-defaults.ts"],"names":[],"mappings":"AAEA,OAAO,EAAW,KAAK,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAEhF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,gBAAgB,EAAE,OAAO,CAAC,oBAAoB,
|
|
1
|
+
{"version":3,"file":"cluster-defaults.d.ts","sourceRoot":"","sources":["../../src/cluster-defaults.ts"],"names":[],"mappings":"AAEA,OAAO,EAAW,KAAK,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAEhF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,gBAAgB,EAAE,OAAO,CAAC,oBAAoB,CAwE1D,CAAC"}
|
|
@@ -30,8 +30,9 @@ exports.CLUSTER_DEFAULTS = {
|
|
|
30
30
|
storageEncrypted: true,
|
|
31
31
|
/**
|
|
32
32
|
* Require IAM authentication for data-plane connections, removing the
|
|
33
|
-
* need for long-lived static credentials.
|
|
34
|
-
*
|
|
33
|
+
* need for long-lived static credentials. Authorise a principal with
|
|
34
|
+
* `clusterGrants.connect(...)` on that principal's builder, and open the
|
|
35
|
+
* network path with `.allowDefaultPortFrom()`.
|
|
35
36
|
* @see https://docs.aws.amazon.com/wellarchitected/latest/framework/sec-03.html
|
|
36
37
|
* @see https://docs.aws.amazon.com/neptune/latest/userguide/iam-auth.html
|
|
37
38
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cluster-defaults.js","sourceRoot":"","sources":["../../src/cluster-defaults.ts"],"names":[],"mappings":";;;AAAA,6CAAsD;AACtD,mDAAqD;AACrD,kEAAgF;AAEhF;;;;;;;;;;;;;;;GAeG;AACU,QAAA,gBAAgB,GAAkC;IAC7D;;;;;OAKG;IACH,gBAAgB,EAAE,IAAI;IAEtB
|
|
1
|
+
{"version":3,"file":"cluster-defaults.js","sourceRoot":"","sources":["../../src/cluster-defaults.ts"],"names":[],"mappings":";;;AAAA,6CAAsD;AACtD,mDAAqD;AACrD,kEAAgF;AAEhF;;;;;;;;;;;;;;;GAeG;AACU,QAAA,gBAAgB,GAAkC;IAC7D;;;;;OAKG;IACH,gBAAgB,EAAE,IAAI;IAEtB;;;;;;;OAOG;IACH,iBAAiB,EAAE,IAAI;IAEvB;;;;;OAKG;IACH,aAAa,EAAE,2BAAa,CAAC,MAAM;IAEnC;;;;;OAKG;IACH,kBAAkB,EAAE,IAAI;IAExB;;;;OAIG;IACH,eAAe,EAAE,sBAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IAEjC;;;;;;;OAOG;IACH,qBAAqB,EAAE,CAAC,2BAAO,CAAC,KAAK,CAAC;IAEtC;;;;OAIG;IACH,uBAAuB,EAAE,wBAAa,CAAC,SAAS;IAEhD;;;;OAIG;IACH,kBAAkB,EAAE,IAAI;IAExB;;;;OAIG;IACH,uBAAuB,EAAE,IAAI;CAC9B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { IGrantable } from "aws-cdk-lib/aws-iam";
|
|
2
|
+
import type { IDatabaseCluster } from "@aws-cdk/aws-neptune-alpha";
|
|
3
|
+
import { type Grant, type Resolvable } from "@composurecdk/core";
|
|
4
|
+
/**
|
|
5
|
+
* Consumer-side grant helpers for a Neptune cluster's IAM-authenticated data
|
|
6
|
+
* plane. Pass one to a grantee builder's `grant(...)` — e.g.
|
|
7
|
+
* `role.grant(clusterGrants.connect(ref("graph", (r) => r.cluster)))`.
|
|
8
|
+
*
|
|
9
|
+
* Each delegates to the cluster's native `grant*` method. See ADR-0013.
|
|
10
|
+
*
|
|
11
|
+
* These cover the **IAM** half of reaching a cluster. The network half — the
|
|
12
|
+
* security-group ingress that lets the principal open a socket at all — stays
|
|
13
|
+
* on the cluster, whose own security group the rule is written into:
|
|
14
|
+
* `createClusterBuilder().allowDefaultPortFrom(peer)`. A principal needs both.
|
|
15
|
+
*
|
|
16
|
+
* The cluster's `iamAuthentication` default is `true`; on a cluster that turns
|
|
17
|
+
* it off, the alpha L2 rejects a grant outright rather than emitting an inert
|
|
18
|
+
* policy, so network access is then the whole grant.
|
|
19
|
+
*
|
|
20
|
+
* @see https://docs.aws.amazon.com/neptune/latest/userguide/iam-auth.html
|
|
21
|
+
*/
|
|
22
|
+
export declare const clusterGrants: {
|
|
23
|
+
/**
|
|
24
|
+
* Connect to the cluster's data plane. Delegates to the cluster's
|
|
25
|
+
* `grantConnect`, which grants the whole `neptune-db:*` action namespace on
|
|
26
|
+
* the cluster — read, write, load, and management alike. A principal that
|
|
27
|
+
* needs less than that wants a narrower policy of its own, scoped to the
|
|
28
|
+
* cluster's `neptune-db` ARN.
|
|
29
|
+
*
|
|
30
|
+
* @see https://docs.aws.amazon.com/neptune/latest/userguide/iam-dp-actions.html
|
|
31
|
+
*/
|
|
32
|
+
connect: (cluster: Resolvable<IDatabaseCluster>) => Grant<IGrantable>;
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=grants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grants.d.ts","sourceRoot":"","sources":["../../src/grants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,KAAK,KAAK,EAAY,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAE3E;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,aAAa;IACxB;;;;;;;;OAQG;uBACgB,UAAU,CAAC,gBAAgB,CAAC,KAAG,KAAK,CAAC,UAAU,CAAC;CAIpE,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.clusterGrants = void 0;
|
|
4
|
+
const core_1 = require("@composurecdk/core");
|
|
5
|
+
/**
|
|
6
|
+
* Consumer-side grant helpers for a Neptune cluster's IAM-authenticated data
|
|
7
|
+
* plane. Pass one to a grantee builder's `grant(...)` — e.g.
|
|
8
|
+
* `role.grant(clusterGrants.connect(ref("graph", (r) => r.cluster)))`.
|
|
9
|
+
*
|
|
10
|
+
* Each delegates to the cluster's native `grant*` method. See ADR-0013.
|
|
11
|
+
*
|
|
12
|
+
* These cover the **IAM** half of reaching a cluster. The network half — the
|
|
13
|
+
* security-group ingress that lets the principal open a socket at all — stays
|
|
14
|
+
* on the cluster, whose own security group the rule is written into:
|
|
15
|
+
* `createClusterBuilder().allowDefaultPortFrom(peer)`. A principal needs both.
|
|
16
|
+
*
|
|
17
|
+
* The cluster's `iamAuthentication` default is `true`; on a cluster that turns
|
|
18
|
+
* it off, the alpha L2 rejects a grant outright rather than emitting an inert
|
|
19
|
+
* policy, so network access is then the whole grant.
|
|
20
|
+
*
|
|
21
|
+
* @see https://docs.aws.amazon.com/neptune/latest/userguide/iam-auth.html
|
|
22
|
+
*/
|
|
23
|
+
exports.clusterGrants = {
|
|
24
|
+
/**
|
|
25
|
+
* Connect to the cluster's data plane. Delegates to the cluster's
|
|
26
|
+
* `grantConnect`, which grants the whole `neptune-db:*` action namespace on
|
|
27
|
+
* the cluster — read, write, load, and management alike. A principal that
|
|
28
|
+
* needs less than that wants a narrower policy of its own, scoped to the
|
|
29
|
+
* cluster's `neptune-db` ARN.
|
|
30
|
+
*
|
|
31
|
+
* @see https://docs.aws.amazon.com/neptune/latest/userguide/iam-dp-actions.html
|
|
32
|
+
*/
|
|
33
|
+
connect: (cluster) => (0, core_1.grantVia)(cluster, (c, grantee) => {
|
|
34
|
+
c.grantConnect(grantee);
|
|
35
|
+
}),
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=grants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grants.js","sourceRoot":"","sources":["../../src/grants.ts"],"names":[],"mappings":";;;AAEA,6CAA2E;AAE3E;;;;;;;;;;;;;;;;;GAiBG;AACU,QAAA,aAAa,GAAG;IAC3B;;;;;;;;OAQG;IACH,OAAO,EAAE,CAAC,OAAqC,EAAqB,EAAE,CACpE,IAAA,eAAQ,EAAC,OAAO,EAAE,CAAC,CAAC,EAAE,OAAmB,EAAE,EAAE;QAC3C,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAC1B,CAAC,CAAC;CACL,CAAC"}
|
package/dist/commonjs/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export { createClusterBuilder, type
|
|
1
|
+
export { createClusterBuilder, type ClusterBuilderProps, type ClusterBuilderResult, type IClusterBuilder, } from "./cluster-builder.js";
|
|
2
2
|
export { CLUSTER_DEFAULTS } from "./cluster-defaults.js";
|
|
3
|
+
export { clusterGrants } from "./grants.js";
|
|
3
4
|
export { CLUSTER_PARAMETER_GROUP_DEFAULTS, clusterParameterGroupFamily, } from "./cluster-parameter-group-defaults.js";
|
|
4
5
|
export { type NeptuneClusterAlarmConfig } from "./cluster-alarm-config.js";
|
|
5
6
|
export { CLUSTER_ALARM_DEFAULTS } from "./cluster-alarm-defaults.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,eAAe,GACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EACL,gCAAgC,EAChC,2BAA2B,GAC5B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC"}
|
package/dist/commonjs/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CLUSTER_ALARM_DEFAULTS = exports.clusterParameterGroupFamily = exports.CLUSTER_PARAMETER_GROUP_DEFAULTS = exports.CLUSTER_DEFAULTS = exports.createClusterBuilder = void 0;
|
|
3
|
+
exports.CLUSTER_ALARM_DEFAULTS = exports.clusterParameterGroupFamily = exports.CLUSTER_PARAMETER_GROUP_DEFAULTS = exports.clusterGrants = exports.CLUSTER_DEFAULTS = exports.createClusterBuilder = void 0;
|
|
4
4
|
var cluster_builder_js_1 = require("./cluster-builder.js");
|
|
5
5
|
Object.defineProperty(exports, "createClusterBuilder", { enumerable: true, get: function () { return cluster_builder_js_1.createClusterBuilder; } });
|
|
6
6
|
var cluster_defaults_js_1 = require("./cluster-defaults.js");
|
|
7
7
|
Object.defineProperty(exports, "CLUSTER_DEFAULTS", { enumerable: true, get: function () { return cluster_defaults_js_1.CLUSTER_DEFAULTS; } });
|
|
8
|
+
var grants_js_1 = require("./grants.js");
|
|
9
|
+
Object.defineProperty(exports, "clusterGrants", { enumerable: true, get: function () { return grants_js_1.clusterGrants; } });
|
|
8
10
|
var cluster_parameter_group_defaults_js_1 = require("./cluster-parameter-group-defaults.js");
|
|
9
11
|
Object.defineProperty(exports, "CLUSTER_PARAMETER_GROUP_DEFAULTS", { enumerable: true, get: function () { return cluster_parameter_group_defaults_js_1.CLUSTER_PARAMETER_GROUP_DEFAULTS; } });
|
|
10
12
|
Object.defineProperty(exports, "clusterParameterGroupFamily", { enumerable: true, get: function () { return cluster_parameter_group_defaults_js_1.clusterParameterGroupFamily; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,2DAK8B;AAJ5B,0HAAA,oBAAoB,OAAA;AAKtB,6DAAyD;AAAhD,uHAAA,gBAAgB,OAAA;AACzB,yCAA4C;AAAnC,0GAAA,aAAa,OAAA;AACtB,6FAG+C;AAF7C,uJAAA,gCAAgC,OAAA;AAChC,kJAAA,2BAA2B,OAAA;AAG7B,yEAAqE;AAA5D,mIAAA,sBAAsB,OAAA"}
|
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
import { type Alarm } from "aws-cdk-lib/aws-cloudwatch";
|
|
2
|
-
import { type IConnectable
|
|
3
|
-
import { type IGrantable } from "aws-cdk-lib/aws-iam";
|
|
2
|
+
import { type IConnectable } from "aws-cdk-lib/aws-ec2";
|
|
4
3
|
import { DatabaseCluster, type DatabaseClusterProps, type IClusterParameterGroup, type IDatabaseCluster, type ISubnetGroup } from "@aws-cdk/aws-neptune-alpha";
|
|
5
4
|
import { type IConstruct } from "constructs";
|
|
6
5
|
import { COPY_STATE, type Lifecycle, type Resolvable } from "@composurecdk/core";
|
|
7
6
|
import { type ITaggedBuilder } from "@composurecdk/cloudformation";
|
|
8
7
|
import { AlarmDefinitionBuilder } from "@composurecdk/cloudwatch";
|
|
9
8
|
import type { NeptuneClusterAlarmConfig } from "./cluster-alarm-config.js";
|
|
10
|
-
/**
|
|
11
|
-
* A principal that can be granted access to a Neptune cluster via
|
|
12
|
-
* {@link IClusterBuilder.allowAccessFrom}. Must be both an {@link IConnectable}
|
|
13
|
-
* (so its security group can be opened to the cluster's port) and an
|
|
14
|
-
* {@link IGrantable} (so it can be granted IAM `connect`). EC2 instances,
|
|
15
|
-
* Lambda functions, and Fargate tasks all satisfy this.
|
|
16
|
-
*/
|
|
17
|
-
export type ClusterAccessor = IConnectable & IGrantable;
|
|
18
9
|
/**
|
|
19
10
|
* Configuration properties for the Neptune cluster builder.
|
|
20
11
|
*
|
|
@@ -25,21 +16,25 @@ export type ClusterAccessor = IConnectable & IGrantable;
|
|
|
25
16
|
*
|
|
26
17
|
* - `vpc` is supplied via the dedicated {@link IClusterBuilder.vpc | .vpc()}
|
|
27
18
|
* method (it is required).
|
|
28
|
-
* - `securityGroups` accepts `Resolvable
|
|
19
|
+
* - `securityGroups` accepts `Resolvable` entries.
|
|
29
20
|
* - `kmsKey` accepts a `Resolvable` key.
|
|
30
21
|
*
|
|
31
22
|
* It also adds builder-specific options for the auto-created cluster
|
|
32
23
|
* parameter group and recommended alarms.
|
|
24
|
+
*
|
|
25
|
+
* Each re-declared prop reads its inner type from CDK's own prop rather than
|
|
26
|
+
* naming an interface, so it keeps tracking the installed `aws-cdk-lib` as CDK
|
|
27
|
+
* moves its prop types (ADR-0018).
|
|
33
28
|
*/
|
|
34
29
|
export interface ClusterBuilderProps extends Omit<DatabaseClusterProps, "vpc" | "securityGroups" | "kmsKey"> {
|
|
35
30
|
/**
|
|
36
|
-
* Security groups to attach to the cluster. Accepts concrete
|
|
37
|
-
*
|
|
38
|
-
*
|
|
31
|
+
* Security groups to attach to the cluster. Accepts concrete security
|
|
32
|
+
* groups or {@link Ref}s that resolve to them at build time (e.g. a sibling
|
|
33
|
+
* `SecurityGroupBuilder`).
|
|
39
34
|
*
|
|
40
35
|
* @default - CDK creates a security group for the cluster.
|
|
41
36
|
*/
|
|
42
|
-
securityGroups?: readonly Resolvable<
|
|
37
|
+
securityGroups?: readonly Resolvable<NonNullable<DatabaseClusterProps["securityGroups"]>[number]>[];
|
|
43
38
|
/**
|
|
44
39
|
* The customer-managed KMS key used to encrypt the cluster's storage at
|
|
45
40
|
* rest.
|
|
@@ -149,30 +144,35 @@ declare class ClusterBuilder implements Lifecycle<ClusterBuilderResult> {
|
|
|
149
144
|
#private;
|
|
150
145
|
props: Partial<ClusterBuilderProps>;
|
|
151
146
|
/**
|
|
152
|
-
* Sets the VPC the cluster runs in. Required. Accepts a concrete
|
|
153
|
-
* {@link
|
|
154
|
-
*
|
|
147
|
+
* Sets the VPC the cluster runs in. Required. Accepts a concrete VPC or a
|
|
148
|
+
* {@link Ref} that resolves to one at build time — the standard
|
|
149
|
+
* cross-component wiring path (e.g. to a sibling `VpcBuilder`).
|
|
155
150
|
*
|
|
156
151
|
* @param vpc - The VPC or a Ref to one.
|
|
157
152
|
* @returns This builder for chaining.
|
|
158
153
|
*/
|
|
159
|
-
vpc(vpc: Resolvable<
|
|
154
|
+
vpc(vpc: Resolvable<NonNullable<DatabaseClusterProps["vpc"]>>): this;
|
|
160
155
|
/**
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
156
|
+
* Opens the cluster's port to `peer` via CDK's
|
|
157
|
+
* `cluster.connections.allowDefaultPortFrom(peer)` — ingress on the
|
|
158
|
+
* cluster's security group from the peer's, and the matching egress back on
|
|
159
|
+
* the peer's.
|
|
160
|
+
*
|
|
161
|
+
* This is the **network** half of reaching the cluster. Because IAM
|
|
162
|
+
* authentication is on by default, the peer's principal also needs the
|
|
163
|
+
* data-plane grant, declared on that principal's own builder:
|
|
164
|
+
* `role.grant(clusterGrants.connect(ref("graph", (r) => r.cluster)))` — the
|
|
165
|
+
* consumer-side shape every grant in the library follows (ADR-0013).
|
|
167
166
|
*
|
|
168
|
-
* Accepts a concrete {@link
|
|
169
|
-
*
|
|
170
|
-
* `afterBuild` hook.
|
|
167
|
+
* Accepts a concrete {@link IConnectable} (a `SecurityGroup`, an `Instance`,
|
|
168
|
+
* a `Function` in a VPC, …) or a {@link Ref} to one, so the rule can be
|
|
169
|
+
* declared inside `compose()` rather than wired up in an `afterBuild` hook.
|
|
171
170
|
*
|
|
172
|
-
* @param peer - The
|
|
171
|
+
* @param peer - The connectable to open the port to, or a Ref to one.
|
|
172
|
+
* @param description - Optional description recorded on the ingress rule.
|
|
173
173
|
* @returns This builder for chaining.
|
|
174
174
|
*/
|
|
175
|
-
|
|
175
|
+
allowDefaultPortFrom(peer: Resolvable<IConnectable>, description?: string): this;
|
|
176
176
|
/**
|
|
177
177
|
* Adds a custom CloudWatch alarm to be created alongside the recommended
|
|
178
178
|
* alarms. The callback receives an {@link AlarmDefinitionBuilder} scoped to
|
|
@@ -194,7 +194,7 @@ declare class ClusterBuilder implements Lifecycle<ClusterBuilderResult> {
|
|
|
194
194
|
* This is the entry point for defining a Neptune component. The returned
|
|
195
195
|
* builder exposes every {@link ClusterBuilderProps} property as a fluent
|
|
196
196
|
* setter/getter, plus {@link IClusterBuilder.vpc | .vpc()} and
|
|
197
|
-
* {@link IClusterBuilder.
|
|
197
|
+
* {@link IClusterBuilder.allowDefaultPortFrom | .allowDefaultPortFrom()} for
|
|
198
198
|
* cross-component wiring with Ref support. It implements {@link Lifecycle}
|
|
199
199
|
* for use with {@link compose}.
|
|
200
200
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cluster-builder.d.ts","sourceRoot":"","sources":["../../src/cluster-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,KAAK,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"cluster-builder.d.ts","sourceRoot":"","sources":["../../src/cluster-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAEL,eAAe,EACf,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,YAAY,EAClB,MAAM,4BAA4B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AAe,GAAG,cAAc,CAAC,mBAAmB,EAAE,cAAc,CAAC,CAAC;AAElF,cAAM,cAAe,YAAW,SAAS,CAAC,oBAAoB,CAAC;;IAC7D,KAAK,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAM;IAKzC;;;;;;;OAOG;IACH,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,WAAW,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI;IAKpE;;;;;;;;;;;;;;;;;;;OAmBG;IACH,oBAAoB,CAAC,IAAI,EAAE,UAAU,CAAC,YAAY,CAAC,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI;IAKhF;;;;;;;;OAQG;IACH,QAAQ,CACN,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,CACT,KAAK,EAAE,sBAAsB,CAAC,gBAAgB,CAAC,KAC5C,sBAAsB,CAAC,gBAAgB,CAAC,GAC5C,IAAI;IAKP,gCAAgC;IAChC,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI;IAM1C,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,oBAAoB;CAoE7F;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,oBAAoB,IAAI,eAAe,CAEtD"}
|
|
@@ -8,12 +8,12 @@ import { createClusterAlarms } from "./cluster-alarms.js";
|
|
|
8
8
|
class ClusterBuilder {
|
|
9
9
|
props = {};
|
|
10
10
|
#customAlarms = [];
|
|
11
|
-
#
|
|
11
|
+
#access = [];
|
|
12
12
|
#vpc;
|
|
13
13
|
/**
|
|
14
|
-
* Sets the VPC the cluster runs in. Required. Accepts a concrete
|
|
15
|
-
* {@link
|
|
16
|
-
*
|
|
14
|
+
* Sets the VPC the cluster runs in. Required. Accepts a concrete VPC or a
|
|
15
|
+
* {@link Ref} that resolves to one at build time — the standard
|
|
16
|
+
* cross-component wiring path (e.g. to a sibling `VpcBuilder`).
|
|
17
17
|
*
|
|
18
18
|
* @param vpc - The VPC or a Ref to one.
|
|
19
19
|
* @returns This builder for chaining.
|
|
@@ -23,22 +23,27 @@ class ClusterBuilder {
|
|
|
23
23
|
return this;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* (granting the IAM `connect` action required by the cluster's
|
|
31
|
-
* IAM-authentication default).
|
|
26
|
+
* Opens the cluster's port to `peer` via CDK's
|
|
27
|
+
* `cluster.connections.allowDefaultPortFrom(peer)` — ingress on the
|
|
28
|
+
* cluster's security group from the peer's, and the matching egress back on
|
|
29
|
+
* the peer's.
|
|
32
30
|
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
31
|
+
* This is the **network** half of reaching the cluster. Because IAM
|
|
32
|
+
* authentication is on by default, the peer's principal also needs the
|
|
33
|
+
* data-plane grant, declared on that principal's own builder:
|
|
34
|
+
* `role.grant(clusterGrants.connect(ref("graph", (r) => r.cluster)))` — the
|
|
35
|
+
* consumer-side shape every grant in the library follows (ADR-0013).
|
|
36
36
|
*
|
|
37
|
-
*
|
|
37
|
+
* Accepts a concrete {@link IConnectable} (a `SecurityGroup`, an `Instance`,
|
|
38
|
+
* a `Function` in a VPC, …) or a {@link Ref} to one, so the rule can be
|
|
39
|
+
* declared inside `compose()` rather than wired up in an `afterBuild` hook.
|
|
40
|
+
*
|
|
41
|
+
* @param peer - The connectable to open the port to, or a Ref to one.
|
|
42
|
+
* @param description - Optional description recorded on the ingress rule.
|
|
38
43
|
* @returns This builder for chaining.
|
|
39
44
|
*/
|
|
40
|
-
|
|
41
|
-
this.#
|
|
45
|
+
allowDefaultPortFrom(peer, description) {
|
|
46
|
+
this.#access.push({ peer, description });
|
|
42
47
|
return this;
|
|
43
48
|
}
|
|
44
49
|
/**
|
|
@@ -58,7 +63,7 @@ class ClusterBuilder {
|
|
|
58
63
|
[COPY_STATE](target) {
|
|
59
64
|
target.#vpc = this.#vpc;
|
|
60
65
|
target.#customAlarms.push(...this.#customAlarms);
|
|
61
|
-
target.#
|
|
66
|
+
target.#access.push(...this.#access);
|
|
62
67
|
}
|
|
63
68
|
build(scope, id, context) {
|
|
64
69
|
const resolvedVpc = this.#vpc ? resolve(this.#vpc, context) : undefined;
|
|
@@ -91,15 +96,8 @@ class ClusterBuilder {
|
|
|
91
96
|
...(kmsKey !== undefined ? { kmsKey: resolve(kmsKey, context) } : {}),
|
|
92
97
|
};
|
|
93
98
|
const cluster = new DatabaseCluster(scope, id, mergedProps);
|
|
94
|
-
for (const
|
|
95
|
-
|
|
96
|
-
cluster.connections.allowDefaultPortFrom(peer);
|
|
97
|
-
// The IAM `connect` grant is only meaningful when IAM authentication is
|
|
98
|
-
// enabled (the default). If a user has turned it off, opening the
|
|
99
|
-
// network path is the whole grant — a grantConnect policy would be inert.
|
|
100
|
-
if (mergedProps.iamAuthentication !== false) {
|
|
101
|
-
cluster.grantConnect(peer);
|
|
102
|
-
}
|
|
99
|
+
for (const rule of this.#access) {
|
|
100
|
+
cluster.connections.allowDefaultPortFrom(resolve(rule.peer, context), rule.description);
|
|
103
101
|
}
|
|
104
102
|
const alarms = createClusterAlarms(scope, id, cluster, alarmConfig, mergedProps.serverlessScalingConfiguration, this.#customAlarms);
|
|
105
103
|
return { cluster, subnetGroup: cluster.subnetGroup, clusterParameterGroup, alarms };
|
|
@@ -112,7 +110,7 @@ class ClusterBuilder {
|
|
|
112
110
|
* This is the entry point for defining a Neptune component. The returned
|
|
113
111
|
* builder exposes every {@link ClusterBuilderProps} property as a fluent
|
|
114
112
|
* setter/getter, plus {@link IClusterBuilder.vpc | .vpc()} and
|
|
115
|
-
* {@link IClusterBuilder.
|
|
113
|
+
* {@link IClusterBuilder.allowDefaultPortFrom | .allowDefaultPortFrom()} for
|
|
116
114
|
* cross-component wiring with Ref support. It implements {@link Lifecycle}
|
|
117
115
|
* for use with {@link compose}.
|
|
118
116
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cluster-builder.js","sourceRoot":"","sources":["../../src/cluster-builder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cluster-builder.js","sourceRoot":"","sources":["../../src/cluster-builder.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,qBAAqB,EACrB,eAAe,GAKhB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,UAAU,EAAkB,OAAO,EAAmB,MAAM,oBAAoB,CAAC;AAC1F,OAAO,EAAuB,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EACL,gCAAgC,EAChC,2BAA2B,GAC5B,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AA2J1D,MAAM,cAAc;IAClB,KAAK,GAAiC,EAAE,CAAC;IAChC,aAAa,GAA+C,EAAE,CAAC;IAC/D,OAAO,GAAiB,EAAE,CAAC;IACpC,IAAI,CAAwD;IAE5D;;;;;;;OAOG;IACH,GAAG,CAAC,GAAyD;QAC3D,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,oBAAoB,CAAC,IAA8B,EAAE,WAAoB;QACvE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;QACzC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;OAQG;IACH,QAAQ,CACN,GAAW,EACX,SAE6C;QAE7C,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,sBAAs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;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO,aAAa,CAAsC,cAAc,CAAC,CAAC;AAC5E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cluster-defaults.d.ts","sourceRoot":"","sources":["../../src/cluster-defaults.ts"],"names":[],"mappings":"AAEA,OAAO,EAAW,KAAK,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAEhF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,gBAAgB,EAAE,OAAO,CAAC,oBAAoB,
|
|
1
|
+
{"version":3,"file":"cluster-defaults.d.ts","sourceRoot":"","sources":["../../src/cluster-defaults.ts"],"names":[],"mappings":"AAEA,OAAO,EAAW,KAAK,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAEhF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,gBAAgB,EAAE,OAAO,CAAC,oBAAoB,CAwE1D,CAAC"}
|
|
@@ -27,8 +27,9 @@ export const CLUSTER_DEFAULTS = {
|
|
|
27
27
|
storageEncrypted: true,
|
|
28
28
|
/**
|
|
29
29
|
* Require IAM authentication for data-plane connections, removing the
|
|
30
|
-
* need for long-lived static credentials.
|
|
31
|
-
*
|
|
30
|
+
* need for long-lived static credentials. Authorise a principal with
|
|
31
|
+
* `clusterGrants.connect(...)` on that principal's builder, and open the
|
|
32
|
+
* network path with `.allowDefaultPortFrom()`.
|
|
32
33
|
* @see https://docs.aws.amazon.com/wellarchitected/latest/framework/sec-03.html
|
|
33
34
|
* @see https://docs.aws.amazon.com/neptune/latest/userguide/iam-auth.html
|
|
34
35
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cluster-defaults.js","sourceRoot":"","sources":["../../src/cluster-defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,OAAO,EAA6B,MAAM,4BAA4B,CAAC;AAEhF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAkC;IAC7D;;;;;OAKG;IACH,gBAAgB,EAAE,IAAI;IAEtB
|
|
1
|
+
{"version":3,"file":"cluster-defaults.js","sourceRoot":"","sources":["../../src/cluster-defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,OAAO,EAA6B,MAAM,4BAA4B,CAAC;AAEhF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAkC;IAC7D;;;;;OAKG;IACH,gBAAgB,EAAE,IAAI;IAEtB;;;;;;;OAOG;IACH,iBAAiB,EAAE,IAAI;IAEvB;;;;;OAKG;IACH,aAAa,EAAE,aAAa,CAAC,MAAM;IAEnC;;;;;OAKG;IACH,kBAAkB,EAAE,IAAI;IAExB;;;;OAIG;IACH,eAAe,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IAEjC;;;;;;;OAOG;IACH,qBAAqB,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IAEtC;;;;OAIG;IACH,uBAAuB,EAAE,aAAa,CAAC,SAAS;IAEhD;;;;OAIG;IACH,kBAAkB,EAAE,IAAI;IAExB;;;;OAIG;IACH,uBAAuB,EAAE,IAAI;CAC9B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { IGrantable } from "aws-cdk-lib/aws-iam";
|
|
2
|
+
import type { IDatabaseCluster } from "@aws-cdk/aws-neptune-alpha";
|
|
3
|
+
import { type Grant, type Resolvable } from "@composurecdk/core";
|
|
4
|
+
/**
|
|
5
|
+
* Consumer-side grant helpers for a Neptune cluster's IAM-authenticated data
|
|
6
|
+
* plane. Pass one to a grantee builder's `grant(...)` — e.g.
|
|
7
|
+
* `role.grant(clusterGrants.connect(ref("graph", (r) => r.cluster)))`.
|
|
8
|
+
*
|
|
9
|
+
* Each delegates to the cluster's native `grant*` method. See ADR-0013.
|
|
10
|
+
*
|
|
11
|
+
* These cover the **IAM** half of reaching a cluster. The network half — the
|
|
12
|
+
* security-group ingress that lets the principal open a socket at all — stays
|
|
13
|
+
* on the cluster, whose own security group the rule is written into:
|
|
14
|
+
* `createClusterBuilder().allowDefaultPortFrom(peer)`. A principal needs both.
|
|
15
|
+
*
|
|
16
|
+
* The cluster's `iamAuthentication` default is `true`; on a cluster that turns
|
|
17
|
+
* it off, the alpha L2 rejects a grant outright rather than emitting an inert
|
|
18
|
+
* policy, so network access is then the whole grant.
|
|
19
|
+
*
|
|
20
|
+
* @see https://docs.aws.amazon.com/neptune/latest/userguide/iam-auth.html
|
|
21
|
+
*/
|
|
22
|
+
export declare const clusterGrants: {
|
|
23
|
+
/**
|
|
24
|
+
* Connect to the cluster's data plane. Delegates to the cluster's
|
|
25
|
+
* `grantConnect`, which grants the whole `neptune-db:*` action namespace on
|
|
26
|
+
* the cluster — read, write, load, and management alike. A principal that
|
|
27
|
+
* needs less than that wants a narrower policy of its own, scoped to the
|
|
28
|
+
* cluster's `neptune-db` ARN.
|
|
29
|
+
*
|
|
30
|
+
* @see https://docs.aws.amazon.com/neptune/latest/userguide/iam-dp-actions.html
|
|
31
|
+
*/
|
|
32
|
+
connect: (cluster: Resolvable<IDatabaseCluster>) => Grant<IGrantable>;
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=grants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grants.d.ts","sourceRoot":"","sources":["../../src/grants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,KAAK,KAAK,EAAY,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAE3E;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,aAAa;IACxB;;;;;;;;OAQG;uBACgB,UAAU,CAAC,gBAAgB,CAAC,KAAG,KAAK,CAAC,UAAU,CAAC;CAIpE,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { grantVia } from "@composurecdk/core";
|
|
2
|
+
/**
|
|
3
|
+
* Consumer-side grant helpers for a Neptune cluster's IAM-authenticated data
|
|
4
|
+
* plane. Pass one to a grantee builder's `grant(...)` — e.g.
|
|
5
|
+
* `role.grant(clusterGrants.connect(ref("graph", (r) => r.cluster)))`.
|
|
6
|
+
*
|
|
7
|
+
* Each delegates to the cluster's native `grant*` method. See ADR-0013.
|
|
8
|
+
*
|
|
9
|
+
* These cover the **IAM** half of reaching a cluster. The network half — the
|
|
10
|
+
* security-group ingress that lets the principal open a socket at all — stays
|
|
11
|
+
* on the cluster, whose own security group the rule is written into:
|
|
12
|
+
* `createClusterBuilder().allowDefaultPortFrom(peer)`. A principal needs both.
|
|
13
|
+
*
|
|
14
|
+
* The cluster's `iamAuthentication` default is `true`; on a cluster that turns
|
|
15
|
+
* it off, the alpha L2 rejects a grant outright rather than emitting an inert
|
|
16
|
+
* policy, so network access is then the whole grant.
|
|
17
|
+
*
|
|
18
|
+
* @see https://docs.aws.amazon.com/neptune/latest/userguide/iam-auth.html
|
|
19
|
+
*/
|
|
20
|
+
export const clusterGrants = {
|
|
21
|
+
/**
|
|
22
|
+
* Connect to the cluster's data plane. Delegates to the cluster's
|
|
23
|
+
* `grantConnect`, which grants the whole `neptune-db:*` action namespace on
|
|
24
|
+
* the cluster — read, write, load, and management alike. A principal that
|
|
25
|
+
* needs less than that wants a narrower policy of its own, scoped to the
|
|
26
|
+
* cluster's `neptune-db` ARN.
|
|
27
|
+
*
|
|
28
|
+
* @see https://docs.aws.amazon.com/neptune/latest/userguide/iam-dp-actions.html
|
|
29
|
+
*/
|
|
30
|
+
connect: (cluster) => grantVia(cluster, (c, grantee) => {
|
|
31
|
+
c.grantConnect(grantee);
|
|
32
|
+
}),
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=grants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grants.js","sourceRoot":"","sources":["../../src/grants.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,QAAQ,EAAmB,MAAM,oBAAoB,CAAC;AAE3E;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B;;;;;;;;OAQG;IACH,OAAO,EAAE,CAAC,OAAqC,EAAqB,EAAE,CACpE,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,OAAmB,EAAE,EAAE;QAC3C,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAC1B,CAAC,CAAC;CACL,CAAC"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export { createClusterBuilder, type
|
|
1
|
+
export { createClusterBuilder, type ClusterBuilderProps, type ClusterBuilderResult, type IClusterBuilder, } from "./cluster-builder.js";
|
|
2
2
|
export { CLUSTER_DEFAULTS } from "./cluster-defaults.js";
|
|
3
|
+
export { clusterGrants } from "./grants.js";
|
|
3
4
|
export { CLUSTER_PARAMETER_GROUP_DEFAULTS, clusterParameterGroupFamily, } from "./cluster-parameter-group-defaults.js";
|
|
4
5
|
export { type NeptuneClusterAlarmConfig } from "./cluster-alarm-config.js";
|
|
5
6
|
export { CLUSTER_ALARM_DEFAULTS } from "./cluster-alarm-defaults.js";
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,eAAe,GACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EACL,gCAAgC,EAChC,2BAA2B,GAC5B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { createClusterBuilder, } from "./cluster-builder.js";
|
|
2
2
|
export { CLUSTER_DEFAULTS } from "./cluster-defaults.js";
|
|
3
|
+
export { clusterGrants } from "./grants.js";
|
|
3
4
|
export { CLUSTER_PARAMETER_GROUP_DEFAULTS, clusterParameterGroupFamily, } from "./cluster-parameter-group-defaults.js";
|
|
4
5
|
export { CLUSTER_ALARM_DEFAULTS } from "./cluster-alarm-defaults.js";
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,GAIrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EACL,gCAAgC,EAChC,2BAA2B,GAC5B,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@composurecdk/neptune",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Composable Amazon Neptune cluster builder with well-architected defaults",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "https://github.com/laazyj/composureCDK",
|
|
7
|
+
"url": "git+https://github.com/laazyj/composureCDK.git",
|
|
8
8
|
"directory": "packages/neptune"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
@@ -50,19 +50,20 @@
|
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"@aws-cdk/aws-neptune-alpha": "^2.190.0-alpha.0",
|
|
53
|
-
"@composurecdk/cloudformation": "^0.
|
|
54
|
-
"@composurecdk/cloudwatch": "^0.
|
|
55
|
-
"@composurecdk/core": "^0.
|
|
53
|
+
"@composurecdk/cloudformation": "^0.10.0",
|
|
54
|
+
"@composurecdk/cloudwatch": "^0.10.0",
|
|
55
|
+
"@composurecdk/core": "^0.10.0",
|
|
56
56
|
"aws-cdk-lib": "^2.190.0",
|
|
57
57
|
"constructs": "^10.0.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@aws-cdk/aws-neptune-alpha": "2.257.0-alpha.0",
|
|
61
|
-
"@
|
|
62
|
-
"
|
|
63
|
-
"
|
|
61
|
+
"@composurecdk/cdk-testing": "*",
|
|
62
|
+
"@types/node": "^26.5.1",
|
|
63
|
+
"aws-cdk-lib": "^2.268.0",
|
|
64
|
+
"constructs": "^10.8.1",
|
|
64
65
|
"typescript": "^6.0.3",
|
|
65
|
-
"vitest": "^
|
|
66
|
+
"vitest": "^5.0.0"
|
|
66
67
|
},
|
|
67
68
|
"exports": {
|
|
68
69
|
"./package.json": "./package.json",
|