@composurecdk/ec2 0.8.4 → 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 +4 -0
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +7 -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/esm/index.d.ts +4 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +3 -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/package.json +16 -5
package/README.md
CHANGED
|
@@ -288,6 +288,206 @@ compose(
|
|
|
288
288
|
|
|
289
289
|
The Security Group builder does **not** create CloudWatch alarms. Security groups do not emit CloudWatch metrics — the [AWS recommended-alarms reference](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html) has no SG entry. Operational visibility for SGs comes from adjacent signals (VPC Flow Logs, GuardDuty findings, CloudTrail `AuthorizeSecurityGroupIngress`/`Egress` events), none of which belong on the builder result.
|
|
290
290
|
|
|
291
|
+
## Interface Endpoint Builder
|
|
292
|
+
|
|
293
|
+
VPC interface endpoints (AWS PrivateLink) have no props-time surface in CDK —
|
|
294
|
+
the only way to add one is the post-build `vpc.addInterfaceEndpoint(...)` call,
|
|
295
|
+
whose security group is never exposed. `createInterfaceEndpointBuilder` makes an
|
|
296
|
+
endpoint a first-class `compose()` component. It maps **1:1 to a CDK
|
|
297
|
+
`InterfaceVpcEndpoint`** (one `service` per endpoint) and supports two security
|
|
298
|
+
group modes:
|
|
299
|
+
|
|
300
|
+
- **BYO** — `.securityGroups([...])` with SGs you fully manage (typically
|
|
301
|
+
sibling `SecurityGroupBuilder`s): full ingress/egress/port control.
|
|
302
|
+
- **Managed shortcut** — omit `.securityGroups()` and the builder auto-creates a
|
|
303
|
+
closed SG, exposes it on the result, and `.allowDefaultPortFrom(peer)` wires
|
|
304
|
+
bidirectionally: ingress on the managed SG from the peer **and** egress from
|
|
305
|
+
the peer's SG to the managed SG (on the service's default port, 443).
|
|
306
|
+
|
|
307
|
+
The two are mutually exclusive (combining them throws). To group several
|
|
308
|
+
endpoints under one access policy, point them at the same security group.
|
|
309
|
+
|
|
310
|
+
### Minimalist single service (managed shortcut)
|
|
311
|
+
|
|
312
|
+
```ts
|
|
313
|
+
import { compose, ref } from "@composurecdk/core";
|
|
314
|
+
import {
|
|
315
|
+
createInterfaceEndpointBuilder,
|
|
316
|
+
createSecurityGroupBuilder,
|
|
317
|
+
createVpcBuilder,
|
|
318
|
+
type SecurityGroupBuilderResult,
|
|
319
|
+
type VpcBuilderResult,
|
|
320
|
+
} from "@composurecdk/ec2";
|
|
321
|
+
import { InterfaceVpcEndpointAwsService, SubnetType } from "aws-cdk-lib/aws-ec2";
|
|
322
|
+
|
|
323
|
+
compose(
|
|
324
|
+
{
|
|
325
|
+
network: createVpcBuilder().natGateways(0),
|
|
326
|
+
bastionSg: createSecurityGroupBuilder()
|
|
327
|
+
.vpc(ref<VpcBuilderResult>("network").get("vpc"))
|
|
328
|
+
.description("Bastion"),
|
|
329
|
+
ssm: createInterfaceEndpointBuilder()
|
|
330
|
+
.vpc(ref<VpcBuilderResult>("network").get("vpc"))
|
|
331
|
+
.service(InterfaceVpcEndpointAwsService.SSM)
|
|
332
|
+
.subnets({ subnetType: SubnetType.PRIVATE_ISOLATED })
|
|
333
|
+
.allowDefaultPortFrom(ref<SecurityGroupBuilderResult>("bastionSg").get("securityGroup")),
|
|
334
|
+
},
|
|
335
|
+
{ network: [], bastionSg: ["network"], ssm: ["network", "bastionSg"] },
|
|
336
|
+
).build(stack, "App");
|
|
337
|
+
// result.ssm = { endpoint: InterfaceVpcEndpoint, securityGroup: SecurityGroup }
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
The managed `securityGroup` is present on the result for cases where another
|
|
341
|
+
component needs a direct reference to it (e.g. BYO-mode builders that share
|
|
342
|
+
one SG across several endpoints). The peer's egress rule is wired automatically
|
|
343
|
+
by `.allowDefaultPortFrom()` — no manual `addEgressRule` call needed.
|
|
344
|
+
|
|
345
|
+
### SSM access (multiple endpoints, one shared SG)
|
|
346
|
+
|
|
347
|
+
SSM/Session Manager in a NAT-free VPC needs three endpoints with identical
|
|
348
|
+
ingress. One endpoint per builder — share a single BYO `SecurityGroupBuilder`
|
|
349
|
+
across all three. The access policy lives on the shared SG, not on individual
|
|
350
|
+
endpoints:
|
|
351
|
+
|
|
352
|
+
```ts
|
|
353
|
+
import { compose, ref } from "@composurecdk/core";
|
|
354
|
+
import {
|
|
355
|
+
createInterfaceEndpointBuilder,
|
|
356
|
+
createSecurityGroupBuilder,
|
|
357
|
+
createVpcBuilder,
|
|
358
|
+
type SecurityGroupBuilderResult,
|
|
359
|
+
type VpcBuilderResult,
|
|
360
|
+
} from "@composurecdk/ec2";
|
|
361
|
+
import { InterfaceVpcEndpointAwsService, Port, SubnetType } from "aws-cdk-lib/aws-ec2";
|
|
362
|
+
|
|
363
|
+
compose(
|
|
364
|
+
{
|
|
365
|
+
network: createVpcBuilder().natGateways(0),
|
|
366
|
+
bastionSg: createSecurityGroupBuilder()
|
|
367
|
+
.vpc(ref<VpcBuilderResult>("network").get("vpc"))
|
|
368
|
+
.description("Bastion"),
|
|
369
|
+
// One SG shared by all three endpoints — the access policy lives here.
|
|
370
|
+
endpointSg: createSecurityGroupBuilder()
|
|
371
|
+
.vpc(ref<VpcBuilderResult>("network").get("vpc"))
|
|
372
|
+
.description("SSM endpoints")
|
|
373
|
+
.addIngressRule(
|
|
374
|
+
ref<SecurityGroupBuilderResult>("bastionSg").get("securityGroup"),
|
|
375
|
+
Port.tcp(443),
|
|
376
|
+
),
|
|
377
|
+
ssm: createInterfaceEndpointBuilder()
|
|
378
|
+
.vpc(ref<VpcBuilderResult>("network").get("vpc"))
|
|
379
|
+
.service(InterfaceVpcEndpointAwsService.SSM)
|
|
380
|
+
.subnets({ subnetType: SubnetType.PRIVATE_ISOLATED })
|
|
381
|
+
.securityGroups([ref<SecurityGroupBuilderResult>("endpointSg").get("securityGroup")]),
|
|
382
|
+
ssmmessages: createInterfaceEndpointBuilder()
|
|
383
|
+
.vpc(ref<VpcBuilderResult>("network").get("vpc"))
|
|
384
|
+
.service(InterfaceVpcEndpointAwsService.SSM_MESSAGES)
|
|
385
|
+
.subnets({ subnetType: SubnetType.PRIVATE_ISOLATED })
|
|
386
|
+
.securityGroups([ref<SecurityGroupBuilderResult>("endpointSg").get("securityGroup")]),
|
|
387
|
+
ec2messages: createInterfaceEndpointBuilder()
|
|
388
|
+
.vpc(ref<VpcBuilderResult>("network").get("vpc"))
|
|
389
|
+
.service(InterfaceVpcEndpointAwsService.EC2_MESSAGES)
|
|
390
|
+
.subnets({ subnetType: SubnetType.PRIVATE_ISOLATED })
|
|
391
|
+
.securityGroups([ref<SecurityGroupBuilderResult>("endpointSg").get("securityGroup")]),
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
network: [],
|
|
395
|
+
bastionSg: ["network"],
|
|
396
|
+
endpointSg: ["network", "bastionSg"],
|
|
397
|
+
ssm: ["network", "endpointSg"],
|
|
398
|
+
ssmmessages: ["network", "endpointSg"],
|
|
399
|
+
ec2messages: ["network", "endpointSg"],
|
|
400
|
+
},
|
|
401
|
+
).build(stack, "App");
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
### Complex / custom service (BYO security group)
|
|
405
|
+
|
|
406
|
+
A custom PrivateLink service on a non-443 port, with precise ingress _and_
|
|
407
|
+
egress controlled by the `SecurityGroupBuilder` you already have:
|
|
408
|
+
|
|
409
|
+
```ts
|
|
410
|
+
import { InterfaceVpcEndpointService, Port } from "aws-cdk-lib/aws-ec2";
|
|
411
|
+
|
|
412
|
+
compose(
|
|
413
|
+
{
|
|
414
|
+
network: createVpcBuilder(),
|
|
415
|
+
appSg: createSecurityGroupBuilder()
|
|
416
|
+
.vpc(ref<VpcBuilderResult>("network").get("vpc"))
|
|
417
|
+
.description("App tier"),
|
|
418
|
+
endpointSg: createSecurityGroupBuilder()
|
|
419
|
+
.vpc(ref<VpcBuilderResult>("network").get("vpc"))
|
|
420
|
+
.description("Partner PrivateLink endpoint")
|
|
421
|
+
.addIngressRule(ref<SecurityGroupBuilderResult>("appSg").get("securityGroup"), Port.tcp(8443))
|
|
422
|
+
.addEgressRule(ref<SecurityGroupBuilderResult>("appSg").get("securityGroup"), Port.tcp(8443)),
|
|
423
|
+
partner: createInterfaceEndpointBuilder()
|
|
424
|
+
.vpc(ref<VpcBuilderResult>("network").get("vpc"))
|
|
425
|
+
.service(
|
|
426
|
+
new InterfaceVpcEndpointService("com.amazonaws.vpce.eu-west-1.vpce-svc-0abc123", 8443),
|
|
427
|
+
)
|
|
428
|
+
.securityGroups([ref<SecurityGroupBuilderResult>("endpointSg").get("securityGroup")]),
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
network: [],
|
|
432
|
+
appSg: ["network"],
|
|
433
|
+
endpointSg: ["network", "appSg"],
|
|
434
|
+
partner: ["network", "endpointSg"],
|
|
435
|
+
},
|
|
436
|
+
).build(stack, "App");
|
|
437
|
+
// result.partner = { endpoint: InterfaceVpcEndpoint } (no managed securityGroup in BYO mode)
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
### Interface Endpoint Defaults
|
|
441
|
+
|
|
442
|
+
`createInterfaceEndpointBuilder` applies the following defaults. Each can be overridden via the builder's fluent API.
|
|
443
|
+
|
|
444
|
+
| Property | Default | Rationale |
|
|
445
|
+
| ------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
446
|
+
| `privateDnsEnabled` | `true` | Enables `<service>.<region>.amazonaws.com` to resolve to the endpoint ENIs, keeping traffic on the AWS network without requiring application-level changes. Disabled by default in raw CDK for custom services. |
|
|
447
|
+
|
|
448
|
+
The defaults are exported as `INTERFACE_ENDPOINT_DEFAULTS` for visibility and testing:
|
|
449
|
+
|
|
450
|
+
```ts
|
|
451
|
+
import { INTERFACE_ENDPOINT_DEFAULTS } from "@composurecdk/ec2";
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
### Recommended Alarms
|
|
455
|
+
|
|
456
|
+
The builder creates [AWS-recommended CloudWatch alarms](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#PrivateLinkEndpoints) by default. No alarm actions are configured — wire actions via `alarmActionsPolicy` from `@composurecdk/cloudwatch`, or by accessing alarms from the build result.
|
|
457
|
+
|
|
458
|
+
| Alarm | Metric | Default threshold | Created when |
|
|
459
|
+
| ---------------- | --------------------------- | ---------------------------- | ------------ |
|
|
460
|
+
| `packetsDropped` | PacketsDropped (Sum, 1 min) | > 0 over 5 consecutive 1-min | Always |
|
|
461
|
+
|
|
462
|
+
If your workload intentionally sends packets larger than 8,500 bytes (the PrivateLink MTU limit), raise the threshold to reduce noise from expected MTU drops:
|
|
463
|
+
|
|
464
|
+
```ts
|
|
465
|
+
createInterfaceEndpointBuilder()
|
|
466
|
+
.vpc(ref<VpcBuilderResult>("network").get("vpc"))
|
|
467
|
+
.service(InterfaceVpcEndpointAwsService.SSM)
|
|
468
|
+
.recommendedAlarms({ packetsDropped: { threshold: 100 } });
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
Disable all recommended alarms:
|
|
472
|
+
|
|
473
|
+
```ts
|
|
474
|
+
builder.recommendedAlarms(false);
|
|
475
|
+
// or
|
|
476
|
+
builder.recommendedAlarms({ enabled: false });
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
Disable individual alarms:
|
|
480
|
+
|
|
481
|
+
```ts
|
|
482
|
+
builder.recommendedAlarms({ packetsDropped: false });
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
The defaults are exported as `INTERFACE_ENDPOINT_ALARM_DEFAULTS` for visibility and testing:
|
|
486
|
+
|
|
487
|
+
```ts
|
|
488
|
+
import { INTERFACE_ENDPOINT_ALARM_DEFAULTS } from "@composurecdk/ec2";
|
|
489
|
+
```
|
|
490
|
+
|
|
291
491
|
## Volume Builder
|
|
292
492
|
|
|
293
493
|
```ts
|
package/dist/commonjs/index.d.ts
CHANGED
|
@@ -14,6 +14,10 @@ export { createVpcBuilder, type FlowLogsConfig, type IVpcBuilder, type VpcBuilde
|
|
|
14
14
|
export { VPC_DEFAULTS } from "./vpc-defaults.js";
|
|
15
15
|
export { createSecurityGroupBuilder, type ISecurityGroupBuilder, type SecurityGroupBuilderProps, type SecurityGroupBuilderResult, } from "./security-group-builder.js";
|
|
16
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";
|
|
17
21
|
/**
|
|
18
22
|
* This package's AWS-property constraints, grouped by application strategy.
|
|
19
23
|
* The `constraints.validate.*` / `constraints.sanitize.*` shape is identical
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gCAA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9B,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/commonjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.constraints = exports.SECURITY_GROUP_DEFAULTS = exports.createSecurityGroupBuilder = exports.VPC_DEFAULTS = exports.createVpcBuilder = exports.VOLUME_ALARM_DEFAULTS = exports.VOLUME_DEFAULTS = exports.createVolumeBuilder = exports.VOLUME_ATTACHMENT_ALARM_DEFAULTS = exports.INSTANCE_ALARM_DEFAULTS = exports.INSTANCE_DEFAULTS = exports.createInstanceBuilder = void 0;
|
|
3
|
+
exports.constraints = exports.INTERFACE_ENDPOINT_ALARM_DEFAULTS = exports.INTERFACE_ENDPOINT_DEFAULTS = exports.createInterfaceEndpointBuilder = exports.SECURITY_GROUP_DEFAULTS = exports.createSecurityGroupBuilder = exports.VPC_DEFAULTS = exports.createVpcBuilder = exports.VOLUME_ALARM_DEFAULTS = exports.VOLUME_DEFAULTS = exports.createVolumeBuilder = exports.VOLUME_ATTACHMENT_ALARM_DEFAULTS = exports.INSTANCE_ALARM_DEFAULTS = exports.INSTANCE_DEFAULTS = exports.createInstanceBuilder = void 0;
|
|
4
4
|
const security_group_constraints_js_1 = require("./security-group-constraints.js");
|
|
5
5
|
var instance_builder_js_1 = require("./instance-builder.js");
|
|
6
6
|
Object.defineProperty(exports, "createInstanceBuilder", { enumerable: true, get: function () { return instance_builder_js_1.createInstanceBuilder; } });
|
|
@@ -24,6 +24,12 @@ var security_group_builder_js_1 = require("./security-group-builder.js");
|
|
|
24
24
|
Object.defineProperty(exports, "createSecurityGroupBuilder", { enumerable: true, get: function () { return security_group_builder_js_1.createSecurityGroupBuilder; } });
|
|
25
25
|
var security_group_defaults_js_1 = require("./security-group-defaults.js");
|
|
26
26
|
Object.defineProperty(exports, "SECURITY_GROUP_DEFAULTS", { enumerable: true, get: function () { return security_group_defaults_js_1.SECURITY_GROUP_DEFAULTS; } });
|
|
27
|
+
var interface_endpoint_builder_js_1 = require("./interface-endpoint-builder.js");
|
|
28
|
+
Object.defineProperty(exports, "createInterfaceEndpointBuilder", { enumerable: true, get: function () { return interface_endpoint_builder_js_1.createInterfaceEndpointBuilder; } });
|
|
29
|
+
var interface_endpoint_defaults_js_1 = require("./interface-endpoint-defaults.js");
|
|
30
|
+
Object.defineProperty(exports, "INTERFACE_ENDPOINT_DEFAULTS", { enumerable: true, get: function () { return interface_endpoint_defaults_js_1.INTERFACE_ENDPOINT_DEFAULTS; } });
|
|
31
|
+
var interface_endpoint_alarm_defaults_js_1 = require("./interface-endpoint-alarm-defaults.js");
|
|
32
|
+
Object.defineProperty(exports, "INTERFACE_ENDPOINT_ALARM_DEFAULTS", { enumerable: true, get: function () { return interface_endpoint_alarm_defaults_js_1.INTERFACE_ENDPOINT_ALARM_DEFAULTS; } });
|
|
27
33
|
/**
|
|
28
34
|
* This package's AWS-property constraints, grouped by application strategy.
|
|
29
35
|
* The `constraints.validate.*` / `constraints.sanitize.*` shape is identical
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AACA,mFAGyC;AAEzC,6DAK+B;AAJ7B,4HAAA,qBAAqB,OAAA;AAKvB,+DAA2D;AAAlD,yHAAA,iBAAiB,OAAA;AAE1B,2EAAuE;AAA9D,qIAAA,uBAAuB,OAAA;AAGhC,mGAA4F;AAAnF,0JAAA,gCAAgC,OAAA;AAEzC,yDAK6B;AAJ3B,w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AAgC;QAC1D,iBAAiB,EAAE,yDAAyB;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,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.INTERFACE_ENDPOINT_ALARM_DEFAULTS = void 0;
|
|
4
|
+
const aws_cloudwatch_1 = require("aws-cdk-lib/aws-cloudwatch");
|
|
5
|
+
/**
|
|
6
|
+
* AWS-recommended default alarm configuration for VPC interface endpoints.
|
|
7
|
+
*
|
|
8
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#PrivateLinkEndpoints
|
|
9
|
+
*/
|
|
10
|
+
exports.INTERFACE_ENDPOINT_ALARM_DEFAULTS = {
|
|
11
|
+
enabled: true,
|
|
12
|
+
/**
|
|
13
|
+
* Any sustained packet drop at the endpoint signals a connectivity or
|
|
14
|
+
* configuration problem — an unhealthy endpoint service, a security group
|
|
15
|
+
* blocking traffic, or jumbo frames exceeding the 8,500-byte PrivateLink
|
|
16
|
+
* MTU. Five consecutive 1-minute periods avoids false alarms from isolated
|
|
17
|
+
* oversized packets while still catching persistent issues quickly.
|
|
18
|
+
*
|
|
19
|
+
* @see https://docs.aws.amazon.com/vpc/latest/privatelink/privatelink-troubleshoot.html
|
|
20
|
+
*/
|
|
21
|
+
packetsDropped: {
|
|
22
|
+
threshold: 0,
|
|
23
|
+
evaluationPeriods: 5,
|
|
24
|
+
datapointsToAlarm: 5,
|
|
25
|
+
treatMissingData: aws_cloudwatch_1.TreatMissingData.NOT_BREACHING,
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
//# 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,+DAA8D;AAQ9D;;;;GAIG;AACU,QAAA,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,iCAAgB,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,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createInterfaceEndpointAlarms = createInterfaceEndpointAlarms;
|
|
4
|
+
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
5
|
+
const aws_cloudwatch_1 = require("aws-cdk-lib/aws-cloudwatch");
|
|
6
|
+
const cloudwatch_1 = require("@composurecdk/cloudwatch");
|
|
7
|
+
const interface_endpoint_alarm_defaults_js_1 = require("./interface-endpoint-alarm-defaults.js");
|
|
8
|
+
const PACKETS_DROPPED_PERIOD = aws_cdk_lib_1.Duration.minutes(1);
|
|
9
|
+
const PACKETS_DROPPED_PERIOD_LABEL = `${String(PACKETS_DROPPED_PERIOD.toMinutes())} minute`;
|
|
10
|
+
function endpointMetric(endpoint, metricName, statistic, period) {
|
|
11
|
+
return new aws_cloudwatch_1.Metric({
|
|
12
|
+
namespace: "AWS/PrivateLinkEndpoints",
|
|
13
|
+
metricName,
|
|
14
|
+
dimensionsMap: { "VPC Endpoint Id": endpoint.vpcEndpointId },
|
|
15
|
+
statistic,
|
|
16
|
+
period,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function resolveEndpointAlarmDefinitions(endpoint, config) {
|
|
20
|
+
if (config?.enabled === false)
|
|
21
|
+
return [];
|
|
22
|
+
const definitions = [];
|
|
23
|
+
if (config?.packetsDropped !== false) {
|
|
24
|
+
const cfg = (0, cloudwatch_1.resolveAlarmConfig)(config?.packetsDropped, interface_endpoint_alarm_defaults_js_1.INTERFACE_ENDPOINT_ALARM_DEFAULTS.packetsDropped);
|
|
25
|
+
definitions.push({
|
|
26
|
+
key: "packetsDropped",
|
|
27
|
+
alarmName: cfg.alarmName,
|
|
28
|
+
metric: endpointMetric(endpoint, "PacketsDropped", aws_cloudwatch_1.Stats.SUM, PACKETS_DROPPED_PERIOD),
|
|
29
|
+
threshold: cfg.threshold,
|
|
30
|
+
comparisonOperator: aws_cloudwatch_1.ComparisonOperator.GREATER_THAN_THRESHOLD,
|
|
31
|
+
evaluationPeriods: cfg.evaluationPeriods,
|
|
32
|
+
datapointsToAlarm: cfg.datapointsToAlarm,
|
|
33
|
+
treatMissingData: cfg.treatMissingData,
|
|
34
|
+
description: `VPC interface endpoint is dropping packets — possible endpoint service unhealthy, ` +
|
|
35
|
+
`security group blocking traffic, or packets exceeding the 8,500-byte PrivateLink MTU. ` +
|
|
36
|
+
`Threshold: > ${String(cfg.threshold)} (sum) over ` +
|
|
37
|
+
`${String(cfg.evaluationPeriods)} x ${PACKETS_DROPPED_PERIOD_LABEL}.`,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return definitions;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Creates AWS-recommended CloudWatch alarms for a VPC interface endpoint,
|
|
44
|
+
* merging recommended definitions with any custom alarm builders.
|
|
45
|
+
*
|
|
46
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#PrivateLinkEndpoints
|
|
47
|
+
*/
|
|
48
|
+
function createInterfaceEndpointAlarms(scope, id, endpoint, config, customAlarms = []) {
|
|
49
|
+
if (config === false)
|
|
50
|
+
return {};
|
|
51
|
+
const enabled = config?.enabled ?? interface_endpoint_alarm_defaults_js_1.INTERFACE_ENDPOINT_ALARM_DEFAULTS.enabled;
|
|
52
|
+
if (!enabled)
|
|
53
|
+
return {};
|
|
54
|
+
const recommended = resolveEndpointAlarmDefinitions(endpoint, config);
|
|
55
|
+
const custom = customAlarms.map((b) => b.resolve(endpoint));
|
|
56
|
+
return (0, cloudwatch_1.createAlarms)(scope, id, [...recommended, ...custom]);
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=interface-endpoint-alarms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface-endpoint-alarms.js","sourceRoot":"","sources":["../../src/interface-endpoint-alarms.ts"],"names":[],"mappings":";;AAkEA,sEAgBC;AAlFD,6CAAuC;AACvC,+DAA2F;AAI3F,yDAAoG;AAEpG,iGAA2F;AAE3F,MAAM,sBAAsB,GAAG,sBAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACnD,MAAM,4BAA4B,GAAG,GAAG,MAAM,CAAC,sBAAsB,CAAC,SAAS,EAAE,CAAC,SAAS,CAAC;AAE5F,SAAS,cAAc,CACrB,QAA8B,EAC9B,UAAkB,EAClB,SAAiB,EACjB,MAAgB;IAEhB,OAAO,IAAI,uBAAM,CAAC;QAChB,SAAS,EAAE,0BAA0B;QACrC,UAAU;QACV,aAAa,EAAE,EAAE,iBAAiB,EAAE,QAAQ,CAAC,aAAa,EAAE;QAC5D,SAAS;QACT,MAAM;KACP,CAAC,CAAC;AACL,CAAC;AAED,SAAS,+BAA+B,CACtC,QAA8B,EAC9B,MAAgD;IAEhD,IAAI,MAAM,EAAE,OAAO,KAAK,KAAK;QAAE,OAAO,EAAE,CAAC;IAEzC,MAAM,WAAW,GAAsB,EAAE,CAAC;IAE1C,IAAI,MAAM,EAAE,cAAc,KAAK,KA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E5D,OAAO,IAAA,yBAAY,EAAC,KAAK,EAAE,EAAE,EAAE,CAAC,GAAG,WAAW,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { type Alarm } from "aws-cdk-lib/aws-cloudwatch";
|
|
2
|
+
import { InterfaceVpcEndpoint, type IConnectable, type InterfaceVpcEndpointProps, type ISecurityGroup, type IVpc, type SecurityGroup } from "aws-cdk-lib/aws-ec2";
|
|
3
|
+
import { type IConstruct } from "constructs";
|
|
4
|
+
import { COPY_STATE, type Lifecycle, type Resolvable } from "@composurecdk/core";
|
|
5
|
+
import { type ITaggedBuilder } from "@composurecdk/cloudformation";
|
|
6
|
+
import { AlarmDefinitionBuilder } from "@composurecdk/cloudwatch";
|
|
7
|
+
import type { InterfaceEndpointAlarmConfig } from "./interface-endpoint-alarm-config.js";
|
|
8
|
+
/**
|
|
9
|
+
* Configuration properties for the interface-endpoint builder.
|
|
10
|
+
*
|
|
11
|
+
* Lifts three CDK props off the props object:
|
|
12
|
+
* - `vpc` — supplied via {@link IInterfaceEndpointBuilder.vpc | .vpc()} so it
|
|
13
|
+
* can accept a {@link Resolvable} for cross-component wiring.
|
|
14
|
+
* - `securityGroups` — supplied via
|
|
15
|
+
* {@link IInterfaceEndpointBuilder.securityGroups | .securityGroups()} so
|
|
16
|
+
* each can be a {@link Resolvable} (typically a sibling
|
|
17
|
+
* `SecurityGroupBuilder`).
|
|
18
|
+
* - `open` — always `false`; ingress is explicit (see the builder docs).
|
|
19
|
+
*/
|
|
20
|
+
export interface InterfaceEndpointBuilderProps extends Omit<InterfaceVpcEndpointProps, "vpc" | "securityGroups" | "open"> {
|
|
21
|
+
/**
|
|
22
|
+
* Configuration for AWS-recommended CloudWatch alarms.
|
|
23
|
+
*
|
|
24
|
+
* By default, the builder creates recommended alarms with sensible
|
|
25
|
+
* thresholds. Individual alarms can be customized or disabled. Set to
|
|
26
|
+
* `false` to disable all alarms.
|
|
27
|
+
*
|
|
28
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#PrivateLinkEndpoints
|
|
29
|
+
*/
|
|
30
|
+
recommendedAlarms?: InterfaceEndpointAlarmConfig | false;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The build output of an {@link IInterfaceEndpointBuilder}.
|
|
34
|
+
*
|
|
35
|
+
* `securityGroup` is present only in **managed mode** — i.e. when the caller
|
|
36
|
+
* did *not* supply `.securityGroups(...)`, so the builder auto-created one. It
|
|
37
|
+
* is exposed for cases where sibling builders need to reference the
|
|
38
|
+
* auto-created SG directly. In **BYO mode** it is `undefined`: the caller
|
|
39
|
+
* already holds refs to the security groups they passed in.
|
|
40
|
+
*/
|
|
41
|
+
export interface InterfaceEndpointBuilderResult {
|
|
42
|
+
endpoint: InterfaceVpcEndpoint;
|
|
43
|
+
securityGroup?: SecurityGroup;
|
|
44
|
+
alarms: Record<string, Alarm>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A fluent builder for a single VPC interface endpoint (AWS PrivateLink).
|
|
48
|
+
*
|
|
49
|
+
* Unlike raw CDK — where interface endpoints exist only as a post-build
|
|
50
|
+
* `vpc.addInterfaceEndpoint(...)` call whose security group is never exposed —
|
|
51
|
+
* this builder is a first-class {@link compose} component. It maps 1:1 to a
|
|
52
|
+
* CDK `InterfaceVpcEndpoint` (one `service` per endpoint); group several into
|
|
53
|
+
* one access policy by pointing them at the same security group.
|
|
54
|
+
*
|
|
55
|
+
* **Security group, two modes:**
|
|
56
|
+
* - *BYO* — call {@link IInterfaceEndpointBuilder.securityGroups | .securityGroups([...])}
|
|
57
|
+
* with security groups you fully manage (typically sibling
|
|
58
|
+
* `SecurityGroupBuilder`s). Full ingress/egress/port control; the builder
|
|
59
|
+
* creates no SG and `securityGroup` is absent from the result.
|
|
60
|
+
* - *Managed shortcut* — omit `.securityGroups()` and the builder auto-creates
|
|
61
|
+
* a closed SG, exposes it on the result, and for each peer you pass to
|
|
62
|
+
* {@link IInterfaceEndpointBuilder.allowDefaultPortFrom} it opens ingress on
|
|
63
|
+
* the managed SG **and** egress on the peer's SG — matching exactly what CDK's
|
|
64
|
+
* `connections.allowDefaultPortFrom(...)` does bidirectionally.
|
|
65
|
+
*
|
|
66
|
+
* The two are mutually exclusive — combining BYO `.securityGroups()` with
|
|
67
|
+
* `.allowDefaultPortFrom()` throws, since the rule would have nowhere it
|
|
68
|
+
* could be applied that the caller isn't already managing.
|
|
69
|
+
*
|
|
70
|
+
* @see https://docs.aws.amazon.com/vpc/latest/privatelink/
|
|
71
|
+
*
|
|
72
|
+
* @example Managed shortcut (the SSM-from-bastion common case)
|
|
73
|
+
* ```ts
|
|
74
|
+
* createInterfaceEndpointBuilder()
|
|
75
|
+
* .vpc(ref<VpcBuilderResult>("network").get("vpc"))
|
|
76
|
+
* .service(InterfaceVpcEndpointAwsService.SSM)
|
|
77
|
+
* .subnets({ subnetType: SubnetType.PRIVATE_ISOLATED })
|
|
78
|
+
* .allowDefaultPortFrom(ref<SecurityGroupBuilderResult>("bastionSg").get("securityGroup"));
|
|
79
|
+
* // result = { endpoint, securityGroup }
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export type IInterfaceEndpointBuilder = ITaggedBuilder<InterfaceEndpointBuilderProps, InterfaceEndpointBuilder>;
|
|
83
|
+
declare class InterfaceEndpointBuilder implements Lifecycle<InterfaceEndpointBuilderResult> {
|
|
84
|
+
#private;
|
|
85
|
+
props: Partial<InterfaceEndpointBuilderProps>;
|
|
86
|
+
/**
|
|
87
|
+
* Sets the VPC the endpoint is created in. Accepts a concrete {@link IVpc}
|
|
88
|
+
* or a {@link Ref} to a sibling {@link IVpcBuilder}.
|
|
89
|
+
*/
|
|
90
|
+
vpc(vpc: Resolvable<IVpc>): this;
|
|
91
|
+
/**
|
|
92
|
+
* Bring-your-own security groups. Each entry is a {@link Resolvable}, so it
|
|
93
|
+
* can be a concrete {@link ISecurityGroup} or a {@link Ref} to a sibling
|
|
94
|
+
* `SecurityGroupBuilder` — giving you full ingress/egress/port control. When
|
|
95
|
+
* set, the builder creates no security group of its own and
|
|
96
|
+
* {@link InterfaceEndpointBuilderResult.securityGroup} is `undefined`.
|
|
97
|
+
*
|
|
98
|
+
* Mutually exclusive with {@link allowDefaultPortFrom}.
|
|
99
|
+
*/
|
|
100
|
+
securityGroups(securityGroups: Resolvable<ISecurityGroup>[]): this;
|
|
101
|
+
/**
|
|
102
|
+
* Managed-SG shortcut: wires `peer` to the auto-created security group via
|
|
103
|
+
* CDK's `endpoint.connections.allowDefaultPortFrom(peer)` — opening ingress
|
|
104
|
+
* on the managed SG from `peer`'s SG **and** egress from `peer`'s SG to the
|
|
105
|
+
* managed SG, on the service's default port (443 for AWS services).
|
|
106
|
+
*
|
|
107
|
+
* Because this delegates to CDK connections, `peer` must be an
|
|
108
|
+
* {@link IConnectable} (e.g. a `SecurityGroup` or `Instance`), not a raw
|
|
109
|
+
* `IPeer` (e.g. `Peer.ipv4(...)`). For CIDR-based rules use BYO mode with
|
|
110
|
+
* an explicit `addIngressRule` on your own {@link SecurityGroupBuilder}.
|
|
111
|
+
*
|
|
112
|
+
* Mutually exclusive with {@link securityGroups}.
|
|
113
|
+
*/
|
|
114
|
+
allowDefaultPortFrom(peer: Resolvable<IConnectable>, description?: string): this;
|
|
115
|
+
/**
|
|
116
|
+
* Adds a custom CloudWatch alarm alongside the recommended ones. The
|
|
117
|
+
* callback receives an {@link AlarmDefinitionBuilder} typed to the
|
|
118
|
+
* `InterfaceVpcEndpoint` construct, giving access to the endpoint at
|
|
119
|
+
* build time for metric dimension wiring.
|
|
120
|
+
*/
|
|
121
|
+
addAlarm(key: string, configure: (alarm: AlarmDefinitionBuilder<InterfaceVpcEndpoint>) => AlarmDefinitionBuilder<InterfaceVpcEndpoint>): this;
|
|
122
|
+
/** @internal — see ADR-0005. */
|
|
123
|
+
[COPY_STATE](target: InterfaceEndpointBuilder): void;
|
|
124
|
+
build(scope: IConstruct, id: string, context?: Record<string, object>): InterfaceEndpointBuilderResult;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Creates a new {@link IInterfaceEndpointBuilder} for a single VPC interface
|
|
128
|
+
* endpoint. The returned builder exposes every
|
|
129
|
+
* {@link InterfaceEndpointBuilderProps} property as a fluent setter/getter,
|
|
130
|
+
* plus `.vpc()`, `.securityGroups()` (BYO), and `.allowDefaultPortFrom()`
|
|
131
|
+
* (managed-SG shortcut).
|
|
132
|
+
*/
|
|
133
|
+
export declare function createInterfaceEndpointBuilder(): IInterfaceEndpointBuilder;
|
|
134
|
+
export {};
|
|
135
|
+
//# sourceMappingURL=interface-endpoint-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface-endpoint-builder.d.ts","sourceRoot":"","sources":["../../src/interface-endpoint-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EACL,oBAAoB,EACpB,KAAK,YAAY,EACjB,KAAK,yBAAyB,EAC9B,KAAK,cAAc,EACnB,KAAK,IAAI,EACT,KAAK,aAAa,EACnB,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;AAClF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAGlE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AAGzF;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,6BAA8B,SAAQ,IAAI,CACzD,yBAAyB,EACzB,KAAK,GAAG,gBAAgB,GAAG,MAAM,CAClC;I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