@composurecdk/ec2 0.6.0 → 0.8.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/README.md +121 -0
- package/dist/commonjs/index.d.ts +14 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +22 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/instance-alarm-config.d.ts.map +1 -0
- package/dist/commonjs/instance-alarm-config.js +3 -0
- package/dist/commonjs/instance-alarm-config.js.map +1 -0
- package/dist/commonjs/instance-alarm-defaults.d.ts.map +1 -0
- package/dist/commonjs/instance-alarm-defaults.js +65 -0
- package/dist/commonjs/instance-alarm-defaults.js.map +1 -0
- package/dist/commonjs/instance-alarms.d.ts.map +1 -0
- package/dist/commonjs/instance-alarms.js +132 -0
- package/dist/commonjs/instance-alarms.js.map +1 -0
- package/dist/{instance-builder.d.ts → commonjs/instance-builder.d.ts} +44 -6
- package/dist/commonjs/instance-builder.d.ts.map +1 -0
- package/dist/commonjs/instance-builder.js +135 -0
- package/dist/commonjs/instance-builder.js.map +1 -0
- package/dist/commonjs/instance-defaults.d.ts.map +1 -0
- package/dist/commonjs/instance-defaults.js +62 -0
- package/dist/commonjs/instance-defaults.js.map +1 -0
- package/dist/commonjs/instance-volume-attachment-config.d.ts +34 -0
- package/dist/commonjs/instance-volume-attachment-config.d.ts.map +1 -0
- package/dist/commonjs/instance-volume-attachment-config.js +3 -0
- package/dist/commonjs/instance-volume-attachment-config.js.map +1 -0
- package/dist/commonjs/instance-volume-attachment-defaults.d.ts +14 -0
- package/dist/commonjs/instance-volume-attachment-defaults.d.ts.map +1 -0
- package/dist/commonjs/instance-volume-attachment-defaults.js +27 -0
- package/dist/commonjs/instance-volume-attachment-defaults.js.map +1 -0
- package/dist/commonjs/instance-volume-attachments.d.ts +59 -0
- package/dist/commonjs/instance-volume-attachments.d.ts.map +1 -0
- package/dist/commonjs/instance-volume-attachments.js +107 -0
- package/dist/commonjs/instance-volume-attachments.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/volume-alarm-config.d.ts +35 -0
- package/dist/commonjs/volume-alarm-config.d.ts.map +1 -0
- package/dist/commonjs/volume-alarm-config.js +3 -0
- package/dist/commonjs/volume-alarm-config.js.map +1 -0
- package/dist/commonjs/volume-alarm-defaults.d.ts +17 -0
- package/dist/commonjs/volume-alarm-defaults.d.ts.map +1 -0
- package/dist/commonjs/volume-alarm-defaults.js +30 -0
- package/dist/commonjs/volume-alarm-defaults.js.map +1 -0
- package/dist/commonjs/volume-alarms.d.ts +29 -0
- package/dist/commonjs/volume-alarms.d.ts.map +1 -0
- package/dist/commonjs/volume-alarms.js +92 -0
- package/dist/commonjs/volume-alarms.js.map +1 -0
- package/dist/commonjs/volume-builder.d.ts +171 -0
- package/dist/commonjs/volume-builder.d.ts.map +1 -0
- package/dist/commonjs/volume-builder.js +98 -0
- package/dist/commonjs/volume-builder.js.map +1 -0
- package/dist/commonjs/volume-defaults.d.ts +15 -0
- package/dist/commonjs/volume-defaults.d.ts.map +1 -0
- package/dist/commonjs/volume-defaults.js +50 -0
- package/dist/commonjs/volume-defaults.js.map +1 -0
- package/dist/{vpc-builder.d.ts → commonjs/vpc-builder.d.ts} +3 -2
- package/dist/commonjs/vpc-builder.d.ts.map +1 -0
- package/dist/commonjs/vpc-builder.js +82 -0
- package/dist/commonjs/vpc-builder.js.map +1 -0
- package/dist/commonjs/vpc-defaults.d.ts.map +1 -0
- package/dist/commonjs/vpc-defaults.js +58 -0
- package/dist/commonjs/vpc-defaults.js.map +1 -0
- package/dist/esm/index.d.ts +14 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/instance-alarm-config.d.ts +62 -0
- package/dist/esm/instance-alarm-config.d.ts.map +1 -0
- package/dist/esm/instance-alarm-config.js.map +1 -0
- package/dist/esm/instance-alarm-defaults.d.ts +20 -0
- package/dist/esm/instance-alarm-defaults.d.ts.map +1 -0
- package/dist/esm/instance-alarm-defaults.js.map +1 -0
- package/dist/esm/instance-alarms.d.ts +28 -0
- package/dist/esm/instance-alarms.d.ts.map +1 -0
- package/dist/esm/instance-alarms.js.map +1 -0
- package/dist/esm/instance-builder.d.ts +223 -0
- package/dist/esm/instance-builder.d.ts.map +1 -0
- package/dist/{instance-builder.js → esm/instance-builder.js} +49 -4
- package/dist/esm/instance-builder.js.map +1 -0
- package/dist/esm/instance-defaults.d.ts +14 -0
- package/dist/esm/instance-defaults.d.ts.map +1 -0
- package/dist/esm/instance-defaults.js.map +1 -0
- package/dist/esm/instance-volume-attachment-config.d.ts +34 -0
- package/dist/esm/instance-volume-attachment-config.d.ts.map +1 -0
- package/dist/esm/instance-volume-attachment-config.js +2 -0
- package/dist/esm/instance-volume-attachment-config.js.map +1 -0
- package/dist/esm/instance-volume-attachment-defaults.d.ts +14 -0
- package/dist/esm/instance-volume-attachment-defaults.d.ts.map +1 -0
- package/dist/esm/instance-volume-attachment-defaults.js +24 -0
- package/dist/esm/instance-volume-attachment-defaults.js.map +1 -0
- package/dist/esm/instance-volume-attachments.d.ts +59 -0
- package/dist/esm/instance-volume-attachments.d.ts.map +1 -0
- package/dist/esm/instance-volume-attachments.js +104 -0
- package/dist/esm/instance-volume-attachments.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/volume-alarm-config.d.ts +35 -0
- package/dist/esm/volume-alarm-config.d.ts.map +1 -0
- package/dist/esm/volume-alarm-config.js +2 -0
- package/dist/esm/volume-alarm-config.js.map +1 -0
- package/dist/esm/volume-alarm-defaults.d.ts +17 -0
- package/dist/esm/volume-alarm-defaults.d.ts.map +1 -0
- package/dist/esm/volume-alarm-defaults.js +27 -0
- package/dist/esm/volume-alarm-defaults.js.map +1 -0
- package/dist/esm/volume-alarms.d.ts +29 -0
- package/dist/esm/volume-alarms.d.ts.map +1 -0
- package/dist/esm/volume-alarms.js +88 -0
- package/dist/esm/volume-alarms.js.map +1 -0
- package/dist/esm/volume-builder.d.ts +171 -0
- package/dist/esm/volume-builder.d.ts.map +1 -0
- package/dist/esm/volume-builder.js +95 -0
- package/dist/esm/volume-builder.js.map +1 -0
- package/dist/esm/volume-defaults.d.ts +15 -0
- package/dist/esm/volume-defaults.d.ts.map +1 -0
- package/dist/esm/volume-defaults.js +47 -0
- package/dist/esm/volume-defaults.js.map +1 -0
- package/dist/esm/vpc-builder.d.ts +110 -0
- package/dist/esm/vpc-builder.d.ts.map +1 -0
- package/dist/{vpc-builder.js → esm/vpc-builder.js} +2 -2
- package/dist/esm/vpc-builder.js.map +1 -0
- package/dist/esm/vpc-defaults.d.ts +15 -0
- package/dist/esm/vpc-defaults.d.ts.map +1 -0
- package/dist/esm/vpc-defaults.js.map +1 -0
- package/package.json +36 -17
- package/dist/index.d.ts +0 -7
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -6
- package/dist/index.js.map +0 -1
- package/dist/instance-alarm-config.d.ts.map +0 -1
- package/dist/instance-alarm-config.js.map +0 -1
- package/dist/instance-alarm-defaults.d.ts.map +0 -1
- package/dist/instance-alarm-defaults.js.map +0 -1
- package/dist/instance-alarms.d.ts.map +0 -1
- package/dist/instance-alarms.js.map +0 -1
- package/dist/instance-builder.d.ts.map +0 -1
- package/dist/instance-builder.js.map +0 -1
- package/dist/instance-defaults.d.ts.map +0 -1
- package/dist/instance-defaults.js.map +0 -1
- package/dist/vpc-builder.d.ts.map +0 -1
- package/dist/vpc-builder.js.map +0 -1
- package/dist/vpc-defaults.d.ts.map +0 -1
- package/dist/vpc-defaults.js.map +0 -1
- /package/dist/{instance-alarm-config.d.ts → commonjs/instance-alarm-config.d.ts} +0 -0
- /package/dist/{instance-alarm-defaults.d.ts → commonjs/instance-alarm-defaults.d.ts} +0 -0
- /package/dist/{instance-alarms.d.ts → commonjs/instance-alarms.d.ts} +0 -0
- /package/dist/{instance-defaults.d.ts → commonjs/instance-defaults.d.ts} +0 -0
- /package/dist/{vpc-defaults.d.ts → commonjs/vpc-defaults.d.ts} +0 -0
- /package/dist/{instance-alarm-config.js → esm/instance-alarm-config.js} +0 -0
- /package/dist/{instance-alarm-defaults.js → esm/instance-alarm-defaults.js} +0 -0
- /package/dist/{instance-alarms.js → esm/instance-alarms.js} +0 -0
- /package/dist/{instance-defaults.js → esm/instance-defaults.js} +0 -0
- /package/dist/{vpc-defaults.js → esm/vpc-defaults.js} +0 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { Duration, Token } from "aws-cdk-lib";
|
|
2
|
+
import { ComparisonOperator, Metric, Stats } from "aws-cdk-lib/aws-cloudwatch";
|
|
3
|
+
import { CfnVolumeAttachment, } from "aws-cdk-lib/aws-ec2";
|
|
4
|
+
import { resolve } from "@composurecdk/core";
|
|
5
|
+
import { createAlarms, resolveAlarmConfig } from "@composurecdk/cloudwatch";
|
|
6
|
+
import { VOLUME_ATTACHMENT_ALARM_DEFAULTS } from "./instance-volume-attachment-defaults.js";
|
|
7
|
+
const STALLED_IO_PERIOD = Duration.minutes(1);
|
|
8
|
+
const STALLED_IO_PERIOD_LABEL = `${String(STALLED_IO_PERIOD.toMinutes())} minute`;
|
|
9
|
+
function resolveInstanceAz(instanceProps) {
|
|
10
|
+
if (instanceProps.availabilityZone && !Token.isUnresolved(instanceProps.availabilityZone)) {
|
|
11
|
+
return instanceProps.availabilityZone;
|
|
12
|
+
}
|
|
13
|
+
let selected;
|
|
14
|
+
try {
|
|
15
|
+
selected = instanceProps.vpc.selectSubnets(instanceProps.vpcSubnets);
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
// selectSubnets() throws for several unrelated reasons (no matching subnets,
|
|
19
|
+
// unresolved tokens, etc.). The validation is best-effort — if we can't
|
|
20
|
+
// resolve a concrete AZ, fall through and let CFN surface the real failure.
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
return selected.availabilityZones.find((az) => !Token.isUnresolved(az));
|
|
24
|
+
}
|
|
25
|
+
function unwrapVolume(resolved) {
|
|
26
|
+
if ("volumeId" in resolved) {
|
|
27
|
+
return resolved;
|
|
28
|
+
}
|
|
29
|
+
return resolved.volume;
|
|
30
|
+
}
|
|
31
|
+
function volumeAttachmentMetric(volume, instance, metricName, statistic, period) {
|
|
32
|
+
return new Metric({
|
|
33
|
+
namespace: "AWS/EBS",
|
|
34
|
+
metricName,
|
|
35
|
+
dimensionsMap: {
|
|
36
|
+
VolumeId: volume.volumeId,
|
|
37
|
+
InstanceId: instance.instanceId,
|
|
38
|
+
},
|
|
39
|
+
statistic,
|
|
40
|
+
period,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function resolveVolumeAttachmentAlarmDefinitions(attachmentKey, volume, instance, config) {
|
|
44
|
+
if (config === false)
|
|
45
|
+
return [];
|
|
46
|
+
const enabled = config?.enabled ?? VOLUME_ATTACHMENT_ALARM_DEFAULTS.enabled;
|
|
47
|
+
if (!enabled)
|
|
48
|
+
return [];
|
|
49
|
+
if (config?.volumeStalledIo === false)
|
|
50
|
+
return [];
|
|
51
|
+
const cfg = resolveAlarmConfig(config?.volumeStalledIo, VOLUME_ATTACHMENT_ALARM_DEFAULTS.volumeStalledIo);
|
|
52
|
+
return [
|
|
53
|
+
{
|
|
54
|
+
key: `${attachmentKey}.volumeStalledIo`,
|
|
55
|
+
alarmName: cfg.alarmName,
|
|
56
|
+
metric: volumeAttachmentMetric(volume, instance, "VolumeStalledIOCheck", Stats.MAXIMUM, STALLED_IO_PERIOD),
|
|
57
|
+
threshold: cfg.threshold,
|
|
58
|
+
comparisonOperator: ComparisonOperator.GREATER_THAN_OR_EQUAL_TO_THRESHOLD,
|
|
59
|
+
evaluationPeriods: cfg.evaluationPeriods,
|
|
60
|
+
datapointsToAlarm: cfg.datapointsToAlarm,
|
|
61
|
+
treatMissingData: cfg.treatMissingData,
|
|
62
|
+
description: `EBS volume attachment "${attachmentKey}" is reporting a stalled I/O condition. ` +
|
|
63
|
+
`Threshold: >= ${String(cfg.threshold)} (max) over ${String(cfg.evaluationPeriods)} x ${STALLED_IO_PERIOD_LABEL}. ` +
|
|
64
|
+
`Note: VolumeStalledIOCheck is published only for Nitro-instance attachments.`,
|
|
65
|
+
},
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Creates a {@link CfnVolumeAttachment} for each pending attachment and
|
|
70
|
+
* (when configured) the per-attachment recommended alarms. Synth-time AZ
|
|
71
|
+
* alignment is validated when both the volume's AZ and the instance's
|
|
72
|
+
* effective AZ are concrete strings.
|
|
73
|
+
*
|
|
74
|
+
* @returns The created `CfnVolumeAttachment`s keyed by attachment key,
|
|
75
|
+
* plus the per-attachment alarms keyed by `${attachmentKey}.${alarmKey}`
|
|
76
|
+
* so they can be flat-merged into the instance's `alarms` record.
|
|
77
|
+
*/
|
|
78
|
+
export function createVolumeAttachments(scope, id, instance, instanceProps, attachments, context) {
|
|
79
|
+
const attachmentRecords = {};
|
|
80
|
+
const alarmDefinitions = [];
|
|
81
|
+
// Resolve the instance AZ once — it is the same for every attachment.
|
|
82
|
+
const instanceAz = attachments.length > 0 ? resolveInstanceAz(instanceProps) : undefined;
|
|
83
|
+
for (const pending of attachments) {
|
|
84
|
+
const resolved = resolve(pending.volumeRef, context);
|
|
85
|
+
const volume = unwrapVolume(resolved);
|
|
86
|
+
if (instanceAz !== undefined && !Token.isUnresolved(volume.availabilityZone)) {
|
|
87
|
+
if (volume.availabilityZone !== instanceAz) {
|
|
88
|
+
throw new Error(`attachVolume "${pending.key}": volume is in availability zone "${volume.availabilityZone}" ` +
|
|
89
|
+
`but the instance is in "${instanceAz}". ` +
|
|
90
|
+
`EBS volumes can only attach to instances in the same AZ.`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const attachment = new CfnVolumeAttachment(scope, `${id}${pending.key}Attachment`, {
|
|
94
|
+
device: pending.options.device,
|
|
95
|
+
instanceId: instance.instanceId,
|
|
96
|
+
volumeId: volume.volumeId,
|
|
97
|
+
});
|
|
98
|
+
attachmentRecords[pending.key] = attachment;
|
|
99
|
+
alarmDefinitions.push(...resolveVolumeAttachmentAlarmDefinitions(pending.key, volume, instance, pending.options.recommendedAlarms));
|
|
100
|
+
}
|
|
101
|
+
const alarms = alarmDefinitions.length > 0 ? createAlarms(scope, id, alarmDefinitions) : {};
|
|
102
|
+
return { attachments: attachmentRecords, alarms };
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=instance-volume-attachments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instance-volume-attachments.js","sourceRoot":"","sources":["../../src/instance-volume-attachments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAc,kBAAkB,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAC3F,OAAO,EACL,mBAAmB,GAKpB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,OAAO,EAAmB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAwB,YAAY,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAGlG,OAAO,EAAE,gCAAgC,EAAE,MAAM,0CAA0C,CAAC;AAE5F,MAAM,iBAAiB,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAC9C,MAAM,uBAAuB,GAAG,GAAG,MAAM,CAAC,iBAAiB,CAAC,SAAS,EAAE,CAAC,SAAS,CAAC;AA4ClF,SAAS,iBAAiB,CAAC,aAA4B;IACrD,IAAI,aAAa,CAAC,gBAAgB,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,aAAa,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAC1F,OAAO,aAAa,CAAC,gBAAgB,CAAC;IACxC,CAAC;IAED,IAAI,QAAyB,CAAC;IAC9B,IAAI,CAAC;QACH,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,aAAa,CAAC,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C,MAAM,IAAI,KAAK,CACb,iBAAiB,OAAO,CAAC,GAAG,sCAAsC,MAAM,CAAC,gBAAgB,IAAI;oBAC3F,2BAA2B,UAAU,KAAK;oBAC1C,0DAA0D,CAC7D,CAAC;YACJ,CAAC;QACH,CAAC;QAED,MAAM,UAAU,GAAG,IAAI,mBAAmB,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,YAAY,EAAE;YACjF,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM;YAC9B,UAAU,EAAE,QAAQ,CAAC,UAAU;YAC/B,QAAQ,EAAE,MAAM,CAAC,QAAQ;SAC1B,CAAC,CAAC;QACH,iBAAiB,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC;QAE5C,gBAAgB,CAAC,IAAI,CACnB,GAAG,uCAAuC,CACxC,OAAO,CAAC,GAAG,EACX,MAAM,EACN,QAAQ,EACR,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAClC,CACF,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,EAAE,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5F,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,EAAE,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { AlarmConfig } from "@composurecdk/cloudwatch";
|
|
2
|
+
/**
|
|
3
|
+
* Controls which recommended alarms are created for an EBS volume.
|
|
4
|
+
* All applicable alarms are enabled by default with AWS-recommended
|
|
5
|
+
* thresholds. Set individual alarms to `false` to disable them, or
|
|
6
|
+
* provide an {@link AlarmConfig} to tune thresholds.
|
|
7
|
+
*
|
|
8
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#EBS
|
|
9
|
+
*/
|
|
10
|
+
export interface VolumeAlarmConfig {
|
|
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 a burstable volume's I/O credit balance falls low,
|
|
19
|
+
* indicating the volume is about to be throttled to baseline IOPS or
|
|
20
|
+
* throughput.
|
|
21
|
+
*
|
|
22
|
+
* Only created when the configured `volumeType` is one of the burstable
|
|
23
|
+
* types: `gp2` (IOPS credits), `st1` and `sc1` (throughput credits).
|
|
24
|
+
* For non-burstable types (`gp3`, `io1`, `io2`, `standard`) the metric
|
|
25
|
+
* is not emitted, so the alarm is skipped entirely.
|
|
26
|
+
*
|
|
27
|
+
* Metric: `AWS/EBS BurstBalance`, statistic Average, period 5 minutes.
|
|
28
|
+
* Default threshold: < 20% over 3 consecutive 5-minute windows.
|
|
29
|
+
*
|
|
30
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#EBS
|
|
31
|
+
* @see https://docs.aws.amazon.com/ebs/latest/userguide/general-purpose.html#gp2-volume-performance
|
|
32
|
+
*/
|
|
33
|
+
burstBalance?: AlarmConfig | false;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=volume-alarm-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"volume-alarm-config.d.ts","sourceRoot":"","sources":["../../src/volume-alarm-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;;;;;;;;;;;;OAeG;IACH,YAAY,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC;CACpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"volume-alarm-config.js","sourceRoot":"","sources":["../../src/volume-alarm-config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AlarmConfigDefaults } from "@composurecdk/cloudwatch";
|
|
2
|
+
interface VolumeAlarmDefaults {
|
|
3
|
+
enabled: true;
|
|
4
|
+
burstBalance: AlarmConfigDefaults;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* AWS-recommended default alarm configuration for EBS volumes.
|
|
8
|
+
*
|
|
9
|
+
* Thresholds are sourced from the CloudWatch Best Practice Recommended
|
|
10
|
+
* Alarms guide. Thresholds may reasonably be tuned per-workload; defaults
|
|
11
|
+
* bias toward catching obvious issues without excessive noise.
|
|
12
|
+
*
|
|
13
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#EBS
|
|
14
|
+
*/
|
|
15
|
+
export declare const VOLUME_ALARM_DEFAULTS: VolumeAlarmDefaults;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=volume-alarm-defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"volume-alarm-defaults.d.ts","sourceRoot":"","sources":["../../src/volume-alarm-defaults.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,UAAU,mBAAmB;IAC3B,OAAO,EAAE,IAAI,CAAC;IACd,YAAY,EAAE,mBAAmB,CAAC;CACnC;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,EAAE,mBAgBnC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { TreatMissingData } from "aws-cdk-lib/aws-cloudwatch";
|
|
2
|
+
/**
|
|
3
|
+
* AWS-recommended default alarm configuration for EBS volumes.
|
|
4
|
+
*
|
|
5
|
+
* Thresholds are sourced from the CloudWatch Best Practice Recommended
|
|
6
|
+
* Alarms guide. Thresholds may reasonably be tuned per-workload; defaults
|
|
7
|
+
* bias toward catching obvious issues without excessive noise.
|
|
8
|
+
*
|
|
9
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#EBS
|
|
10
|
+
*/
|
|
11
|
+
export const VOLUME_ALARM_DEFAULTS = {
|
|
12
|
+
enabled: true,
|
|
13
|
+
/**
|
|
14
|
+
* Burst credit balance is a percentage. Below 20% the volume is
|
|
15
|
+
* approaching throttling to baseline performance — early warning to
|
|
16
|
+
* upsize, switch to a non-burstable type (e.g. `gp3`), or investigate
|
|
17
|
+
* unexpectedly heavy I/O. The 3-of-3 evaluation at 5-minute granularity
|
|
18
|
+
* suppresses transient dips around backup windows.
|
|
19
|
+
*/
|
|
20
|
+
burstBalance: {
|
|
21
|
+
threshold: 20,
|
|
22
|
+
evaluationPeriods: 3,
|
|
23
|
+
datapointsToAlarm: 3,
|
|
24
|
+
treatMissingData: TreatMissingData.NOT_BREACHING,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=volume-alarm-defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"volume-alarm-defaults.js","sourceRoot":"","sources":["../../src/volume-alarm-defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAQ9D;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAwB;IACxD,OAAO,EAAE,IAAI;IAEb;;;;;;OAMG;IACH,YAAY,EAAE;QACZ,SAAS,EAAE,EAAE;QACb,iBAAiB,EAAE,CAAC;QACpB,iBAAiB,EAAE,CAAC;QACpB,gBAAgB,EAAE,gBAAgB,CAAC,aAAa;KACjD;CACF,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type Alarm } from "aws-cdk-lib/aws-cloudwatch";
|
|
2
|
+
import { EbsDeviceVolumeType, type Volume } from "aws-cdk-lib/aws-ec2";
|
|
3
|
+
import type { IConstruct } from "constructs";
|
|
4
|
+
import type { AlarmDefinition } from "@composurecdk/cloudwatch";
|
|
5
|
+
import { AlarmDefinitionBuilder } from "@composurecdk/cloudwatch";
|
|
6
|
+
import type { VolumeAlarmConfig } from "./volume-alarm-config.js";
|
|
7
|
+
/**
|
|
8
|
+
* Resolves the recommended alarm configuration into fully-resolved
|
|
9
|
+
* {@link AlarmDefinition}s, applying contextual logic for the
|
|
10
|
+
* burstable-only credit alarm.
|
|
11
|
+
*/
|
|
12
|
+
export declare function resolveVolumeAlarmDefinitions(volume: Volume, config: VolumeAlarmConfig | undefined, volumeType: EbsDeviceVolumeType | undefined): AlarmDefinition[];
|
|
13
|
+
/**
|
|
14
|
+
* Creates AWS-recommended CloudWatch alarms for an EBS volume,
|
|
15
|
+
* merging recommended definitions with any custom alarm builders.
|
|
16
|
+
*
|
|
17
|
+
* @param scope - CDK construct scope for creating alarm constructs.
|
|
18
|
+
* @param id - Base identifier for alarm construct ids.
|
|
19
|
+
* @param volume - The EBS volume to create alarms for.
|
|
20
|
+
* @param config - User-provided alarm configuration, or `false` to disable all.
|
|
21
|
+
* @param volumeType - Resolved volume type, used to gate the contextual
|
|
22
|
+
* burst-balance alarm.
|
|
23
|
+
* @param customAlarms - Custom alarm builders added via `addAlarm()`.
|
|
24
|
+
* @returns A record mapping alarm keys to their created Alarm constructs.
|
|
25
|
+
*
|
|
26
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#EBS
|
|
27
|
+
*/
|
|
28
|
+
export declare function createVolumeAlarms(scope: IConstruct, id: string, volume: Volume, config: VolumeAlarmConfig | false | undefined, volumeType: EbsDeviceVolumeType | undefined, customAlarms?: AlarmDefinitionBuilder<Volume>[]): Record<string, Alarm>;
|
|
29
|
+
//# sourceMappingURL=volume-alarms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"volume-alarms.d.ts","sourceRoot":"","sources":["../../src/volume-alarms.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAqC,MAAM,4BAA4B,CAAC;AAC3F,OAAO,EAAE,mBAAmB,EAAgB,KAAK,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACrF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAoC,MAAM,0BAA0B,CAAC;AACpG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AA4ClE;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,iBAAiB,GAAG,SAAS,EACrC,UAAU,EAAE,mBAAmB,GAAG,SAAS,GAC1C,eAAe,EAAE,CAqBnB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,UAAU,EACjB,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,iBAAiB,GAAG,KAAK,GAAG,SAAS,EAC7C,UAAU,EAAE,mBAAmB,GAAG,SAAS,EAC3C,YAAY,GAAE,sBAAsB,CAAC,MAAM,CAAC,EAAO,GAClD,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAUvB"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Duration } from "aws-cdk-lib";
|
|
2
|
+
import { ComparisonOperator, Metric, Stats } from "aws-cdk-lib/aws-cloudwatch";
|
|
3
|
+
import { EbsDeviceVolumeType } from "aws-cdk-lib/aws-ec2";
|
|
4
|
+
import { createAlarms, resolveAlarmConfig } from "@composurecdk/cloudwatch";
|
|
5
|
+
import { VOLUME_ALARM_DEFAULTS } from "./volume-alarm-defaults.js";
|
|
6
|
+
/**
|
|
7
|
+
* BurstBalance is published at 5-minute granularity for burstable volume
|
|
8
|
+
* types. A shorter period yields missing data rather than higher resolution.
|
|
9
|
+
*
|
|
10
|
+
* @see https://docs.aws.amazon.com/ebs/latest/userguide/using_cloudwatch_ebs.html
|
|
11
|
+
*/
|
|
12
|
+
const BURST_METRIC_PERIOD = Duration.minutes(5);
|
|
13
|
+
const BURST_METRIC_PERIOD_LABEL = `${String(BURST_METRIC_PERIOD.toMinutes())} minute`;
|
|
14
|
+
/**
|
|
15
|
+
* EBS volume types that publish a `BurstBalance` metric. `gp2` accrues IOPS
|
|
16
|
+
* credits; `st1` and `sc1` accrue throughput credits. Other types
|
|
17
|
+
* (`gp3`, `io1`, `io2`, `standard`) have no burst credit model.
|
|
18
|
+
*
|
|
19
|
+
* @see https://docs.aws.amazon.com/ebs/latest/userguide/using_cloudwatch_ebs.html
|
|
20
|
+
*/
|
|
21
|
+
const BURSTABLE_VOLUME_TYPES = new Set([
|
|
22
|
+
EbsDeviceVolumeType.GP2,
|
|
23
|
+
EbsDeviceVolumeType.ST1,
|
|
24
|
+
EbsDeviceVolumeType.SC1,
|
|
25
|
+
]);
|
|
26
|
+
function isBurstableVolumeType(volumeType) {
|
|
27
|
+
return volumeType !== undefined && BURSTABLE_VOLUME_TYPES.has(volumeType);
|
|
28
|
+
}
|
|
29
|
+
function volumeMetric(volume, metricName, statistic, period) {
|
|
30
|
+
return new Metric({
|
|
31
|
+
namespace: "AWS/EBS",
|
|
32
|
+
metricName,
|
|
33
|
+
dimensionsMap: { VolumeId: volume.volumeId },
|
|
34
|
+
statistic,
|
|
35
|
+
period,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Resolves the recommended alarm configuration into fully-resolved
|
|
40
|
+
* {@link AlarmDefinition}s, applying contextual logic for the
|
|
41
|
+
* burstable-only credit alarm.
|
|
42
|
+
*/
|
|
43
|
+
export function resolveVolumeAlarmDefinitions(volume, config, volumeType) {
|
|
44
|
+
if (config?.enabled === false)
|
|
45
|
+
return [];
|
|
46
|
+
const definitions = [];
|
|
47
|
+
if (config?.burstBalance !== false && isBurstableVolumeType(volumeType)) {
|
|
48
|
+
const cfg = resolveAlarmConfig(config?.burstBalance, VOLUME_ALARM_DEFAULTS.burstBalance);
|
|
49
|
+
definitions.push({
|
|
50
|
+
key: "burstBalance",
|
|
51
|
+
alarmName: cfg.alarmName,
|
|
52
|
+
metric: volumeMetric(volume, "BurstBalance", Stats.AVERAGE, BURST_METRIC_PERIOD),
|
|
53
|
+
threshold: cfg.threshold,
|
|
54
|
+
comparisonOperator: ComparisonOperator.LESS_THAN_THRESHOLD,
|
|
55
|
+
evaluationPeriods: cfg.evaluationPeriods,
|
|
56
|
+
datapointsToAlarm: cfg.datapointsToAlarm,
|
|
57
|
+
treatMissingData: cfg.treatMissingData,
|
|
58
|
+
description: `EBS burstable volume burst credit balance is low — baseline-IOPS throttling is imminent. Threshold: < ${String(cfg.threshold)}% (average) over ${String(cfg.evaluationPeriods)} x ${BURST_METRIC_PERIOD_LABEL}.`,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return definitions;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Creates AWS-recommended CloudWatch alarms for an EBS volume,
|
|
65
|
+
* merging recommended definitions with any custom alarm builders.
|
|
66
|
+
*
|
|
67
|
+
* @param scope - CDK construct scope for creating alarm constructs.
|
|
68
|
+
* @param id - Base identifier for alarm construct ids.
|
|
69
|
+
* @param volume - The EBS volume to create alarms for.
|
|
70
|
+
* @param config - User-provided alarm configuration, or `false` to disable all.
|
|
71
|
+
* @param volumeType - Resolved volume type, used to gate the contextual
|
|
72
|
+
* burst-balance alarm.
|
|
73
|
+
* @param customAlarms - Custom alarm builders added via `addAlarm()`.
|
|
74
|
+
* @returns A record mapping alarm keys to their created Alarm constructs.
|
|
75
|
+
*
|
|
76
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#EBS
|
|
77
|
+
*/
|
|
78
|
+
export function createVolumeAlarms(scope, id, volume, config, volumeType, customAlarms = []) {
|
|
79
|
+
if (config === false)
|
|
80
|
+
return {};
|
|
81
|
+
const enabled = config?.enabled ?? VOLUME_ALARM_DEFAULTS.enabled;
|
|
82
|
+
if (!enabled)
|
|
83
|
+
return {};
|
|
84
|
+
const recommended = resolveVolumeAlarmDefinitions(volume, config, volumeType);
|
|
85
|
+
const custom = customAlarms.map((b) => b.resolve(volume));
|
|
86
|
+
return createAlarms(scope, id, [...recommended, ...custom]);
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=volume-alarms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"volume-alarms.js","sourceRoot":"","sources":["../../src/volume-alarms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAc,kBAAkB,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAC3F,OAAO,EAAE,mBAAmB,EAA6B,MAAM,qBAAqB,CAAC;AAGrF,OAAO,EAA0B,YAAY,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEpG,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE;;;;;GAKG;AACH,MAAM,mBAAmB,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAChD,MAAM,yBAAyB,GAAG,GAAG,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,CAAC,SAAS,CAAC;AAEtF;;;;;;GAMG;AACH,MAAM,sBAAsB,GAAqC,IAAI,GAAG,CAAC;IACvE,mBAAmB,CAAC,GAAG;IACvB,mBAAmB,CAAC,GAAG;IACvB,mBAAmB,CAAC,GAAG;CACxB,CAAC,CAAC;AAEH,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AAM,yBAAyB,GAAG;SAC/N,CAAC,CAAC;IACL,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,kBAAkB,CAChC,KAAiB,EACjB,EAAU,EACV,MAAc,EACd,MAA6C,EAC7C,UAA2C,EAC3C,eAAiD,EAAE;IAEnD,IAAI,MAAM,KAAK,KAAK;QAAE,OAAO,EAAE,CAAC;IAEhC,MAAM,OAAO,GAAG,MAAM,EAAE,OAAO,IAAI,qBAAqB,CAAC,OAAO,CAAC;IACjE,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IAExB,MAAM,WAAW,GAAG,6BAA6B,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;IAC9E,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAE1D,OAAO,YAAY,CAAC,KAAK,EAAE,EAAE,EAAE,CAAC,GAAG,WAAW,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { type Alarm } from "aws-cdk-lib/aws-cloudwatch";
|
|
2
|
+
import { Volume, type VolumeProps } from "aws-cdk-lib/aws-ec2";
|
|
3
|
+
import { type IKey } from "aws-cdk-lib/aws-kms";
|
|
4
|
+
import { type IConstruct } from "constructs";
|
|
5
|
+
import { COPY_STATE, type Lifecycle, type Resolvable } from "@composurecdk/core";
|
|
6
|
+
import { type ITaggedBuilder } from "@composurecdk/cloudformation";
|
|
7
|
+
import { AlarmDefinitionBuilder } from "@composurecdk/cloudwatch";
|
|
8
|
+
import type { VolumeAlarmConfig } from "./volume-alarm-config.js";
|
|
9
|
+
/**
|
|
10
|
+
* Configuration properties for the EBS volume builder.
|
|
11
|
+
*
|
|
12
|
+
* Extends the CDK {@link VolumeProps} but lifts the cross-component-wiring
|
|
13
|
+
* props to {@link Resolvable} so they can be supplied as either concrete
|
|
14
|
+
* values or {@link Ref}s to sibling components in a {@link compose}d system:
|
|
15
|
+
*
|
|
16
|
+
* - `availabilityZone` is supplied via the dedicated
|
|
17
|
+
* {@link IVolumeBuilder.availabilityZone | .availabilityZone()} method
|
|
18
|
+
* so it can be wired from a sibling `VpcBuilder`.
|
|
19
|
+
* - `encryptionKey` is exposed on the builder as a `Resolvable<IKey>`
|
|
20
|
+
* setter so a sibling KMS key builder can supply a CMK.
|
|
21
|
+
*
|
|
22
|
+
* Other props (`size`, `volumeType`, `iops`, `throughput`, `enableMultiAttach`,
|
|
23
|
+
* `autoEnableIo`, `removalPolicy`, etc.) are passed through with their CDK
|
|
24
|
+
* types unchanged because they are almost always constructed inline rather
|
|
25
|
+
* than referenced from another component.
|
|
26
|
+
*/
|
|
27
|
+
export interface VolumeBuilderProps extends Omit<VolumeProps, "availabilityZone" | "encryptionKey"> {
|
|
28
|
+
/**
|
|
29
|
+
* Customer-managed KMS key (CMK) used to encrypt the volume.
|
|
30
|
+
*
|
|
31
|
+
* Accepts a concrete {@link IKey} or a {@link Ref} that resolves to one
|
|
32
|
+
* at build time (e.g. a sibling key builder in the same composed system).
|
|
33
|
+
*
|
|
34
|
+
* @default - the account's default EBS KMS key, applied because
|
|
35
|
+
* `encrypted: true` is set in {@link VOLUME_DEFAULTS}.
|
|
36
|
+
*
|
|
37
|
+
* @see https://docs.aws.amazon.com/wellarchitected/latest/security-pillar/sec_protect_data_rest_encrypt.html
|
|
38
|
+
*/
|
|
39
|
+
encryptionKey?: Resolvable<IKey>;
|
|
40
|
+
/**
|
|
41
|
+
* Configuration for AWS-recommended CloudWatch alarms.
|
|
42
|
+
*
|
|
43
|
+
* By default, the builder creates recommended alarms with sensible
|
|
44
|
+
* thresholds for every applicable metric. Individual alarms can be
|
|
45
|
+
* customized or disabled. Set to `false` to disable all alarms.
|
|
46
|
+
*
|
|
47
|
+
* No alarm actions are configured by default since notification methods
|
|
48
|
+
* are user-specific. Access alarms from the build result or use an
|
|
49
|
+
* `afterBuild` hook to apply actions.
|
|
50
|
+
*
|
|
51
|
+
* Contextual alarms (`burstBalance`) are only created when the
|
|
52
|
+
* corresponding volume configuration is present — e.g., a burstable
|
|
53
|
+
* `gp2`/`st1`/`sc1` volume type.
|
|
54
|
+
*
|
|
55
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#EBS
|
|
56
|
+
*/
|
|
57
|
+
recommendedAlarms?: VolumeAlarmConfig | false;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The build output of a {@link IVolumeBuilder}. Contains the CDK constructs
|
|
61
|
+
* created during {@link Lifecycle.build}, keyed by role.
|
|
62
|
+
*/
|
|
63
|
+
export interface VolumeBuilderResult {
|
|
64
|
+
volume: Volume;
|
|
65
|
+
/**
|
|
66
|
+
* CloudWatch alarms created for the volume, keyed by alarm name.
|
|
67
|
+
*
|
|
68
|
+
* Includes both AWS-recommended alarms and any custom alarms added
|
|
69
|
+
* via {@link IVolumeBuilder.addAlarm}. Access individual alarms by
|
|
70
|
+
* key (e.g., `result.alarms.burstBalance`).
|
|
71
|
+
*
|
|
72
|
+
* No alarm actions are configured — apply them via the result or an
|
|
73
|
+
* `afterBuild` hook.
|
|
74
|
+
*
|
|
75
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#EBS
|
|
76
|
+
*/
|
|
77
|
+
alarms: Record<string, Alarm>;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* A fluent builder for configuring and creating an AWS EBS volume.
|
|
81
|
+
*
|
|
82
|
+
* Each configuration property from the CDK {@link VolumeProps} is exposed
|
|
83
|
+
* as an overloaded method: call with a value to set it (returns the builder
|
|
84
|
+
* for chaining), or call with no arguments to read the current value.
|
|
85
|
+
*
|
|
86
|
+
* The `availabilityZone` is set via the dedicated
|
|
87
|
+
* {@link IVolumeBuilder.availabilityZone | .availabilityZone()} method that
|
|
88
|
+
* accepts a {@link Resolvable} value for cross-component wiring (e.g., to
|
|
89
|
+
* a sibling {@link IVpcBuilder}). The `encryptionKey` setter likewise
|
|
90
|
+
* accepts a {@link Resolvable} value so a sibling KMS-key builder's output
|
|
91
|
+
* can be supplied via {@link ref}.
|
|
92
|
+
*
|
|
93
|
+
* The builder implements {@link Lifecycle}, so it can be used directly as a
|
|
94
|
+
* component in a {@link compose | composed system}. When built, it creates
|
|
95
|
+
* an EBS volume with the configured properties and returns a
|
|
96
|
+
* {@link VolumeBuilderResult}.
|
|
97
|
+
*
|
|
98
|
+
* AWS-recommended CloudWatch alarms are created by default. Alarms can be
|
|
99
|
+
* customized or disabled via the `recommendedAlarms` property. Custom
|
|
100
|
+
* alarms can be added via the {@link addAlarm} method.
|
|
101
|
+
*
|
|
102
|
+
* @see https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Volume.html
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```ts
|
|
106
|
+
* const data = createVolumeBuilder()
|
|
107
|
+
* .availabilityZone(ref<VpcBuilderResult>("network").map(r => r.vpc.availabilityZones[0]))
|
|
108
|
+
* .size(Size.gibibytes(50));
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
export type IVolumeBuilder = ITaggedBuilder<VolumeBuilderProps, VolumeBuilder>;
|
|
112
|
+
declare class VolumeBuilder implements Lifecycle<VolumeBuilderResult> {
|
|
113
|
+
#private;
|
|
114
|
+
props: Partial<VolumeBuilderProps>;
|
|
115
|
+
/**
|
|
116
|
+
* Sets the Availability Zone the volume will be created in.
|
|
117
|
+
*
|
|
118
|
+
* Accepts a concrete AZ string or a {@link Ref} that resolves to one at
|
|
119
|
+
* build time. This is how cross-component wiring works — e.g., to a
|
|
120
|
+
* sibling {@link IVpcBuilder} via
|
|
121
|
+
* `ref<VpcBuilderResult>("network").map(r => r.vpc.availabilityZones[0])`.
|
|
122
|
+
*
|
|
123
|
+
* @param availabilityZone - The AZ string or a Ref to one.
|
|
124
|
+
* @returns This builder for chaining.
|
|
125
|
+
*/
|
|
126
|
+
availabilityZone(availabilityZone: Resolvable<string>): this;
|
|
127
|
+
/**
|
|
128
|
+
* Adds a custom CloudWatch alarm to be created alongside the recommended
|
|
129
|
+
* alarms. The provided callback receives an {@link AlarmDefinitionBuilder}
|
|
130
|
+
* scoped to the built {@link Volume}; configure it fluently and return it.
|
|
131
|
+
*
|
|
132
|
+
* @param key - A unique key for the alarm (used to generate the alarm id).
|
|
133
|
+
* @param configure - Callback that configures the alarm definition.
|
|
134
|
+
* @returns This builder for chaining.
|
|
135
|
+
*/
|
|
136
|
+
addAlarm(key: string, configure: (alarm: AlarmDefinitionBuilder<Volume>) => AlarmDefinitionBuilder<Volume>): this;
|
|
137
|
+
/** @internal — see ADR-0005. */
|
|
138
|
+
[COPY_STATE](target: VolumeBuilder): void;
|
|
139
|
+
build(scope: IConstruct, id: string, context?: Record<string, object>): VolumeBuilderResult;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Creates a new {@link IVolumeBuilder} for configuring an AWS EBS volume.
|
|
143
|
+
*
|
|
144
|
+
* This is the entry point for defining an EBS volume component. The
|
|
145
|
+
* returned builder exposes every {@link VolumeBuilderProps} property as a
|
|
146
|
+
* fluent setter/getter, plus
|
|
147
|
+
* {@link IVolumeBuilder.availabilityZone | .availabilityZone()} for
|
|
148
|
+
* cross-component AZ wiring with Ref support. It implements
|
|
149
|
+
* {@link Lifecycle} for use with {@link compose}.
|
|
150
|
+
*
|
|
151
|
+
* @returns A fluent builder for an AWS EBS volume.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```ts
|
|
155
|
+
* const data = createVolumeBuilder()
|
|
156
|
+
* .availabilityZone(ref<VpcBuilderResult>("network").map(r => r.vpc.availabilityZones[0]))
|
|
157
|
+
* .size(Size.gibibytes(50));
|
|
158
|
+
*
|
|
159
|
+
* // Use standalone:
|
|
160
|
+
* const result = data.build(stack, "Data", { network });
|
|
161
|
+
*
|
|
162
|
+
* // Or compose into a system:
|
|
163
|
+
* const system = compose(
|
|
164
|
+
* { network: createVpcBuilder(), data },
|
|
165
|
+
* { network: [], data: ["network"] },
|
|
166
|
+
* );
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
export declare function createVolumeBuilder(): IVolumeBuilder;
|
|
170
|
+
export {};
|
|
171
|
+
//# sourceMappingURL=volume-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"volume-builder.d.ts","sourceRoot":"","sources":["../../src/volume-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAChD,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;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAIlE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAC9C,WAAW,EACX,kBAAkB,GAAG,eAAe,CACrC;IACC;;;;;;;;;;OAUG;IACH,aAAa,CAAC,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;IAEjC;;;;;;;;;;;;;;;;OAgBG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,GAAG,KAAK,CAAC;CAC/C;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IAEf;;;;;;;;;;;OAWG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,MAAM,cAAc,GAAG,cAAc,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC;AAE/E,cAAM,aAAc,YAAW,SAAS,CAAC,mBAAmB,CAAC;;IAC3D,KAAK,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAM;IAIxC;;;;;;;;;;OAUG;IACH,gBAAgB,CAAC,gBAAgB,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,IAAI;IAK5D;;;;;;;;OAQG;IACH,QAAQ,CACN,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,CAAC,KAAK,EAAE,sBAAsB,CAAC,MAAM,CAAC,KAAK,sBAAsB,CAAC,MAAM,CAAC,GACnF,IAAI;IAKP,gCAAgC;IAChC,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI;IAKzC,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,mBAAmB;CAkC5F;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,mBAAmB,IAAI,cAAc,CAEpD"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Volume } from "aws-cdk-lib/aws-ec2";
|
|
2
|
+
import { COPY_STATE, resolve } from "@composurecdk/core";
|
|
3
|
+
import { taggedBuilder } from "@composurecdk/cloudformation";
|
|
4
|
+
import { AlarmDefinitionBuilder } from "@composurecdk/cloudwatch";
|
|
5
|
+
import { createVolumeAlarms } from "./volume-alarms.js";
|
|
6
|
+
import { VOLUME_DEFAULTS } from "./volume-defaults.js";
|
|
7
|
+
class VolumeBuilder {
|
|
8
|
+
props = {};
|
|
9
|
+
#customAlarms = [];
|
|
10
|
+
#availabilityZone;
|
|
11
|
+
/**
|
|
12
|
+
* Sets the Availability Zone the volume will be created in.
|
|
13
|
+
*
|
|
14
|
+
* Accepts a concrete AZ string or a {@link Ref} that resolves to one at
|
|
15
|
+
* build time. This is how cross-component wiring works — e.g., to a
|
|
16
|
+
* sibling {@link IVpcBuilder} via
|
|
17
|
+
* `ref<VpcBuilderResult>("network").map(r => r.vpc.availabilityZones[0])`.
|
|
18
|
+
*
|
|
19
|
+
* @param availabilityZone - The AZ string or a Ref to one.
|
|
20
|
+
* @returns This builder for chaining.
|
|
21
|
+
*/
|
|
22
|
+
availabilityZone(availabilityZone) {
|
|
23
|
+
this.#availabilityZone = availabilityZone;
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Adds a custom CloudWatch alarm to be created alongside the recommended
|
|
28
|
+
* alarms. The provided callback receives an {@link AlarmDefinitionBuilder}
|
|
29
|
+
* scoped to the built {@link Volume}; configure it fluently and return it.
|
|
30
|
+
*
|
|
31
|
+
* @param key - A unique key for the alarm (used to generate the alarm id).
|
|
32
|
+
* @param configure - Callback that configures the alarm definition.
|
|
33
|
+
* @returns This builder for chaining.
|
|
34
|
+
*/
|
|
35
|
+
addAlarm(key, configure) {
|
|
36
|
+
this.#customAlarms.push(configure(new AlarmDefinitionBuilder(key)));
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
/** @internal — see ADR-0005. */
|
|
40
|
+
[COPY_STATE](target) {
|
|
41
|
+
target.#availabilityZone = this.#availabilityZone;
|
|
42
|
+
target.#customAlarms.push(...this.#customAlarms);
|
|
43
|
+
}
|
|
44
|
+
build(scope, id, context) {
|
|
45
|
+
const resolvedAz = this.#availabilityZone
|
|
46
|
+
? resolve(this.#availabilityZone, context)
|
|
47
|
+
: undefined;
|
|
48
|
+
if (resolvedAz === undefined) {
|
|
49
|
+
throw new Error(`VolumeBuilder "${id}" requires an availability zone. ` +
|
|
50
|
+
`Call .availabilityZone() with a string or a Ref to one.`);
|
|
51
|
+
}
|
|
52
|
+
const { recommendedAlarms: alarmConfig, encryptionKey, ...volumeProps } = this.props;
|
|
53
|
+
const mergedProps = {
|
|
54
|
+
...VOLUME_DEFAULTS,
|
|
55
|
+
...volumeProps,
|
|
56
|
+
availabilityZone: resolvedAz,
|
|
57
|
+
...(encryptionKey !== undefined ? { encryptionKey: resolve(encryptionKey, context) } : {}),
|
|
58
|
+
};
|
|
59
|
+
const volume = new Volume(scope, id, mergedProps);
|
|
60
|
+
const alarms = createVolumeAlarms(scope, id, volume, alarmConfig, mergedProps.volumeType, this.#customAlarms);
|
|
61
|
+
return { volume, alarms };
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Creates a new {@link IVolumeBuilder} for configuring an AWS EBS volume.
|
|
66
|
+
*
|
|
67
|
+
* This is the entry point for defining an EBS volume component. The
|
|
68
|
+
* returned builder exposes every {@link VolumeBuilderProps} property as a
|
|
69
|
+
* fluent setter/getter, plus
|
|
70
|
+
* {@link IVolumeBuilder.availabilityZone | .availabilityZone()} for
|
|
71
|
+
* cross-component AZ wiring with Ref support. It implements
|
|
72
|
+
* {@link Lifecycle} for use with {@link compose}.
|
|
73
|
+
*
|
|
74
|
+
* @returns A fluent builder for an AWS EBS volume.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* const data = createVolumeBuilder()
|
|
79
|
+
* .availabilityZone(ref<VpcBuilderResult>("network").map(r => r.vpc.availabilityZones[0]))
|
|
80
|
+
* .size(Size.gibibytes(50));
|
|
81
|
+
*
|
|
82
|
+
* // Use standalone:
|
|
83
|
+
* const result = data.build(stack, "Data", { network });
|
|
84
|
+
*
|
|
85
|
+
* // Or compose into a system:
|
|
86
|
+
* const system = compose(
|
|
87
|
+
* { network: createVpcBuilder(), data },
|
|
88
|
+
* { network: [], data: ["network"] },
|
|
89
|
+
* );
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
export function createVolumeBuilder() {
|
|
93
|
+
return taggedBuilder(VolumeBuilder);
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=volume-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"volume-builder.js","sourceRoot":"","sources":["../../src/volume-builder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AAG/D,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;AAElE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAiHvD,MAAM,aAAa;IACjB,KAAK,GAAgC,EAAE,CAAC;IAC/B,aAAa,GAAqC,EAAE,CAAC;IAC9D,iBAAiB,CAAsB;IAEvC;;;;;;;;;;OAUG;IACH,gBAAgB,CAAC,gBAAoC;QACnD,IAAI,CAAC,iBAAiB,GAAG,gBAAgB,CAAC;QAC1C,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;OAQG;IACH,QAAQ,CACN,GAAW,EACX,SAAoF;QAEpF,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,sBAAsB,CAAS,GAAG,CAAC,CAAC,CAAC,CAAC;QAC5E,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gCAAgC;IAChC,CAAC,UAAU,CAAC,CAAC,MAAqB;QAChC,MAAM,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,CAAC;QAClD,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG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
|
+
* Secure, AWS-recommended defaults applied to every EBS volume built with
|
|
4
|
+
* {@link createVolumeBuilder}. Each property can be individually overridden
|
|
5
|
+
* via the builder's fluent API.
|
|
6
|
+
*
|
|
7
|
+
* Three properties intentionally have no default — they are application-
|
|
8
|
+
* specific and must be supplied explicitly:
|
|
9
|
+
* - `availabilityZone` (via the builder's `.availabilityZone()` method)
|
|
10
|
+
* - `size`
|
|
11
|
+
* - `iops` / `throughput` (only when opting into a volume type that
|
|
12
|
+
* requires them, e.g. `io1`/`io2`)
|
|
13
|
+
*/
|
|
14
|
+
export declare const VOLUME_DEFAULTS: Partial<VolumeProps>;
|
|
15
|
+
//# sourceMappingURL=volume-defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"volume-defaults.d.ts","sourceRoot":"","sources":["../../src/volume-defaults.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAE5E;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,EAAE,OAAO,CAAC,WAAW,CAkChD,CAAC"}
|