@composurecdk/ec2 0.8.3 → 0.8.5
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/README.md +200 -0
- package/dist/commonjs/index.d.ts +20 -0
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +23 -1
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/interface-endpoint-alarm-config.d.ts +34 -0
- package/dist/commonjs/interface-endpoint-alarm-config.d.ts.map +1 -0
- package/dist/commonjs/interface-endpoint-alarm-config.js +3 -0
- package/dist/commonjs/interface-endpoint-alarm-config.js.map +1 -0
- package/dist/commonjs/interface-endpoint-alarm-defaults.d.ts +13 -0
- package/dist/commonjs/interface-endpoint-alarm-defaults.d.ts.map +1 -0
- package/dist/commonjs/interface-endpoint-alarm-defaults.js +28 -0
- package/dist/commonjs/interface-endpoint-alarm-defaults.js.map +1 -0
- package/dist/commonjs/interface-endpoint-alarms.d.ts +13 -0
- package/dist/commonjs/interface-endpoint-alarms.d.ts.map +1 -0
- package/dist/commonjs/interface-endpoint-alarms.js +58 -0
- package/dist/commonjs/interface-endpoint-alarms.js.map +1 -0
- package/dist/commonjs/interface-endpoint-builder.d.ts +135 -0
- package/dist/commonjs/interface-endpoint-builder.d.ts.map +1 -0
- package/dist/commonjs/interface-endpoint-builder.js +126 -0
- package/dist/commonjs/interface-endpoint-builder.js.map +1 -0
- package/dist/commonjs/interface-endpoint-defaults.d.ts +14 -0
- package/dist/commonjs/interface-endpoint-defaults.d.ts.map +1 -0
- package/dist/commonjs/interface-endpoint-defaults.js +27 -0
- package/dist/commonjs/interface-endpoint-defaults.js.map +1 -0
- package/dist/commonjs/security-group-builder.d.ts.map +1 -1
- package/dist/commonjs/security-group-builder.js +7 -0
- package/dist/commonjs/security-group-builder.js.map +1 -1
- package/dist/commonjs/security-group-constraints.d.ts +17 -0
- package/dist/commonjs/security-group-constraints.d.ts.map +1 -0
- package/dist/commonjs/security-group-constraints.js +70 -0
- package/dist/commonjs/security-group-constraints.js.map +1 -0
- package/dist/commonjs/vpc-builder.d.ts.map +1 -1
- package/dist/commonjs/vpc-builder.js +11 -0
- package/dist/commonjs/vpc-builder.js.map +1 -1
- package/dist/esm/index.d.ts +20 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +19 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interface-endpoint-alarm-config.d.ts +34 -0
- package/dist/esm/interface-endpoint-alarm-config.d.ts.map +1 -0
- package/dist/esm/interface-endpoint-alarm-config.js +2 -0
- package/dist/esm/interface-endpoint-alarm-config.js.map +1 -0
- package/dist/esm/interface-endpoint-alarm-defaults.d.ts +13 -0
- package/dist/esm/interface-endpoint-alarm-defaults.d.ts.map +1 -0
- package/dist/esm/interface-endpoint-alarm-defaults.js +25 -0
- package/dist/esm/interface-endpoint-alarm-defaults.js.map +1 -0
- package/dist/esm/interface-endpoint-alarms.d.ts +13 -0
- package/dist/esm/interface-endpoint-alarms.d.ts.map +1 -0
- package/dist/esm/interface-endpoint-alarms.js +55 -0
- package/dist/esm/interface-endpoint-alarms.js.map +1 -0
- package/dist/esm/interface-endpoint-builder.d.ts +135 -0
- package/dist/esm/interface-endpoint-builder.d.ts.map +1 -0
- package/dist/esm/interface-endpoint-builder.js +123 -0
- package/dist/esm/interface-endpoint-builder.js.map +1 -0
- package/dist/esm/interface-endpoint-defaults.d.ts +14 -0
- package/dist/esm/interface-endpoint-defaults.d.ts.map +1 -0
- package/dist/esm/interface-endpoint-defaults.js +24 -0
- package/dist/esm/interface-endpoint-defaults.js.map +1 -0
- package/dist/esm/security-group-builder.d.ts.map +1 -1
- package/dist/esm/security-group-builder.js +7 -0
- package/dist/esm/security-group-builder.js.map +1 -1
- package/dist/esm/security-group-constraints.d.ts +17 -0
- package/dist/esm/security-group-constraints.d.ts.map +1 -0
- package/dist/esm/security-group-constraints.js +66 -0
- package/dist/esm/security-group-constraints.js.map +1 -0
- package/dist/esm/vpc-builder.d.ts.map +1 -1
- package/dist/esm/vpc-builder.js +11 -0
- package/dist/esm/vpc-builder.js.map +1 -1
- package/package.json +16 -5
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createInterfaceEndpointBuilder = createInterfaceEndpointBuilder;
|
|
4
|
+
const aws_ec2_1 = require("aws-cdk-lib/aws-ec2");
|
|
5
|
+
const core_1 = require("@composurecdk/core");
|
|
6
|
+
const cloudformation_1 = require("@composurecdk/cloudformation");
|
|
7
|
+
const cloudwatch_1 = require("@composurecdk/cloudwatch");
|
|
8
|
+
const security_group_builder_js_1 = require("./security-group-builder.js");
|
|
9
|
+
const interface_endpoint_defaults_js_1 = require("./interface-endpoint-defaults.js");
|
|
10
|
+
const interface_endpoint_alarms_js_1 = require("./interface-endpoint-alarms.js");
|
|
11
|
+
class InterfaceEndpointBuilder {
|
|
12
|
+
props = {};
|
|
13
|
+
#access = [];
|
|
14
|
+
#customAlarms = [];
|
|
15
|
+
#vpc;
|
|
16
|
+
#securityGroups;
|
|
17
|
+
/**
|
|
18
|
+
* Sets the VPC the endpoint is created in. Accepts a concrete {@link IVpc}
|
|
19
|
+
* or a {@link Ref} to a sibling {@link IVpcBuilder}.
|
|
20
|
+
*/
|
|
21
|
+
vpc(vpc) {
|
|
22
|
+
this.#vpc = vpc;
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Bring-your-own security groups. Each entry is a {@link Resolvable}, so it
|
|
27
|
+
* can be a concrete {@link ISecurityGroup} or a {@link Ref} to a sibling
|
|
28
|
+
* `SecurityGroupBuilder` — giving you full ingress/egress/port control. When
|
|
29
|
+
* set, the builder creates no security group of its own and
|
|
30
|
+
* {@link InterfaceEndpointBuilderResult.securityGroup} is `undefined`.
|
|
31
|
+
*
|
|
32
|
+
* Mutually exclusive with {@link allowDefaultPortFrom}.
|
|
33
|
+
*/
|
|
34
|
+
securityGroups(securityGroups) {
|
|
35
|
+
this.#securityGroups = securityGroups;
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Managed-SG shortcut: wires `peer` to the auto-created security group via
|
|
40
|
+
* CDK's `endpoint.connections.allowDefaultPortFrom(peer)` — opening ingress
|
|
41
|
+
* on the managed SG from `peer`'s SG **and** egress from `peer`'s SG to the
|
|
42
|
+
* managed SG, on the service's default port (443 for AWS services).
|
|
43
|
+
*
|
|
44
|
+
* Because this delegates to CDK connections, `peer` must be an
|
|
45
|
+
* {@link IConnectable} (e.g. a `SecurityGroup` or `Instance`), not a raw
|
|
46
|
+
* `IPeer` (e.g. `Peer.ipv4(...)`). For CIDR-based rules use BYO mode with
|
|
47
|
+
* an explicit `addIngressRule` on your own {@link SecurityGroupBuilder}.
|
|
48
|
+
*
|
|
49
|
+
* Mutually exclusive with {@link securityGroups}.
|
|
50
|
+
*/
|
|
51
|
+
allowDefaultPortFrom(peer, description) {
|
|
52
|
+
this.#access.push({ peer, description });
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Adds a custom CloudWatch alarm alongside the recommended ones. The
|
|
57
|
+
* callback receives an {@link AlarmDefinitionBuilder} typed to the
|
|
58
|
+
* `InterfaceVpcEndpoint` construct, giving access to the endpoint at
|
|
59
|
+
* build time for metric dimension wiring.
|
|
60
|
+
*/
|
|
61
|
+
addAlarm(key, configure) {
|
|
62
|
+
this.#customAlarms.push(configure(new cloudwatch_1.AlarmDefinitionBuilder(key)));
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
/** @internal — see ADR-0005. */
|
|
66
|
+
[core_1.COPY_STATE](target) {
|
|
67
|
+
target.#vpc = this.#vpc;
|
|
68
|
+
target.#securityGroups = this.#securityGroups ? [...this.#securityGroups] : undefined;
|
|
69
|
+
target.#access.push(...this.#access);
|
|
70
|
+
target.#customAlarms.push(...this.#customAlarms);
|
|
71
|
+
}
|
|
72
|
+
build(scope, id, context) {
|
|
73
|
+
const resolvedVpc = this.#vpc ? (0, core_1.resolve)(this.#vpc, context) : undefined;
|
|
74
|
+
if (!resolvedVpc) {
|
|
75
|
+
throw new Error(`InterfaceEndpointBuilder "${id}" requires a VPC. Call .vpc() with an IVpc or a Ref to one.`);
|
|
76
|
+
}
|
|
77
|
+
const { recommendedAlarms: alarmConfig, service, ...endpointProps } = this.props;
|
|
78
|
+
if (service === undefined) {
|
|
79
|
+
throw new Error(`InterfaceEndpointBuilder "${id}" requires a service. ` +
|
|
80
|
+
"Call .service() with an InterfaceVpcEndpointAwsService or a custom IInterfaceVpcEndpointService.");
|
|
81
|
+
}
|
|
82
|
+
const byo = this.#securityGroups;
|
|
83
|
+
if (byo !== undefined && this.#access.length > 0) {
|
|
84
|
+
throw new Error(`InterfaceEndpointBuilder "${id}": .allowDefaultPortFrom() applies only to the ` +
|
|
85
|
+
"auto-created security group and cannot be combined with .securityGroups() — " +
|
|
86
|
+
"add the ingress rule to your own SecurityGroupBuilder instead.");
|
|
87
|
+
}
|
|
88
|
+
let managedSecurityGroup;
|
|
89
|
+
let securityGroups;
|
|
90
|
+
if (byo !== undefined) {
|
|
91
|
+
securityGroups = byo.map((sg) => (0, core_1.resolve)(sg, context));
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
managedSecurityGroup = (0, security_group_builder_js_1.createSecurityGroupBuilder)()
|
|
95
|
+
.vpc(resolvedVpc)
|
|
96
|
+
.description(`Interface endpoint ${id}`)
|
|
97
|
+
.build(scope, `${id}Sg`).securityGroup;
|
|
98
|
+
securityGroups = [managedSecurityGroup];
|
|
99
|
+
}
|
|
100
|
+
const endpoint = new aws_ec2_1.InterfaceVpcEndpoint(scope, id, {
|
|
101
|
+
...interface_endpoint_defaults_js_1.INTERFACE_ENDPOINT_DEFAULTS,
|
|
102
|
+
...endpointProps,
|
|
103
|
+
service,
|
|
104
|
+
vpc: resolvedVpc,
|
|
105
|
+
securityGroups,
|
|
106
|
+
// Always explicit: `open: true` would silently add a VPC-wide :443 rule.
|
|
107
|
+
open: false,
|
|
108
|
+
});
|
|
109
|
+
for (const rule of this.#access) {
|
|
110
|
+
endpoint.connections.allowDefaultPortFrom((0, core_1.resolve)(rule.peer, context), rule.description);
|
|
111
|
+
}
|
|
112
|
+
const alarms = (0, interface_endpoint_alarms_js_1.createInterfaceEndpointAlarms)(scope, id, endpoint, alarmConfig, this.#customAlarms);
|
|
113
|
+
return { endpoint, securityGroup: managedSecurityGroup, alarms };
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Creates a new {@link IInterfaceEndpointBuilder} for a single VPC interface
|
|
118
|
+
* endpoint. The returned builder exposes every
|
|
119
|
+
* {@link InterfaceEndpointBuilderProps} property as a fluent setter/getter,
|
|
120
|
+
* plus `.vpc()`, `.securityGroups()` (BYO), and `.allowDefaultPortFrom()`
|
|
121
|
+
* (managed-SG shortcut).
|
|
122
|
+
*/
|
|
123
|
+
function createInterfaceEndpointBuilder() {
|
|
124
|
+
return (0, cloudformation_1.taggedBuilder)(InterfaceEndpointBuilder);
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=interface-endpoint-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface-endpoint-builder.js","sourceRoot":"","sources":["../../src/interface-endpoint-builder.ts"],"names":[],"mappings":";;AA6PA,wEAIC;AAhQD,iDAO6B;AAE7B,6CAA0F;AAC1F,iEAAkF;AAClF,yDAAkE;AAClE,2EAAyE;AACzE,qFAA+E;AAE/E,iFAA+E;AA2F/E,MAAM,wBAAwB;IAC5B,KAAK,GAA2C,EAAE,CAAC;IAC1C,OAAO,GAAiB,EAAE,CAAC;IAC3B,aAAa,GAAmD,EAAE,CAAC;IAC5E,IAAI,CAAoB;IACxB,eAAe,CAAgC;IAE/C;;;OAGG;IACH,GAAG,CAAC,GAAqB;QACvB,IAAI,CAAC,IAAI,GAAG,GAAG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AAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAChC,QAAQ,CAAC,WAAW,CAAC,oBAAoB,CAAC,IAAA,cAAO,EAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAC3F,CAAC;QAED,MAAM,MAAM,GAAG,IAAA,4DAA6B,EAC1C,KAAK,EACL,EAAE,EACF,QAAQ,EACR,WAAW,EACX,IAAI,CAAC,aAAa,CACnB,CAAC;QAEF,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,EAAE,CAAC;IACnE,CAAC;CACF;AAED;;;;;;GAMG;AACH,SAAgB,8BAA8B;IAC5C,OAAO,IAAA,8BAAa,EAClB,wBAAwB,CACzB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { InterfaceVpcEndpointProps } from "aws-cdk-lib/aws-ec2";
|
|
2
|
+
/**
|
|
3
|
+
* Secure, AWS-recommended defaults applied to every interface endpoint built
|
|
4
|
+
* with {@link createInterfaceEndpointBuilder}. Each property can be
|
|
5
|
+
* individually overridden via the builder's fluent API.
|
|
6
|
+
*
|
|
7
|
+
* Note `open` is intentionally *not* here: the builder always sets it to
|
|
8
|
+
* `false` (see the builder's `build()`). Allowing it through would silently
|
|
9
|
+
* add a VPC-wide rule to the managed security group behind the caller's back;
|
|
10
|
+
* ingress is always explicit — via `.allowDefaultPortFrom()` (managed SG) or
|
|
11
|
+
* the BYO `SecurityGroupBuilder`.
|
|
12
|
+
*/
|
|
13
|
+
export declare const INTERFACE_ENDPOINT_DEFAULTS: Partial<InterfaceVpcEndpointProps>;
|
|
14
|
+
//# sourceMappingURL=interface-endpoint-defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface-endpoint-defaults.d.ts","sourceRoot":"","sources":["../../src/interface-endpoint-defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAErE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,2BAA2B,EAAE,OAAO,CAAC,yBAAyB,CAW1E,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.INTERFACE_ENDPOINT_DEFAULTS = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Secure, AWS-recommended defaults applied to every interface endpoint built
|
|
6
|
+
* with {@link createInterfaceEndpointBuilder}. Each property can be
|
|
7
|
+
* individually overridden via the builder's fluent API.
|
|
8
|
+
*
|
|
9
|
+
* Note `open` is intentionally *not* here: the builder always sets it to
|
|
10
|
+
* `false` (see the builder's `build()`). Allowing it through would silently
|
|
11
|
+
* add a VPC-wide rule to the managed security group behind the caller's back;
|
|
12
|
+
* ingress is always explicit — via `.allowDefaultPortFrom()` (managed SG) or
|
|
13
|
+
* the BYO `SecurityGroupBuilder`.
|
|
14
|
+
*/
|
|
15
|
+
exports.INTERFACE_ENDPOINT_DEFAULTS = {
|
|
16
|
+
/**
|
|
17
|
+
* Private DNS enables `<service>.<region>.amazonaws.com` to resolve to the
|
|
18
|
+
* endpoint ENIs instead of the public service IP addresses, keeping traffic
|
|
19
|
+
* on the AWS network without requiring application-level changes. Disabled
|
|
20
|
+
* by default in raw CDK; always on here because every AWS-service use case
|
|
21
|
+
* requires it for transparent private access.
|
|
22
|
+
*
|
|
23
|
+
* @see https://docs.aws.amazon.com/wellarchitected/latest/security-pillar/sec_network_protection_private_connectivity.html
|
|
24
|
+
*/
|
|
25
|
+
privateDnsEnabled: true,
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=interface-endpoint-defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface-endpoint-defaults.js","sourceRoot":"","sources":["../../src/interface-endpoint-defaults.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;GAUG;AACU,QAAA,2BAA2B,GAAuC;IAC7E;;;;;;;;OAQG;IACH,iBAAiB,EAAE,IAAI;CACxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security-group-builder.d.ts","sourceRoot":"","sources":["../../src/security-group-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,KAAK,EACV,KAAK,IAAI,EACT,KAAK,IAAI,EACT,aAAa,EACb,KAAK,kBAAkB,EACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,KAAK,SAAS,EAAW,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC1F,OAAO,EAAE,KAAK,cAAc,EAAiB,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"security-group-builder.d.ts","sourceRoot":"","sources":["../../src/security-group-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,KAAK,EACV,KAAK,IAAI,EACT,KAAK,IAAI,EACT,aAAa,EACb,KAAK,kBAAkB,EACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,KAAK,SAAS,EAAW,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC1F,OAAO,EAAE,KAAK,cAAc,EAAiB,MAAM,8BAA8B,CAAC;AAOlF;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;AAExE;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,0BAA0B;IACzC,aAAa,EAAE,aAAa,CAAC;CAC9B;AAcD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,MAAM,MAAM,qBAAqB,GAAG,cAAc,CAAC,yBAAyB,EAAE,oBAAoB,CAAC,CAAC;AAEpG,cAAM,oBAAqB,YAAW,SAAS,CAAC,0BAA0B,CAAC;;IACzE,KAAK,EAAE,OAAO,CAAC,yBAAyB,CAAC,CAAM;IAK/C;;;;;;;;;OASG;IACH,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI;IAKhC;;;;;;;;;OASG;IACH,cAAc,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI;IAU/E;;;;;;;;;OASG;IACH,aAAa,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI;IAU9E;;;;;;;;;;OAUG;IACH,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI;IAQtD,gCAAgC;IAChC,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE,oBAAoB,GAAG,IAAI;IAMhD,KAAK,CACH,KAAK,EAAE,UAAU,EACjB,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,0BAA0B;CAwD9B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,0BAA0B,IAAI,qBAAqB,CAElE"}
|
|
@@ -5,6 +5,7 @@ const aws_ec2_1 = require("aws-cdk-lib/aws-ec2");
|
|
|
5
5
|
const core_1 = require("@composurecdk/core");
|
|
6
6
|
const cloudformation_1 = require("@composurecdk/cloudformation");
|
|
7
7
|
const security_group_defaults_js_1 = require("./security-group-defaults.js");
|
|
8
|
+
const security_group_constraints_js_1 = require("./security-group-constraints.js");
|
|
8
9
|
class SecurityGroupBuilder {
|
|
9
10
|
props = {};
|
|
10
11
|
#peerRules = [];
|
|
@@ -96,6 +97,12 @@ class SecurityGroupBuilder {
|
|
|
96
97
|
throw new Error(`SecurityGroupBuilder "${id}" requires a description. ` +
|
|
97
98
|
"Call .description() with a short summary of the SG's purpose.");
|
|
98
99
|
}
|
|
100
|
+
// Fail at synth, at the authoring call site, instead of CREATE_FAILED at
|
|
101
|
+
// deploy time. The validators skip unresolved tokens (ADR-0010).
|
|
102
|
+
(0, security_group_constraints_js_1.validateSecurityGroupDescription)(this.props.description);
|
|
103
|
+
if (this.props.securityGroupName !== undefined) {
|
|
104
|
+
(0, security_group_constraints_js_1.validateSecurityGroupName)(this.props.securityGroupName);
|
|
105
|
+
}
|
|
99
106
|
// Drop keys whose value is `undefined` so a fluent call like
|
|
100
107
|
// `.allowAllOutbound(undefined)` (common in "optional override" code:
|
|
101
108
|
// `b.allowAllOutbound(cfg?.allowAllOutbound)`) does not clobber the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security-group-builder.js","sourceRoot":"","sources":["../../src/security-group-builder.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"security-group-builder.js","sourceRoot":"","sources":["../../src/security-group-builder.ts"],"names":[],"mappings":";;AA6QA,gEAEC;AA/QD,iDAM6B;AAE7B,6CAA0F;AAC1F,iEAAkF;AAClF,6EAAuE;AACvE,mFAGyC;AA8FzC,MAAM,oBAAoB;IACxB,KAAK,GAAuC,EAAE,CAAC;IACtC,UAAU,GAAmB,EAAE,CAAC;IAChC,YAAY,GAAsB,EAAE,CAAC;IAC9C,IAAI,CAAoB;IAExB;;;;;;;;;OASG;IACH,GAAG,CAAC,GAAqB;QACvB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;OASG;IACH,cAAc,CAAC,IAAuB,EAAE,IAAU,EAAE,WAAoB;QACtE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;YACnB,SAAS,EAAE,SAAS;YACpB,IAAI;YACJ,IAAI;YACJ,GAAG,CAAC,WAAW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AAO,CAAC,CAAC;YACzC,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;gBACjC,aAAa,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;YAClE,CAAC;iBAAM,CAAC;gBACN,aAAa,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;YACjE,CAAC;QACH,CAAC;QACD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACrC,aAAa,CAAC,cAAc,CAAC,aAAa,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAC3E,CAAC;QAED,OAAO,EAAE,aAAa,EAAE,CAAC;IAC3B,CAAC;CACF;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,0BAA0B;IACxC,OAAO,IAAA,8BAAa,EAAkD,oBAAoB,CAAC,CAAC;AAC9F,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates an EC2 security group description. Unresolved CDK tokens are
|
|
3
|
+
* skipped — their value is resolved by CloudFormation and is not knowable at
|
|
4
|
+
* synth (ADR-0010).
|
|
5
|
+
*
|
|
6
|
+
* @throws on invalid input.
|
|
7
|
+
*/
|
|
8
|
+
export declare function validateSecurityGroupDescription(raw: string): void;
|
|
9
|
+
/**
|
|
10
|
+
* Validates an EC2 security group name. AWS additionally reserves the `sg-`
|
|
11
|
+
* prefix for generated group IDs, so a user-supplied name must not use it.
|
|
12
|
+
* Unresolved CDK tokens are skipped (ADR-0010).
|
|
13
|
+
*
|
|
14
|
+
* @throws on invalid input.
|
|
15
|
+
*/
|
|
16
|
+
export declare function validateSecurityGroupName(raw: string): void;
|
|
17
|
+
//# sourceMappingURL=security-group-constraints.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security-group-constraints.d.ts","sourceRoot":"","sources":["../../src/security-group-constraints.ts"],"names":[],"mappings":"AA2CA;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAGlE;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAQ3D"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateSecurityGroupDescription = validateSecurityGroupDescription;
|
|
4
|
+
exports.validateSecurityGroupName = validateSecurityGroupName;
|
|
5
|
+
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
6
|
+
const cloudformation_1 = require("@composurecdk/cloudformation");
|
|
7
|
+
/**
|
|
8
|
+
* AWS-property constraints for EC2 security groups.
|
|
9
|
+
*
|
|
10
|
+
* The catalogue mechanism (`stringConstraint` / `validateString`) lives in
|
|
11
|
+
* `@composurecdk/cloudformation`; this per-resource data lives next to the
|
|
12
|
+
* builder that enforces it. The trigger for the catalogue was an em-dash in a
|
|
13
|
+
* `GroupDescription` reaching CloudFormation and failing at CREATE_FAILED — a
|
|
14
|
+
* `validate*` call in `build()` turns that into a `cdk synth` error. See
|
|
15
|
+
* ADR-0010.
|
|
16
|
+
*
|
|
17
|
+
* The constraints themselves are module-private; the package exposes only the
|
|
18
|
+
* `validate*` functions (via the `constraints` namespace in the package index).
|
|
19
|
+
*
|
|
20
|
+
* `GroupDescription` and `GroupName` share the same EC2 character set, so they
|
|
21
|
+
* spread the same class fragments; the comma/bracket tail beyond the shared
|
|
22
|
+
* `charSets.AWS_NAME_PUNCT` spine is EC2-specific and stays local.
|
|
23
|
+
*/
|
|
24
|
+
const SG_TAIL = ",\\[\\]&;{}!$*";
|
|
25
|
+
const SG_CHAR_CLASS = `${cloudformation_1.charSets.ALNUM}${cloudformation_1.charSets.AWS_NAME_PUNCT}${SG_TAIL}`;
|
|
26
|
+
const SG_ALLOWED = "ASCII letters, digits, spaces and ._-:/()#,@[]+=&;{}!$*";
|
|
27
|
+
const SG_SOURCE = "https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateSecurityGroup.html";
|
|
28
|
+
const SECURITY_GROUP_DESCRIPTION = (0, cloudformation_1.stringConstraint)({
|
|
29
|
+
name: "EC2 SecurityGroup GroupDescription",
|
|
30
|
+
charClass: SG_CHAR_CLASS,
|
|
31
|
+
maxLength: 255,
|
|
32
|
+
allowed: SG_ALLOWED,
|
|
33
|
+
source: SG_SOURCE,
|
|
34
|
+
});
|
|
35
|
+
const SECURITY_GROUP_NAME = (0, cloudformation_1.stringConstraint)({
|
|
36
|
+
name: "EC2 SecurityGroup GroupName",
|
|
37
|
+
charClass: SG_CHAR_CLASS,
|
|
38
|
+
minLength: 1,
|
|
39
|
+
maxLength: 255,
|
|
40
|
+
allowed: SG_ALLOWED,
|
|
41
|
+
source: SG_SOURCE,
|
|
42
|
+
});
|
|
43
|
+
/**
|
|
44
|
+
* Validates an EC2 security group description. Unresolved CDK tokens are
|
|
45
|
+
* skipped — their value is resolved by CloudFormation and is not knowable at
|
|
46
|
+
* synth (ADR-0010).
|
|
47
|
+
*
|
|
48
|
+
* @throws on invalid input.
|
|
49
|
+
*/
|
|
50
|
+
function validateSecurityGroupDescription(raw) {
|
|
51
|
+
if (aws_cdk_lib_1.Token.isUnresolved(raw))
|
|
52
|
+
return;
|
|
53
|
+
(0, cloudformation_1.validateString)(raw, SECURITY_GROUP_DESCRIPTION);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Validates an EC2 security group name. AWS additionally reserves the `sg-`
|
|
57
|
+
* prefix for generated group IDs, so a user-supplied name must not use it.
|
|
58
|
+
* Unresolved CDK tokens are skipped (ADR-0010).
|
|
59
|
+
*
|
|
60
|
+
* @throws on invalid input.
|
|
61
|
+
*/
|
|
62
|
+
function validateSecurityGroupName(raw) {
|
|
63
|
+
if (aws_cdk_lib_1.Token.isUnresolved(raw))
|
|
64
|
+
return;
|
|
65
|
+
if (raw.startsWith("sg-")) {
|
|
66
|
+
throw new Error(`EC2 SecurityGroup GroupName "${raw}" must not start with the reserved "sg-" prefix. See ${SG_SOURCE}.`);
|
|
67
|
+
}
|
|
68
|
+
(0, cloudformation_1.validateString)(raw, SECURITY_GROUP_NAME);
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=security-group-constraints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security-group-constraints.js","sourceRoot":"","sources":["../../src/security-group-constraints.ts"],"names":[],"mappings":";;AAkDA,4EAGC;AASD,8DAQC;AAtED,6CAAoC;AACpC,iEAA0F;AAE1F;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,GAAG,gBAAgB,CAAC;AACjC,MAAM,aAAa,GAAG,GAAG,yBAAQ,CAAC,KAAK,GAAG,yBAAQ,CAAC,cAAc,GAAG,OAAO,EAAE,CAAC;AAC9E,MAAM,UAAU,GAAG,yDAAyD,CAAC;AAC7E,MAAM,SAAS,GACb,qFAAqF,CAAC;AAExF,MAAM,0BAA0B,GAAG,IAAA,iCAAgB,EAAC;IAClD,IAAI,EAAE,oCAAoC;IAC1C,SAAS,EAAE,aAAa;IACxB,SAAS,EAAE,GAAG;IACd,OAAO,EAAE,UAAU;IACnB,MAAM,EAAE,SAAS;CAClB,CAAC,CAAC;AAEH,MAAM,mBAAmB,GAAG,IAAA,iCAAgB,EAAC;IAC3C,IAAI,EAAE,6BAA6B;IACnC,SAAS,EAAE,aAAa;IACxB,SAAS,EAAE,CAAC;IACZ,SAAS,EAAE,GAAG;IACd,OAAO,EAAE,UAAU;IACnB,MAAM,EAAE,SAAS;CAClB,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,SAAgB,gCAAgC,CAAC,GAAW;IAC1D,IAAI,mBAAK,CAAC,YAAY,CAAC,GAAG,CAAC;QAAE,OAAO;IACpC,IAAA,+BAAc,EA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GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,GAAG,CAAC;IAET;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,QAAQ,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,WAAW,GAAG,cAAc,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;AAItE,cAAM,UAAW,YAAW,SAAS,CAAC,gBAAgB,CAAC;IACrD,KAAK,EAAE,OAAO,CAAC,eAAe,CAAC,CAAM;IAErC,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,GAAG,gBAAgB;CA8BvD;AA2CD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,gBAAgB,IAAI,WAAW,CAE9C"}
|
|
@@ -11,11 +11,22 @@ class VpcBuilder {
|
|
|
11
11
|
build(scope, id) {
|
|
12
12
|
const { flowLogs: flowLogsConfig, ...vpcProps } = this.props;
|
|
13
13
|
const { flowLogsLogGroup, flowLogProps } = resolveFlowLogs(scope, id, flowLogsConfig);
|
|
14
|
+
// CDK accepts `availabilityZones` or `maxAzs`, but not both. When the user
|
|
15
|
+
// pins AZs explicitly, the default `maxAzs` must yield to their intent;
|
|
16
|
+
// setting both is a genuine conflict and fails fast.
|
|
17
|
+
const userPinnedAzs = vpcProps.availabilityZones !== undefined;
|
|
18
|
+
if (userPinnedAzs && vpcProps.maxAzs !== undefined) {
|
|
19
|
+
throw new Error(`VpcBuilder "${id}": .availabilityZones() and .maxAzs() are mutually exclusive — ` +
|
|
20
|
+
`CDK accepts one or the other, not both.`);
|
|
21
|
+
}
|
|
14
22
|
const mergedProps = {
|
|
15
23
|
...vpc_defaults_js_1.VPC_DEFAULTS,
|
|
16
24
|
...flowLogProps,
|
|
17
25
|
...vpcProps,
|
|
18
26
|
};
|
|
27
|
+
if (userPinnedAzs) {
|
|
28
|
+
delete mergedProps.maxAzs;
|
|
29
|
+
}
|
|
19
30
|
return {
|
|
20
31
|
vpc: new aws_ec2_1.Vpc(scope, id, mergedProps),
|
|
21
32
|
flowLogsLogGroup,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vpc-builder.js","sourceRoot":"","sources":["../../src/vpc-builder.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"vpc-builder.js","sourceRoot":"","sources":["../../src/vpc-builder.ts"],"names":[],"mappings":";;AA8LA,4CAEC;AAhMD,iDAA6E;AAI7E,iEAAkF;AAClF,6CAAkF;AAClF,uDAAiD;AAmFjD,MAAM,oBAAoB,GAAG,gBAAgB,CAAC;AAE9C,MAAM,UAAU;IACd,KAAK,GAA6B,EAAE,CAAC;IAErC,KAAK,CAAC,KAAiB,EAAE,EAAU;QACjC,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,QAAQ,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAE7D,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE,GAAG,eAAe,CAAC,KAAK,EAAE,EAAE,EAAE,cAAc,CAAC,CAAC;QAEtF,2EAA2E;QAC3E,wEAAwE;QACxE,qDAAqD;QACrD,MAAM,aAAa,GAAG,QAAQ,CAAC,iBAAiB,KAAK,SAAS,CAAC;QAC/D,IAAI,aAAa,IAAI,QAAQ,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YACnD,MAAM,IAAI,KAAK,CACb,eAAe,EAAE,iEAAiE;gBAChF,yCAAyC,CAC5C,CAAC;QACJ,CAAC;QAED,MAAM,WAAW,GAAG;YAClB,GAAG,8BAAY;YACf,GAAG,YAAY;YACf,GAAG,QAAQ;SACZ,CAAC;QACF,IAAI,aAAa,EAAE,CAAC;YAClB,OAAO,WAAW,CAAC,MAAM,CAAC;QAC5B,CAAC;QAED,OAAO;YACL,GAAG,EAAE,IAAI,aAAG,CAAC,KAAK,EAAE,EAAE,EAAE,WAAW,CAAC;YACpC,gBAAgB;SACjB,CAAC;IACJ,CAAC;CACF;AAED,SAAS,eAAe,CACtB,KAAiB,EACjB,EAAU,EACV,GAA+B;IAE/B,IAAI,GAAG,KAAK,KAAK,EAAE,CAAC;QAClB,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;IAC9B,CAAC;IAED,IAAI,GAAG,EAAE,WAAW,KAAK,SAAS,EAAE,CAAC;QACnC,IAAI,GAAG,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CACb,gEAAgE;gBAC9D,gEAAgE,CACnE,CAAC;QACJ,CAAC;QACD,OAAO;YACL,YAAY,EAAE;gBACZ,QAAQ,EAAE,EAAE,CAAC,oBAAoB,CAAC,EAAE,EAAE,WAAW,EAAE,GAAG,CAAC,WAAW,EAAE,EAAE;aACvE;SACF,CAAC;IACJ,CAAC;IAED,IAAI,UAAU,GAAG,IAAA,4BAAqB,GAAE,CAAC;IACzC,IAAI,GAAG,EAAE,SAAS,EAAE,CAAC;QACnB,UAAU,GAAG,GAAG,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IACzC,CAAC;IACD,MAAM,gBAAgB,GAAG,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,kBAAkB,CAAC,CAAC,QAAQ,CAAC;IAEnF,OAAO;QACL,gBAAgB;QAChB,YAAY,EAAE;YACZ,QAAQ,EAAE;gBACR,CAAC,oBAAoB,CAAC,EAAE;oBACtB,WAAW,EAAE,4BAAkB,CAAC,gBAAgB,CAAC,gBAAgB,CAAC;iBACnE;aACF;SACF;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAgB,gBAAgB;IAC9B,OAAO,IAAA,8BAAa,EAA8B,UAAU,CAAC,CAAC;AAChE,CAAC"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { validateSecurityGroupDescription, validateSecurityGroupName } from "./security-group-constraints.js";
|
|
1
2
|
export { createInstanceBuilder, type IInstanceBuilder, type InstanceBuilderProps, type InstanceBuilderResult, } from "./instance-builder.js";
|
|
2
3
|
export { INSTANCE_DEFAULTS } from "./instance-defaults.js";
|
|
3
4
|
export { type InstanceAlarmConfig } from "./instance-alarm-config.js";
|
|
@@ -13,4 +14,23 @@ export { createVpcBuilder, type FlowLogsConfig, type IVpcBuilder, type VpcBuilde
|
|
|
13
14
|
export { VPC_DEFAULTS } from "./vpc-defaults.js";
|
|
14
15
|
export { createSecurityGroupBuilder, type ISecurityGroupBuilder, type SecurityGroupBuilderProps, type SecurityGroupBuilderResult, } from "./security-group-builder.js";
|
|
15
16
|
export { SECURITY_GROUP_DEFAULTS } from "./security-group-defaults.js";
|
|
17
|
+
export { createInterfaceEndpointBuilder, type IInterfaceEndpointBuilder, type InterfaceEndpointBuilderProps, type InterfaceEndpointBuilderResult, } from "./interface-endpoint-builder.js";
|
|
18
|
+
export { INTERFACE_ENDPOINT_DEFAULTS } from "./interface-endpoint-defaults.js";
|
|
19
|
+
export { type InterfaceEndpointAlarmConfig } from "./interface-endpoint-alarm-config.js";
|
|
20
|
+
export { INTERFACE_ENDPOINT_ALARM_DEFAULTS } from "./interface-endpoint-alarm-defaults.js";
|
|
21
|
+
/**
|
|
22
|
+
* This package's AWS-property constraints, grouped by application strategy.
|
|
23
|
+
* The `constraints.validate.*` / `constraints.sanitize.*` shape is identical
|
|
24
|
+
* in every builder package, so it is discoverable without importing anything
|
|
25
|
+
* beyond the package you already use. The underlying constraint definitions and
|
|
26
|
+
* `validate*` functions stay module-private — this namespace is the only public
|
|
27
|
+
* surface for them. See ADR-0010.
|
|
28
|
+
*/
|
|
29
|
+
export declare const constraints: {
|
|
30
|
+
validate: {
|
|
31
|
+
securityGroupDescription: typeof validateSecurityGroupDescription;
|
|
32
|
+
securityGroupName: typeof validateSecurityGroupName;
|
|
33
|
+
};
|
|
34
|
+
sanitize: {};
|
|
35
|
+
};
|
|
16
36
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gCAAgC,EAChC,yBAAyB,EAC1B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,qBAAqB,EACrB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,GAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,wCAAwC,CAAC;AAC1F,OAAO,EAAE,gCAAgC,EAAE,MAAM,0CAA0C,CAAC;AAE5F,OAAO,EACL,mBAAmB,EACnB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,GACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,OAAO,EACL,gBAAgB,EAChB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EACL,0BAA0B,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,GAChC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAEvE,OAAO,EACL,8BAA8B,EAC9B,KAAK,yBAAyB,EAC9B,KAAK,6BAA6B,EAClC,KAAK,8BAA8B,GACpC,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,KAAK,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AACzF,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAE3F;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW;;;;;;CAMO,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { validateSecurityGroupDescription, validateSecurityGroupName, } from "./security-group-constraints.js";
|
|
1
2
|
export { createInstanceBuilder, } from "./instance-builder.js";
|
|
2
3
|
export { INSTANCE_DEFAULTS } from "./instance-defaults.js";
|
|
3
4
|
export { INSTANCE_ALARM_DEFAULTS } from "./instance-alarm-defaults.js";
|
|
@@ -9,4 +10,22 @@ export { createVpcBuilder, } from "./vpc-builder.js";
|
|
|
9
10
|
export { VPC_DEFAULTS } from "./vpc-defaults.js";
|
|
10
11
|
export { createSecurityGroupBuilder, } from "./security-group-builder.js";
|
|
11
12
|
export { SECURITY_GROUP_DEFAULTS } from "./security-group-defaults.js";
|
|
13
|
+
export { createInterfaceEndpointBuilder, } from "./interface-endpoint-builder.js";
|
|
14
|
+
export { INTERFACE_ENDPOINT_DEFAULTS } from "./interface-endpoint-defaults.js";
|
|
15
|
+
export { INTERFACE_ENDPOINT_ALARM_DEFAULTS } from "./interface-endpoint-alarm-defaults.js";
|
|
16
|
+
/**
|
|
17
|
+
* This package's AWS-property constraints, grouped by application strategy.
|
|
18
|
+
* The `constraints.validate.*` / `constraints.sanitize.*` shape is identical
|
|
19
|
+
* in every builder package, so it is discoverable without importing anything
|
|
20
|
+
* beyond the package you already use. The underlying constraint definitions and
|
|
21
|
+
* `validate*` functions stay module-private — this namespace is the only public
|
|
22
|
+
* surface for them. See ADR-0010.
|
|
23
|
+
*/
|
|
24
|
+
export const constraints = {
|
|
25
|
+
validate: {
|
|
26
|
+
securityGroupDescription: validateSecurityGroupDescription,
|
|
27
|
+
securityGroupName: validateSecurityGroupName,
|
|
28
|
+
},
|
|
29
|
+
sanitize: {},
|
|
30
|
+
};
|
|
12
31
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gCAAgC,EAChC,yBAAyB,GAC1B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,qBAAqB,GAItB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAGvE,OAAO,EAAE,gCAAgC,EAAE,MAAM,0CAA0C,CAAC;AAE5F,OAAO,EACL,mBAAmB,GAIpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,OAAO,EACL,gBAAgB,GAKjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EACL,0BAA0B,GAI3B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAEvE,OAAO,EACL,8BAA8B,GAI/B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAE/E,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAE3F;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,QAAQ,EAAE;QACR,wBAAwB,EAAE,gCAAgC;QAC1D,iBAAiB,EAAE,yBAAyB;KAC7C;IACD,QAAQ,EAAE,EAAE;CACiB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { AlarmConfig } from "@composurecdk/cloudwatch";
|
|
2
|
+
/**
|
|
3
|
+
* Controls which recommended alarms are created for a VPC interface endpoint.
|
|
4
|
+
* All alarms are enabled by default with AWS-recommended thresholds.
|
|
5
|
+
* Set individual alarms to `false` to disable them, or provide an
|
|
6
|
+
* {@link AlarmConfig} to tune thresholds.
|
|
7
|
+
*
|
|
8
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#PrivateLinkEndpoints
|
|
9
|
+
*/
|
|
10
|
+
export interface InterfaceEndpointAlarmConfig {
|
|
11
|
+
/**
|
|
12
|
+
* Master switch: set to `false` to disable all recommended alarms.
|
|
13
|
+
* Individual alarms can also be disabled via their own entry.
|
|
14
|
+
* @default true
|
|
15
|
+
*/
|
|
16
|
+
enabled?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Alarm when the endpoint drops packets, indicating the endpoint or
|
|
19
|
+
* endpoint service is unhealthy, a security group is blocking traffic,
|
|
20
|
+
* or packets are hitting the 8,500-byte PrivateLink MTU limit.
|
|
21
|
+
*
|
|
22
|
+
* Metric: `AWS/PrivateLinkEndpoints PacketsDropped`, statistic Sum,
|
|
23
|
+
* period 1 minute. Default threshold: > 0 over 5 consecutive 1-minute
|
|
24
|
+
* windows.
|
|
25
|
+
*
|
|
26
|
+
* If your workload intentionally sends packets larger than 8,500 bytes
|
|
27
|
+
* you may want to raise the threshold to reduce noise from expected MTU
|
|
28
|
+
* drops.
|
|
29
|
+
*
|
|
30
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#PrivateLinkEndpoints
|
|
31
|
+
*/
|
|
32
|
+
packetsDropped?: AlarmConfig | false;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=interface-endpoint-alarm-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface-endpoint-alarm-config.d.ts","sourceRoot":"","sources":["../../src/interface-endpoint-alarm-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;;;;;;GAOG;AACH,MAAM,WAAW,4BAA4B;IAC3C;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;;;;;;;;;;;OAcG;IACH,cAAc,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC;CACtC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface-endpoint-alarm-config.js","sourceRoot":"","sources":["../../src/interface-endpoint-alarm-config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AlarmConfigDefaults } from "@composurecdk/cloudwatch";
|
|
2
|
+
interface InterfaceEndpointAlarmDefaults {
|
|
3
|
+
enabled: true;
|
|
4
|
+
packetsDropped: AlarmConfigDefaults;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* AWS-recommended default alarm configuration for VPC interface endpoints.
|
|
8
|
+
*
|
|
9
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#PrivateLinkEndpoints
|
|
10
|
+
*/
|
|
11
|
+
export declare const INTERFACE_ENDPOINT_ALARM_DEFAULTS: InterfaceEndpointAlarmDefaults;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=interface-endpoint-alarm-defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface-endpoint-alarm-defaults.d.ts","sourceRoot":"","sources":["../../src/interface-endpoint-alarm-defaults.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,UAAU,8BAA8B;IACtC,OAAO,EAAE,IAAI,CAAC;IACd,cAAc,EAAE,mBAAmB,CAAC;CACrC;AAED;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,EAAE,8BAkB/C,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { TreatMissingData } from "aws-cdk-lib/aws-cloudwatch";
|
|
2
|
+
/**
|
|
3
|
+
* AWS-recommended default alarm configuration for VPC interface endpoints.
|
|
4
|
+
*
|
|
5
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#PrivateLinkEndpoints
|
|
6
|
+
*/
|
|
7
|
+
export const INTERFACE_ENDPOINT_ALARM_DEFAULTS = {
|
|
8
|
+
enabled: true,
|
|
9
|
+
/**
|
|
10
|
+
* Any sustained packet drop at the endpoint signals a connectivity or
|
|
11
|
+
* configuration problem — an unhealthy endpoint service, a security group
|
|
12
|
+
* blocking traffic, or jumbo frames exceeding the 8,500-byte PrivateLink
|
|
13
|
+
* MTU. Five consecutive 1-minute periods avoids false alarms from isolated
|
|
14
|
+
* oversized packets while still catching persistent issues quickly.
|
|
15
|
+
*
|
|
16
|
+
* @see https://docs.aws.amazon.com/vpc/latest/privatelink/privatelink-troubleshoot.html
|
|
17
|
+
*/
|
|
18
|
+
packetsDropped: {
|
|
19
|
+
threshold: 0,
|
|
20
|
+
evaluationPeriods: 5,
|
|
21
|
+
datapointsToAlarm: 5,
|
|
22
|
+
treatMissingData: TreatMissingData.NOT_BREACHING,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=interface-endpoint-alarm-defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface-endpoint-alarm-defaults.js","sourceRoot":"","sources":["../../src/interface-endpoint-alarm-defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAQ9D;;;;GAIG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAmC;IAC/E,OAAO,EAAE,IAAI;IAEb;;;;;;;;OAQG;IACH,cAAc,EAAE;QACd,SAAS,EAAE,CAAC;QACZ,iBAAiB,EAAE,CAAC;QACpB,iBAAiB,EAAE,CAAC;QACpB,gBAAgB,EAAE,gBAAgB,CAAC,aAAa;KACjD;CACF,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Alarm } from "aws-cdk-lib/aws-cloudwatch";
|
|
2
|
+
import { type InterfaceVpcEndpoint } from "aws-cdk-lib/aws-ec2";
|
|
3
|
+
import type { IConstruct } from "constructs";
|
|
4
|
+
import { AlarmDefinitionBuilder } from "@composurecdk/cloudwatch";
|
|
5
|
+
import type { InterfaceEndpointAlarmConfig } from "./interface-endpoint-alarm-config.js";
|
|
6
|
+
/**
|
|
7
|
+
* Creates AWS-recommended CloudWatch alarms for a VPC interface endpoint,
|
|
8
|
+
* merging recommended definitions with any custom alarm builders.
|
|
9
|
+
*
|
|
10
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#PrivateLinkEndpoints
|
|
11
|
+
*/
|
|
12
|
+
export declare function createInterfaceEndpointAlarms(scope: IConstruct, id: string, endpoint: InterfaceVpcEndpoint, config: InterfaceEndpointAlarmConfig | false | undefined, customAlarms?: AlarmDefinitionBuilder<InterfaceVpcEndpoint>[]): Record<string, Alarm>;
|
|
13
|
+
//# sourceMappingURL=interface-endpoint-alarms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface-endpoint-alarms.d.ts","sourceRoot":"","sources":["../../src/interface-endpoint-alarms.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAqC,MAAM,4BAA4B,CAAC;AAC3F,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,sBAAsB,EAAoC,MAAM,0BAA0B,CAAC;AACpG,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AAsDzF;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,UAAU,EACjB,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,oBAAoB,EAC9B,MAAM,EAAE,4BAA4B,GAAG,KAAK,GAAG,SAAS,EACxD,YAAY,GAAE,sBAAsB,CAAC,oBAAoB,CAAC,EAAO,GAChE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAUvB"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Duration } from "aws-cdk-lib";
|
|
2
|
+
import { ComparisonOperator, Metric, Stats } from "aws-cdk-lib/aws-cloudwatch";
|
|
3
|
+
import { createAlarms, resolveAlarmConfig } from "@composurecdk/cloudwatch";
|
|
4
|
+
import { INTERFACE_ENDPOINT_ALARM_DEFAULTS } from "./interface-endpoint-alarm-defaults.js";
|
|
5
|
+
const PACKETS_DROPPED_PERIOD = Duration.minutes(1);
|
|
6
|
+
const PACKETS_DROPPED_PERIOD_LABEL = `${String(PACKETS_DROPPED_PERIOD.toMinutes())} minute`;
|
|
7
|
+
function endpointMetric(endpoint, metricName, statistic, period) {
|
|
8
|
+
return new Metric({
|
|
9
|
+
namespace: "AWS/PrivateLinkEndpoints",
|
|
10
|
+
metricName,
|
|
11
|
+
dimensionsMap: { "VPC Endpoint Id": endpoint.vpcEndpointId },
|
|
12
|
+
statistic,
|
|
13
|
+
period,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function resolveEndpointAlarmDefinitions(endpoint, config) {
|
|
17
|
+
if (config?.enabled === false)
|
|
18
|
+
return [];
|
|
19
|
+
const definitions = [];
|
|
20
|
+
if (config?.packetsDropped !== false) {
|
|
21
|
+
const cfg = resolveAlarmConfig(config?.packetsDropped, INTERFACE_ENDPOINT_ALARM_DEFAULTS.packetsDropped);
|
|
22
|
+
definitions.push({
|
|
23
|
+
key: "packetsDropped",
|
|
24
|
+
alarmName: cfg.alarmName,
|
|
25
|
+
metric: endpointMetric(endpoint, "PacketsDropped", Stats.SUM, PACKETS_DROPPED_PERIOD),
|
|
26
|
+
threshold: cfg.threshold,
|
|
27
|
+
comparisonOperator: ComparisonOperator.GREATER_THAN_THRESHOLD,
|
|
28
|
+
evaluationPeriods: cfg.evaluationPeriods,
|
|
29
|
+
datapointsToAlarm: cfg.datapointsToAlarm,
|
|
30
|
+
treatMissingData: cfg.treatMissingData,
|
|
31
|
+
description: `VPC interface endpoint is dropping packets — possible endpoint service unhealthy, ` +
|
|
32
|
+
`security group blocking traffic, or packets exceeding the 8,500-byte PrivateLink MTU. ` +
|
|
33
|
+
`Threshold: > ${String(cfg.threshold)} (sum) over ` +
|
|
34
|
+
`${String(cfg.evaluationPeriods)} x ${PACKETS_DROPPED_PERIOD_LABEL}.`,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return definitions;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Creates AWS-recommended CloudWatch alarms for a VPC interface endpoint,
|
|
41
|
+
* merging recommended definitions with any custom alarm builders.
|
|
42
|
+
*
|
|
43
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#PrivateLinkEndpoints
|
|
44
|
+
*/
|
|
45
|
+
export function createInterfaceEndpointAlarms(scope, id, endpoint, config, customAlarms = []) {
|
|
46
|
+
if (config === false)
|
|
47
|
+
return {};
|
|
48
|
+
const enabled = config?.enabled ?? INTERFACE_ENDPOINT_ALARM_DEFAULTS.enabled;
|
|
49
|
+
if (!enabled)
|
|
50
|
+
return {};
|
|
51
|
+
const recommended = resolveEndpointAlarmDefinitions(endpoint, config);
|
|
52
|
+
const custom = customAlarms.map((b) => b.resolve(endpoint));
|
|
53
|
+
return createAlarms(scope, id, [...recommended, ...custom]);
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=interface-endpoint-alarms.js.map
|