@composurecdk/budgets 0.7.0 → 0.8.1
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/dist/commonjs/alarm-config.d.ts.map +1 -0
- package/dist/commonjs/alarm-config.js +3 -0
- package/dist/{alarm-config.js.map → commonjs/alarm-config.js.map} +1 -1
- package/dist/commonjs/budget-alarm-builder.d.ts.map +1 -0
- package/dist/commonjs/budget-alarm-builder.js +149 -0
- package/dist/commonjs/budget-alarm-builder.js.map +1 -0
- package/dist/commonjs/budget-alarms.d.ts.map +1 -0
- package/dist/commonjs/budget-alarms.js +53 -0
- package/dist/commonjs/budget-alarms.js.map +1 -0
- package/dist/commonjs/budget-builder.d.ts.map +1 -0
- package/dist/commonjs/budget-builder.js +170 -0
- package/dist/commonjs/budget-builder.js.map +1 -0
- package/dist/commonjs/currency.d.ts.map +1 -0
- package/dist/commonjs/currency.js +39 -0
- package/dist/commonjs/currency.js.map +1 -0
- package/dist/commonjs/defaults.d.ts.map +1 -0
- package/dist/commonjs/defaults.js +94 -0
- package/dist/commonjs/defaults.js.map +1 -0
- package/dist/commonjs/email.d.ts.map +1 -0
- package/dist/commonjs/email.js +33 -0
- package/dist/commonjs/email.js.map +1 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +18 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/notifications.d.ts.map +1 -0
- package/dist/commonjs/notifications.js +43 -0
- package/dist/commonjs/notifications.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/topic-policy.d.ts.map +1 -0
- package/dist/commonjs/topic-policy.js +45 -0
- package/dist/commonjs/topic-policy.js.map +1 -0
- package/dist/esm/alarm-config.d.ts +61 -0
- package/dist/esm/alarm-config.d.ts.map +1 -0
- package/dist/esm/alarm-config.js.map +1 -0
- package/dist/esm/budget-alarm-builder.d.ts +150 -0
- package/dist/esm/budget-alarm-builder.d.ts.map +1 -0
- package/dist/esm/budget-alarm-builder.js.map +1 -0
- package/dist/esm/budget-alarms.d.ts +22 -0
- package/dist/esm/budget-alarms.d.ts.map +1 -0
- package/dist/esm/budget-alarms.js.map +1 -0
- package/dist/esm/budget-builder.d.ts +192 -0
- package/dist/esm/budget-builder.d.ts.map +1 -0
- package/dist/esm/budget-builder.js.map +1 -0
- package/dist/esm/currency.d.ts +21 -0
- package/dist/esm/currency.d.ts.map +1 -0
- package/dist/esm/currency.js.map +1 -0
- package/dist/esm/defaults.d.ts +57 -0
- package/dist/esm/defaults.d.ts.map +1 -0
- package/dist/esm/defaults.js.map +1 -0
- package/dist/esm/email.d.ts +28 -0
- package/dist/esm/email.d.ts.map +1 -0
- package/dist/esm/email.js.map +1 -0
- package/dist/esm/index.d.ts +8 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/notifications.d.ts +88 -0
- package/dist/esm/notifications.d.ts.map +1 -0
- package/dist/esm/notifications.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/topic-policy.d.ts +20 -0
- package/dist/esm/topic-policy.d.ts.map +1 -0
- package/dist/esm/topic-policy.js.map +1 -0
- package/package.json +36 -18
- package/dist/alarm-config.d.ts.map +0 -1
- package/dist/budget-alarm-builder.d.ts.map +0 -1
- package/dist/budget-alarm-builder.js.map +0 -1
- package/dist/budget-alarms.d.ts.map +0 -1
- package/dist/budget-alarms.js.map +0 -1
- package/dist/budget-builder.d.ts.map +0 -1
- package/dist/budget-builder.js.map +0 -1
- package/dist/currency.d.ts.map +0 -1
- package/dist/currency.js.map +0 -1
- package/dist/defaults.d.ts.map +0 -1
- package/dist/defaults.js.map +0 -1
- package/dist/email.d.ts.map +0 -1
- package/dist/email.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/notifications.d.ts.map +0 -1
- package/dist/notifications.js.map +0 -1
- package/dist/topic-policy.d.ts.map +0 -1
- package/dist/topic-policy.js.map +0 -1
- /package/dist/{alarm-config.d.ts → commonjs/alarm-config.d.ts} +0 -0
- /package/dist/{budget-alarm-builder.d.ts → commonjs/budget-alarm-builder.d.ts} +0 -0
- /package/dist/{budget-alarms.d.ts → commonjs/budget-alarms.d.ts} +0 -0
- /package/dist/{budget-builder.d.ts → commonjs/budget-builder.d.ts} +0 -0
- /package/dist/{currency.d.ts → commonjs/currency.d.ts} +0 -0
- /package/dist/{defaults.d.ts → commonjs/defaults.d.ts} +0 -0
- /package/dist/{email.d.ts → commonjs/email.d.ts} +0 -0
- /package/dist/{index.d.ts → commonjs/index.d.ts} +0 -0
- /package/dist/{notifications.d.ts → commonjs/notifications.d.ts} +0 -0
- /package/dist/{topic-policy.d.ts → commonjs/topic-policy.d.ts} +0 -0
- /package/dist/{alarm-config.js → esm/alarm-config.js} +0 -0
- /package/dist/{budget-alarm-builder.js → esm/budget-alarm-builder.js} +0 -0
- /package/dist/{budget-alarms.js → esm/budget-alarms.js} +0 -0
- /package/dist/{budget-builder.js → esm/budget-builder.js} +0 -0
- /package/dist/{currency.js → esm/currency.js} +0 -0
- /package/dist/{defaults.js → esm/defaults.js} +0 -0
- /package/dist/{email.js → esm/email.js} +0 -0
- /package/dist/{index.js → esm/index.js} +0 -0
- /package/dist/{notifications.js → esm/notifications.js} +0 -0
- /package/dist/{topic-policy.js → esm/topic-policy.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,yDAM6B;AAL3B,wHAAA,mBAAmB,OAAA;AAMrB,qEAKmC;AAJjC,mIAAA,wBAAwB,OAAA;AAK1B,6CAA2E;AAAlE,8GAAA,eAAe,OAAA;AAAE,wHAAA,yBAAyB,OAAA;AAEnD,qDAA+D;AAAtD,6HAAA,0BAA0B,OAAA;AACnC,uCAA+C;AAAtC,iGAAA,KAAK,OAAA;AACd,uDAO4B;AAN1B,sHAAA,kBAAkB,OAAA;AA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BAAiB,EACxB,mBAAmB,EAAE,SAAS,CAAC,kBAAkB,EAAE,GAClD,SAAS,CAAC,mCAAmC,CAU/C"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveSubscribers = resolveSubscribers;
|
|
4
|
+
exports.toCfnNotificationWithSubscribers = toCfnNotificationWithSubscribers;
|
|
5
|
+
const core_1 = require("@composurecdk/core");
|
|
6
|
+
/**
|
|
7
|
+
* Resolve a {@link NotifySubscribers} into the CloudFormation shape for
|
|
8
|
+
* `AWS::Budgets::Budget`'s `Subscribers` array, plus any SNS topic
|
|
9
|
+
* referenced so the caller can create a matching topic policy.
|
|
10
|
+
*
|
|
11
|
+
* The SNS subscriber (if any) is emitted first, followed by emails in
|
|
12
|
+
* declaration order — the order is not load-bearing, but stable output
|
|
13
|
+
* keeps test snapshots steady.
|
|
14
|
+
*/
|
|
15
|
+
function resolveSubscribers(subscribers, context) {
|
|
16
|
+
const cfn = [];
|
|
17
|
+
const snsTopics = [];
|
|
18
|
+
if (subscribers.sns !== undefined) {
|
|
19
|
+
const topic = (0, core_1.resolve)(subscribers.sns, context);
|
|
20
|
+
cfn.push({ address: topic.topicArn, subscriptionType: "SNS" });
|
|
21
|
+
snsTopics.push(topic);
|
|
22
|
+
}
|
|
23
|
+
for (const address of subscribers.emails ?? []) {
|
|
24
|
+
cfn.push({ address, subscriptionType: "EMAIL" });
|
|
25
|
+
}
|
|
26
|
+
return { cfn, snsTopics };
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Convert a {@link NotificationEntry} plus resolved subscribers into the
|
|
30
|
+
* CloudFormation `NotificationWithSubscribersProperty` shape.
|
|
31
|
+
*/
|
|
32
|
+
function toCfnNotificationWithSubscribers(entry, resolvedSubscribers) {
|
|
33
|
+
return {
|
|
34
|
+
notification: {
|
|
35
|
+
notificationType: entry.notificationType,
|
|
36
|
+
threshold: entry.threshold,
|
|
37
|
+
comparisonOperator: entry.comparisonOperator ?? "GREATER_THAN",
|
|
38
|
+
thresholdType: entry.thresholdType ?? "PERCENTAGE",
|
|
39
|
+
},
|
|
40
|
+
subscribers: resolvedSubscribers,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=notifications.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications.js","sourceRoot":"","sources":["../../src/notifications.ts"],"names":[],"mappings":";;AAsFA,gDAkBC;AAMD,4EAaC;AAzHD,6CAA8D;AA2E9D;;;;;;;;GAQG;AACH,SAAgB,kBAAkB,CAChC,WAA8B,EAC9B,OAA+B;IAE/B,MAAM,GAAG,GAAmC,EAAE,CAAC;IAC/C,MAAM,SAAS,GAAa,EAAE,CAAC;IAE/B,IAAI,WAAW,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;QAClC,MAAM,KAAK,GAAG,IAAA,cAAO,EAAC,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAChD,GAAG,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,QAAQ,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC,CAAC;QAC/D,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;IAED,KAAK,MAAM,OAAO,IAAI,WAAW,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;QAC/C,GAAG,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;AAC5B,CAAC;AAED;;;GAGG;AACH,SAAgB,gCAAgC,CAC9C,KAAwB,EACxB,mBAAmD;IAEnD,OAAO;QACL,YAAY,EAAE;YACZ,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;YACxC,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,IAAI,cAAc;YAC9D,aAAa,EAAE,KAAK,CAAC,aAAa,IAAI,YAAY;SACnD;QACD,WAAW,EAAE,mBAAmB;KACjC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topic-policy.d.ts","sourceRoot":"","sources":["../../src/topic-policy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,UAAU,EACjB,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,MAAM,EAAE,GACf,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CA2B7B"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createBudgetsTopicPolicies = createBudgetsTopicPolicies;
|
|
4
|
+
const aws_iam_1 = require("aws-cdk-lib/aws-iam");
|
|
5
|
+
const aws_sns_1 = require("aws-cdk-lib/aws-sns");
|
|
6
|
+
/**
|
|
7
|
+
* Create an `AWS::SNS::TopicPolicy` granting the AWS Budgets service
|
|
8
|
+
* principal (`budgets.amazonaws.com`) permission to publish to each of
|
|
9
|
+
* the supplied topics.
|
|
10
|
+
*
|
|
11
|
+
* Without this policy, a budget notification configured with an SNS
|
|
12
|
+
* subscriber will silently fail to deliver — one of the most common
|
|
13
|
+
* footguns when wiring Budgets to SNS by hand. The builder wires it up
|
|
14
|
+
* automatically whenever at least one `SNS` subscriber is configured.
|
|
15
|
+
*
|
|
16
|
+
* Each topic gets its own `TopicPolicy` construct, keyed by the topic's
|
|
17
|
+
* fully-qualified CDK node path, so callers can inspect or extend them
|
|
18
|
+
* via the build result.
|
|
19
|
+
*
|
|
20
|
+
* @see https://docs.aws.amazon.com/cost-management/latest/userguide/budgets-sns-policy.html
|
|
21
|
+
*/
|
|
22
|
+
function createBudgetsTopicPolicies(scope, id, topics) {
|
|
23
|
+
const policies = {};
|
|
24
|
+
const seen = new Set();
|
|
25
|
+
for (const topic of topics) {
|
|
26
|
+
const key = topic.node.path;
|
|
27
|
+
if (seen.has(key))
|
|
28
|
+
continue;
|
|
29
|
+
seen.add(key);
|
|
30
|
+
const policy = new aws_sns_1.TopicPolicy(scope, `${id}TopicPolicy${topic.node.addr}`, {
|
|
31
|
+
topics: [topic],
|
|
32
|
+
policyDocument: undefined,
|
|
33
|
+
});
|
|
34
|
+
policy.document.addStatements(new aws_iam_1.PolicyStatement({
|
|
35
|
+
sid: "AllowBudgetsPublish",
|
|
36
|
+
effect: aws_iam_1.Effect.ALLOW,
|
|
37
|
+
principals: [new aws_iam_1.ServicePrincipal("budgets.amazonaws.com")],
|
|
38
|
+
actions: ["SNS:Publish"],
|
|
39
|
+
resources: [topic.topicArn],
|
|
40
|
+
}));
|
|
41
|
+
policies[key] = policy;
|
|
42
|
+
}
|
|
43
|
+
return policies;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=topic-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topic-policy.js","sourceRoot":"","sources":["../../src/topic-policy.ts"],"names":[],"mappings":";;AAoBA,gEA+BC;AAnDD,iDAAgF;AAChF,iDAA+D;AAG/D;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,0BAA0B,CACxC,KAAiB,EACjB,EAAU,EACV,MAAgB;IAEhB,MAAM,QAAQ,GAAgC,EAAE,CAAC;IACjD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAE/B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;QAC5B,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,SAAS;QAC5B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAEd,MAAM,MAAM,GAAG,IAAI,qBAAW,CAAC,KAAK,EAAE,GAAG,EAAE,cAAc,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE;YAC1E,MAAM,EAAE,CAAC,KAAK,CAAC;YACf,cAAc,EAAE,SAAS;SAC1B,CAAC,CAAC;QACH,MAAM,CAAC,QAAQ,CAAC,aAAa,CAC3B,IAAI,yBAAe,CAAC;YAClB,GAAG,EAAE,qBAAqB;YAC1B,MAAM,EAAE,gBAAM,CAAC,KAAK;YACpB,UAAU,EAAE,CAAC,IAAI,0BAAgB,CAAC,uBAAuB,CAAC,CAAC;YAC3D,OAAO,EAAE,CAAC,aAAa,CAAC;YACxB,SAAS,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC;SAC5B,CAAC,CACH,CAAC;QAEF,QAAQ,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;IACzB,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { AlarmConfig } from "@composurecdk/cloudwatch";
|
|
2
|
+
/**
|
|
3
|
+
* Extended {@link AlarmConfig} for the account-level `EstimatedCharges`
|
|
4
|
+
* billing alarm.
|
|
5
|
+
*
|
|
6
|
+
* The `EstimatedCharges` metric lives in the `AWS/Billing` namespace and
|
|
7
|
+
* is **only emitted in the `us-east-1` region**, regardless of where
|
|
8
|
+
* your resources run. The builder emits a synth-time warning when the
|
|
9
|
+
* surrounding stack is not in `us-east-1`; for non-`us-east-1` stacks,
|
|
10
|
+
* suppress this alarm with `recommendedAlarms: false` and create the
|
|
11
|
+
* alarm in a `us-east-1` stack via `createBudgetAlarmBuilder` (see
|
|
12
|
+
* ADR-0004).
|
|
13
|
+
*
|
|
14
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/monitor_estimated_charges_with_cloudwatch.html
|
|
15
|
+
*/
|
|
16
|
+
export interface EstimatedChargesAlarmConfig extends AlarmConfig {
|
|
17
|
+
/**
|
|
18
|
+
* The absolute cost threshold (in `currency`) at which the alarm fires.
|
|
19
|
+
* This is a hard monetary value, **not** a percentage of the budget.
|
|
20
|
+
*/
|
|
21
|
+
threshold: number;
|
|
22
|
+
/**
|
|
23
|
+
* ISO 4217 currency code that the `EstimatedCharges` metric is
|
|
24
|
+
* emitted in. AWS emits the metric with a `Currency` dimension that
|
|
25
|
+
* must match your billing currency.
|
|
26
|
+
*
|
|
27
|
+
* @default "USD"
|
|
28
|
+
*/
|
|
29
|
+
currency?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Controls which recommended CloudWatch alarms are created for an AWS
|
|
33
|
+
* Budget.
|
|
34
|
+
*
|
|
35
|
+
* AWS Budgets itself does not publish per-budget CloudWatch metrics.
|
|
36
|
+
* The recommended-alarm surface therefore mirrors the well-architected
|
|
37
|
+
* cost-monitoring pattern: a CloudWatch alarm on the account-level
|
|
38
|
+
* `AWS/Billing EstimatedCharges` metric that fires when total estimated
|
|
39
|
+
* charges cross a hard threshold.
|
|
40
|
+
*
|
|
41
|
+
* Off by default — the alarm only emits data when its stack is deployed
|
|
42
|
+
* to `us-east-1`, so callers must opt in explicitly.
|
|
43
|
+
*
|
|
44
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/monitor_estimated_charges_with_cloudwatch.html
|
|
45
|
+
*/
|
|
46
|
+
export interface BudgetAlarmConfig {
|
|
47
|
+
/**
|
|
48
|
+
* Master switch.
|
|
49
|
+
* @default false
|
|
50
|
+
*/
|
|
51
|
+
enabled?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Configuration for the `EstimatedCharges` billing alarm.
|
|
54
|
+
*
|
|
55
|
+
* Pass `false` to disable, or supply an
|
|
56
|
+
* {@link EstimatedChargesAlarmConfig} to enable with a specific
|
|
57
|
+
* monetary threshold.
|
|
58
|
+
*/
|
|
59
|
+
estimatedCharges?: EstimatedChargesAlarmConfig | false;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=alarm-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alarm-config.d.ts","sourceRoot":"","sources":["../../src/alarm-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,2BAA4B,SAAQ,WAAW;IAC9D;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,2BAA2B,GAAG,KAAK,CAAC;CACxD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alarm-config.js","sourceRoot":"","sources":["../../src/alarm-config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { type CfnBudget } from "aws-cdk-lib/aws-budgets";
|
|
2
|
+
import { type Alarm } from "aws-cdk-lib/aws-cloudwatch";
|
|
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 { BudgetAlarmConfig } from "./alarm-config.js";
|
|
8
|
+
import type { BudgetBuilderResult } from "./budget-builder.js";
|
|
9
|
+
/**
|
|
10
|
+
* Configuration properties for {@link createBudgetAlarmBuilder}.
|
|
11
|
+
*
|
|
12
|
+
* The standalone alarm builder mirrors the alarm surface that
|
|
13
|
+
* {@link createBudgetBuilder} creates by default. It exists so that
|
|
14
|
+
* billing alarms can be created in a different stack from the budget
|
|
15
|
+
* itself — specifically a `us-east-1` stack, since the
|
|
16
|
+
* `AWS/Billing EstimatedCharges` metric is only emitted in `us-east-1`
|
|
17
|
+
* regardless of where the budget is deployed.
|
|
18
|
+
*
|
|
19
|
+
* @see ADR-0004 — Split-alarm builder pattern for fixed-region metrics
|
|
20
|
+
*/
|
|
21
|
+
export interface BudgetAlarmBuilderProps {
|
|
22
|
+
/**
|
|
23
|
+
* Configuration for AWS-recommended CloudWatch alarms.
|
|
24
|
+
*
|
|
25
|
+
* Mirrors {@link BudgetBuilderProps.recommendedAlarms}. Off by default —
|
|
26
|
+
* pass an {@link BudgetAlarmConfig.estimatedCharges} entry to enable
|
|
27
|
+
* the account-level billing alarm. Set to `false` to suppress recommended
|
|
28
|
+
* alarms entirely; custom alarms added via
|
|
29
|
+
* {@link IBudgetAlarmBuilder.addAlarm} are unaffected.
|
|
30
|
+
*
|
|
31
|
+
* No alarm actions are configured by default. Use `alarmActionsPolicy`
|
|
32
|
+
* (or an `afterBuild` hook) to wire SNS or other actions onto the
|
|
33
|
+
* resulting alarms.
|
|
34
|
+
*
|
|
35
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/monitor_estimated_charges_with_cloudwatch.html
|
|
36
|
+
*/
|
|
37
|
+
recommendedAlarms?: BudgetAlarmConfig | false;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The build output of an {@link IBudgetAlarmBuilder}.
|
|
41
|
+
*/
|
|
42
|
+
export interface BudgetAlarmBuilderResult {
|
|
43
|
+
/**
|
|
44
|
+
* The CloudWatch alarms created by this builder, keyed by alarm name.
|
|
45
|
+
* Uses the same key scheme as {@link BudgetBuilderResult.alarms}.
|
|
46
|
+
*/
|
|
47
|
+
alarms: Record<string, Alarm>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A fluent builder for budget-related CloudWatch alarms, decoupled from
|
|
51
|
+
* the budget itself. Use this when the budget lives in a stack outside
|
|
52
|
+
* `us-east-1` — route this builder's component into a `us-east-1` stack
|
|
53
|
+
* via `compose().withStacks()` so the alarms land where the
|
|
54
|
+
* `AWS/Billing EstimatedCharges` metric actually emits.
|
|
55
|
+
*
|
|
56
|
+
* @see {@link createBudgetAlarmBuilder}
|
|
57
|
+
*/
|
|
58
|
+
export type IBudgetAlarmBuilder = ITaggedBuilder<BudgetAlarmBuilderProps, BudgetAlarmBuilder>;
|
|
59
|
+
/**
|
|
60
|
+
* Shared alarm-assembly used by both {@link createBudgetBuilder} (in its
|
|
61
|
+
* own stack) and {@link createBudgetAlarmBuilder} (typically in a separate
|
|
62
|
+
* `us-east-1` stack). Materialises the recommended billing alarm and any
|
|
63
|
+
* user-supplied custom alarms, emits the region warning if the resulting
|
|
64
|
+
* scope is not in `us-east-1`, and creates the alarm constructs.
|
|
65
|
+
*
|
|
66
|
+
* The `target.budget` reference is only needed for custom alarms added
|
|
67
|
+
* via `addAlarm()` — the recommended `EstimatedCharges` alarm is
|
|
68
|
+
* account-level and does not key off the budget itself, so `target` may
|
|
69
|
+
* be omitted when only the recommended alarm is being created.
|
|
70
|
+
*
|
|
71
|
+
* @internal
|
|
72
|
+
*/
|
|
73
|
+
export declare function buildBudgetAlarms(scope: IConstruct, id: string, target: Pick<BudgetBuilderResult, "budget"> | undefined, options?: {
|
|
74
|
+
recommendedAlarms?: BudgetAlarmConfig | false;
|
|
75
|
+
customAlarms?: AlarmDefinitionBuilder<CfnBudget>[];
|
|
76
|
+
}): Record<string, Alarm>;
|
|
77
|
+
declare class BudgetAlarmBuilder implements Lifecycle<BudgetAlarmBuilderResult> {
|
|
78
|
+
#private;
|
|
79
|
+
props: Partial<BudgetAlarmBuilderProps>;
|
|
80
|
+
/**
|
|
81
|
+
* Sets the budget to alarm on. Pass the result of
|
|
82
|
+
* {@link createBudgetBuilder} (or a {@link Ref} to it). The builder
|
|
83
|
+
* reads the underlying `CfnBudget` from the result so custom alarms
|
|
84
|
+
* added via {@link addAlarm} can reference it.
|
|
85
|
+
*
|
|
86
|
+
* Optional when only the recommended `EstimatedCharges` alarm is being
|
|
87
|
+
* created — that alarm is account-level and does not reference any
|
|
88
|
+
* specific budget. Required as soon as you call {@link addAlarm}.
|
|
89
|
+
*
|
|
90
|
+
* Pair with `compose().withStacks()` to route this component into a
|
|
91
|
+
* `us-east-1` stack while the budget itself lives elsewhere — set
|
|
92
|
+
* `crossRegionReferences: true` on both stacks so CDK can wire any
|
|
93
|
+
* cross-stack references automatically.
|
|
94
|
+
*/
|
|
95
|
+
budget(budget: Resolvable<BudgetBuilderResult>): this;
|
|
96
|
+
/**
|
|
97
|
+
* Adds a custom alarm against the budget. The configure callback
|
|
98
|
+
* receives a fresh {@link AlarmDefinitionBuilder} pre-set with the
|
|
99
|
+
* alarm's key; configure metric, threshold, comparison and any other
|
|
100
|
+
* options.
|
|
101
|
+
*
|
|
102
|
+
* The created alarm is materialised in this builder's stack — useful
|
|
103
|
+
* for cross-region setups where you want all billing-related alarms to
|
|
104
|
+
* live with the recommended one.
|
|
105
|
+
*/
|
|
106
|
+
addAlarm(key: string, configure: (alarm: AlarmDefinitionBuilder<CfnBudget>) => AlarmDefinitionBuilder<CfnBudget>): this;
|
|
107
|
+
/** @internal — see ADR-0005. */
|
|
108
|
+
[COPY_STATE](target: BudgetAlarmBuilder): void;
|
|
109
|
+
build(scope: IConstruct, id: string, context?: Record<string, object>): BudgetAlarmBuilderResult;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Creates a new {@link IBudgetAlarmBuilder} for materialising AWS Budget
|
|
113
|
+
* alarms in a stack separate from the budget itself.
|
|
114
|
+
*
|
|
115
|
+
* The recommended use is multi-region deployments: the budget lives in
|
|
116
|
+
* the application's stack (in any region — `AWS::Budgets::Budget` is a
|
|
117
|
+
* global resource), and the alarms must live in a `us-east-1` stack so
|
|
118
|
+
* they can read the `AWS/Billing EstimatedCharges` metric AWS emits
|
|
119
|
+
* there.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```ts
|
|
123
|
+
* compose(
|
|
124
|
+
* {
|
|
125
|
+
* account: createBudgetBuilder()
|
|
126
|
+
* .budgetName("Account")
|
|
127
|
+
* .limit({ amount: 1000 })
|
|
128
|
+
* .recommendedAlarms(false), // suppress alarms in the budget's own stack
|
|
129
|
+
*
|
|
130
|
+
* accountAlarms: createBudgetAlarmBuilder()
|
|
131
|
+
* .budget(ref<BudgetBuilderResult>("account"))
|
|
132
|
+
* .recommendedAlarms({
|
|
133
|
+
* estimatedCharges: { threshold: 1000, currency: "USD" },
|
|
134
|
+
* }),
|
|
135
|
+
* },
|
|
136
|
+
* { account: [], accountAlarms: ["account"] },
|
|
137
|
+
* )
|
|
138
|
+
* .withStacks({
|
|
139
|
+
* account: appStack, // any region — Budgets is a global service
|
|
140
|
+
* accountAlarms: monitoringStack, // us-east-1 — where AWS/Billing metrics live
|
|
141
|
+
* })
|
|
142
|
+
* .build(app, "App");
|
|
143
|
+
* ```
|
|
144
|
+
*
|
|
145
|
+
* Set `crossRegionReferences: true` on both stacks if you reference the
|
|
146
|
+
* budget from custom alarms via `.addAlarm()`.
|
|
147
|
+
*/
|
|
148
|
+
export declare function createBudgetAlarmBuilder(): IBudgetAlarmBuilder;
|
|
149
|
+
export {};
|
|
150
|
+
//# sourceMappingURL=budget-alarm-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"budget-alarm-builder.d.ts","sourceRoot":"","sources":["../../src/budget-alarm-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAExD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,KAAK,SAAS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AAQ,CACN,GAAW,EACX,SAA0F;QAE1F,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,sBAAsB,CAAY,GAAG,CAAC,CAAC,CAAC,CAAC;QAC/E,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gCAAgC;IAChC,CAAC,UAAU,CAAC,CAAC,MAA0B;QACrC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC9B,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC;IACnD,CAAC;IAED,KAAK,CAAC,KAAiB,EAAE,EAAU,EAAE,OAAgC;QACnE,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC/E,OAAO;YACL,MAAM,EAAE,iBAAiB,CAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE;gBAC3C,iBAAiB,EAAE,IAAI,CAAC,KAAK,CAAC,iBAAiB;gBAC/C,YAAY,EAAE,IAAI,CAAC,aAAa;aACjC,CAAC;SACH,CAAC;IACJ,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,UAAU,wBAAwB;IACtC,OAAO,aAAa,CAA8C,kBAAkB,CAAC,CAAC;AACxF,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AlarmDefinition } from "@composurecdk/cloudwatch";
|
|
2
|
+
import type { BudgetAlarmConfig } from "./alarm-config.js";
|
|
3
|
+
/**
|
|
4
|
+
* Resolves the recommended alarm configuration into fully-resolved
|
|
5
|
+
* {@link AlarmDefinition}s for an AWS Budget.
|
|
6
|
+
*
|
|
7
|
+
* AWS Budgets does not publish per-budget CloudWatch metrics — the only
|
|
8
|
+
* recommended alarm is the account-level `AWS/Billing EstimatedCharges`
|
|
9
|
+
* billing alarm. Off by default: callers must pass an
|
|
10
|
+
* {@link BudgetAlarmConfig.estimatedCharges} config to opt in.
|
|
11
|
+
*
|
|
12
|
+
* Period and statistic are fixed at the AWS-recommended values
|
|
13
|
+
* (6 hours, Maximum) and not exposed as configuration knobs — billing
|
|
14
|
+
* metrics only update every ~6 hours, so a shorter period would
|
|
15
|
+
* oversample. Threshold, currency, evaluation periods, datapoints and
|
|
16
|
+
* missing-data behaviour remain user-configurable via
|
|
17
|
+
* {@link EstimatedChargesAlarmConfig}.
|
|
18
|
+
*
|
|
19
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/monitor_estimated_charges_with_cloudwatch.html
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolveBudgetAlarmDefinitions(config: BudgetAlarmConfig | undefined): AlarmDefinition[];
|
|
22
|
+
//# sourceMappingURL=budget-alarms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"budget-alarms.d.ts","sourceRoot":"","sources":["../../src/budget-alarms.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAK3D;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,iBAAiB,GAAG,SAAS,GACpC,eAAe,EAAE,CA0BnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"budget-alarms.js","sourceRoot":"","sources":["../../src/budget-alarms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAG1F,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAE1D,MAAM,qBAAqB,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struct } from "constructs";
|
|
5
|
+
import { COPY_STATE, type IBuilder, type Lifecycle } from "@composurecdk/core";
|
|
6
|
+
import { AlarmDefinitionBuilder } from "@composurecdk/cloudwatch";
|
|
7
|
+
import type { BudgetAlarmConfig } from "./alarm-config.js";
|
|
8
|
+
import { type NotificationEntry, type NotifySubscribers } from "./notifications.js";
|
|
9
|
+
/**
|
|
10
|
+
* Spend limit for a cost or usage budget.
|
|
11
|
+
*/
|
|
12
|
+
export interface BudgetLimit {
|
|
13
|
+
/** Numeric limit. */
|
|
14
|
+
amount: number;
|
|
15
|
+
/**
|
|
16
|
+
* Currency or usage unit. Defaults to
|
|
17
|
+
* {@link BUDGET_DEFAULTS.limitUnit} when omitted.
|
|
18
|
+
*
|
|
19
|
+
* For `COST` budgets, must be a recognised AWS Budgets currency
|
|
20
|
+
* (validated at synth — see {@link DEFAULT_BUDGET_CURRENCIES}). The
|
|
21
|
+
* builder also emits a non-fatal warning when this is anything other
|
|
22
|
+
* than `"USD"`, since the account's billing currency isn't visible
|
|
23
|
+
* at synth and a mismatch is rejected at deploy time.
|
|
24
|
+
*/
|
|
25
|
+
unit?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Configuration properties for the budget builder.
|
|
29
|
+
*/
|
|
30
|
+
export interface BudgetBuilderProps {
|
|
31
|
+
/** Name used for `BudgetName` in the `BudgetData` property. */
|
|
32
|
+
budgetName?: string;
|
|
33
|
+
/**
|
|
34
|
+
* One of `COST`, `USAGE`, `RI_UTILIZATION`, `RI_COVERAGE`,
|
|
35
|
+
* `SAVINGS_PLANS_UTILIZATION`, `SAVINGS_PLANS_COVERAGE`.
|
|
36
|
+
*
|
|
37
|
+
* @default "COST"
|
|
38
|
+
*/
|
|
39
|
+
budgetType?: string;
|
|
40
|
+
/** @default "MONTHLY" */
|
|
41
|
+
timeUnit?: string;
|
|
42
|
+
/** Spend limit (required for COST and USAGE budgets). */
|
|
43
|
+
limit?: BudgetLimit;
|
|
44
|
+
/**
|
|
45
|
+
* CloudFormation `CostFilters` map. Keys are filter dimensions
|
|
46
|
+
* (`Service`, `Region`, `LinkedAccount`, `TagKeyValue`, …) and values
|
|
47
|
+
* are arrays of filter values.
|
|
48
|
+
*/
|
|
49
|
+
costFilters?: Record<string, string[]>;
|
|
50
|
+
/** CloudFormation `CostTypes` passthrough. */
|
|
51
|
+
costTypes?: CfnBudget.CostTypesProperty;
|
|
52
|
+
/**
|
|
53
|
+
* Configuration for the AWS-recommended billing alarm.
|
|
54
|
+
*
|
|
55
|
+
* Off by default — pass an
|
|
56
|
+
* {@link BudgetAlarmConfig.estimatedCharges} entry to opt in. Set to
|
|
57
|
+
* `false` to suppress recommended alarms entirely; custom alarms added
|
|
58
|
+
* via {@link IBudgetBuilder.addAlarm} are unaffected.
|
|
59
|
+
*
|
|
60
|
+
* Note: `AWS/Billing EstimatedCharges` is emitted in `us-east-1` only.
|
|
61
|
+
* If this builder is used outside `us-east-1`, the synthesised alarm
|
|
62
|
+
* will never receive data — the builder emits a synth-time warning.
|
|
63
|
+
* For non-`us-east-1` stacks, suppress this builder's alarms with
|
|
64
|
+
* `recommendedAlarms: false` and create alarms in a `us-east-1` stack
|
|
65
|
+
* via {@link createBudgetAlarmBuilder}.
|
|
66
|
+
*
|
|
67
|
+
* @see BudgetAlarmConfig
|
|
68
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/monitor_estimated_charges_with_cloudwatch.html
|
|
69
|
+
*/
|
|
70
|
+
recommendedAlarms?: BudgetAlarmConfig | false;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The build output of an {@link IBudgetBuilder}.
|
|
74
|
+
*/
|
|
75
|
+
export interface BudgetBuilderResult {
|
|
76
|
+
/** The `AWS::Budgets::Budget` construct. */
|
|
77
|
+
budget: CfnBudget;
|
|
78
|
+
/**
|
|
79
|
+
* `AWS::SNS::TopicPolicy` constructs created automatically for any SNS
|
|
80
|
+
* topic referenced as a notification subscriber, keyed by the topic's
|
|
81
|
+
* fully-qualified node path. Grants `budgets.amazonaws.com` permission
|
|
82
|
+
* to publish.
|
|
83
|
+
*
|
|
84
|
+
* `{}` when no SNS subscribers were configured.
|
|
85
|
+
*/
|
|
86
|
+
topicPolicies: Record<string, TopicPolicy>;
|
|
87
|
+
/**
|
|
88
|
+
* CloudWatch alarms created for the budget.
|
|
89
|
+
*
|
|
90
|
+
* Includes both AWS-recommended alarms (`estimatedCharges`, off by
|
|
91
|
+
* default) and any custom alarms added via
|
|
92
|
+
* {@link IBudgetBuilder.addAlarm}. Empty unless the caller opts in via
|
|
93
|
+
* `recommendedAlarms` or `addAlarm`.
|
|
94
|
+
*
|
|
95
|
+
* No alarm actions are configured — apply them via the result or an
|
|
96
|
+
* `afterBuild` hook.
|
|
97
|
+
*/
|
|
98
|
+
alarms: Record<string, Alarm>;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* A fluent builder for configuring and creating an AWS Budget.
|
|
102
|
+
*
|
|
103
|
+
* Wraps the {@link CfnBudget} L1 construct (the CDK does not ship an L2
|
|
104
|
+
* for Budgets) with well-architected defaults, helpers for the
|
|
105
|
+
* percentage-threshold notification shape, and automatic
|
|
106
|
+
* `AWS::SNS::TopicPolicy` wiring for SNS subscribers.
|
|
107
|
+
*
|
|
108
|
+
* The builder can also create the AWS-recommended `EstimatedCharges`
|
|
109
|
+
* billing alarm; opt in via `recommendedAlarms`. For non-`us-east-1`
|
|
110
|
+
* stacks, route the alarms separately via
|
|
111
|
+
* {@link createBudgetAlarmBuilder}.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```ts
|
|
115
|
+
* createBudgetBuilder()
|
|
116
|
+
* .budgetName("AgentBudget")
|
|
117
|
+
* .limit({ amount: 50 })
|
|
118
|
+
* .notifyOnActual(100, {
|
|
119
|
+
* emails: [email("ops@example.com")],
|
|
120
|
+
* sns: ref("alerts", r => r.topic),
|
|
121
|
+
* })
|
|
122
|
+
* .withRecommendedThresholds({ emails: [email("ops@example.com")] })
|
|
123
|
+
* .build(stack, "AgentBudget");
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
export type IBudgetBuilder = IBuilder<BudgetBuilderProps, BudgetBuilder>;
|
|
127
|
+
declare class BudgetBuilder implements Lifecycle<BudgetBuilderResult> {
|
|
128
|
+
#private;
|
|
129
|
+
props: Partial<BudgetBuilderProps>;
|
|
130
|
+
/**
|
|
131
|
+
* Add a notification that fires when ACTUAL spend crosses the given
|
|
132
|
+
* percentage of the budget limit.
|
|
133
|
+
*
|
|
134
|
+
* @param thresholdPercent - Percentage of the budget limit (e.g. `80`).
|
|
135
|
+
* For absolute-value thresholds, use {@link addNotification} directly.
|
|
136
|
+
* @param subscribers - Up to one SNS topic plus up to ten validated
|
|
137
|
+
* email addresses. AWS Budgets caps each notification at 1 SNS + up
|
|
138
|
+
* to 10 EMAIL subscribers.
|
|
139
|
+
*/
|
|
140
|
+
notifyOnActual(thresholdPercent: number, subscribers: NotifySubscribers): this;
|
|
141
|
+
/**
|
|
142
|
+
* Add a notification that fires when FORECASTED spend crosses the
|
|
143
|
+
* given percentage of the budget limit.
|
|
144
|
+
*
|
|
145
|
+
* @param thresholdPercent - Percentage of the budget limit (e.g. `100`).
|
|
146
|
+
* For absolute-value thresholds, use {@link addNotification} directly.
|
|
147
|
+
* @param subscribers - Up to one SNS topic plus up to ten validated
|
|
148
|
+
* email addresses.
|
|
149
|
+
*/
|
|
150
|
+
notifyOnForecasted(thresholdPercent: number, subscribers: NotifySubscribers): this;
|
|
151
|
+
/**
|
|
152
|
+
* Raw notification passthrough for callers that need the full
|
|
153
|
+
* CloudFormation surface (e.g. absolute-value thresholds).
|
|
154
|
+
*/
|
|
155
|
+
addNotification(entry: NotificationEntry): this;
|
|
156
|
+
/**
|
|
157
|
+
* Apply the well-architected recommended notification thresholds:
|
|
158
|
+
*
|
|
159
|
+
* - `ACTUAL` at 80% — early warning before breach.
|
|
160
|
+
* - `FORECASTED` at 100% — trending-over-budget alert.
|
|
161
|
+
*
|
|
162
|
+
* Must be called with at least one subscriber; the same subscriber
|
|
163
|
+
* set is used for both thresholds.
|
|
164
|
+
*
|
|
165
|
+
* @see https://docs.aws.amazon.com/cost-management/latest/userguide/budgets-best-practices.html
|
|
166
|
+
*/
|
|
167
|
+
withRecommendedThresholds(subscribers: NotifySubscribers): this;
|
|
168
|
+
/**
|
|
169
|
+
* Adds a custom CloudWatch alarm against the budget. The configure
|
|
170
|
+
* callback receives a fresh {@link AlarmDefinitionBuilder} pre-set with
|
|
171
|
+
* the alarm's key; configure metric, threshold, comparison and any
|
|
172
|
+
* other options.
|
|
173
|
+
*
|
|
174
|
+
* Custom alarms are materialised in this builder's stack alongside any
|
|
175
|
+
* recommended alarms. Like the recommended `EstimatedCharges` alarm,
|
|
176
|
+
* custom alarms on `AWS/Billing` metrics will only fire when this
|
|
177
|
+
* stack is in `us-east-1` — the builder emits the same synth-time
|
|
178
|
+
* warning (`@composurecdk/budgets:alarm-region`) when used elsewhere.
|
|
179
|
+
* For non-`us-east-1` stacks, route alarms via
|
|
180
|
+
* {@link createBudgetAlarmBuilder} into a `us-east-1` stack.
|
|
181
|
+
*/
|
|
182
|
+
addAlarm(key: string, configure: (alarm: AlarmDefinitionBuilder<CfnBudget>) => AlarmDefinitionBuilder<CfnBudget>): this;
|
|
183
|
+
/** @internal — see ADR-0005. */
|
|
184
|
+
[COPY_STATE](target: BudgetBuilder): void;
|
|
185
|
+
build(scope: IConstruct, id: string, context?: Record<string, object>): BudgetBuilderResult;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Creates a new {@link IBudgetBuilder} for configuring an AWS Budget.
|
|
189
|
+
*/
|
|
190
|
+
export declare function createBudgetBuilder(): IBudgetBuilder;
|
|
191
|
+
export {};
|
|
192
|
+
//# sourceMappingURL=budget-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"budget-builder.d.ts","sourceRoot":"","sources":["../../src/budget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AED,MAAM,QAAQ,GAAG,kBAAkB,CAAC,KAAK,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;YAChE,4BAA4B,CAAC,IAAI,CAAC,gCAAgC,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;YACzF,YAAY,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;QAC3C,CAAC;QAED,OAAO,EAAE,4BAA4B,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;IACnE,CAAC;CACF;AAED,SAAS,gBAAgB,CAAC,WAA8B;IACtD,OAAO,WAAW,CAAC,GAAG,KAAK,SAAS,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;AAChF,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAwB;IACpD,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,aAAa,IAAI,YAAY,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/E,OAAO,gBAAgB,KAAK,CAAC,gBAAgB,MAAM,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,CAAC;AACtF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB;IACjC,4GAA4G;IAC5G,OAAO,OAAO,CAAoC,aAAa,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { IConstruct } from "constructs";
|
|
2
|
+
/**
|
|
3
|
+
* Throws if `unit` is not in {@link DEFAULT_BUDGET_CURRENCIES}.
|
|
4
|
+
*
|
|
5
|
+
* `context` is woven into the message (e.g. `BudgetBuilder "X": limit
|
|
6
|
+
* unit ...`) so callers can blame the right field. Catches typos like
|
|
7
|
+
* `"USDD"` or `"ZZZ"` at synth instead of mid-deploy.
|
|
8
|
+
*/
|
|
9
|
+
export declare function assertValidBudgetCurrency(unit: string, context: string): void;
|
|
10
|
+
/**
|
|
11
|
+
* Annotates `scope` with a non-fatal warning when `unit` is anything
|
|
12
|
+
* other than `USD`. The synth context cannot see an account's billing
|
|
13
|
+
* currency, and AWS Budgets rejects `BudgetLimit.Unit` values that
|
|
14
|
+
* don't match it — so a non-USD configuration deserves a "make sure
|
|
15
|
+
* this matches your billing currency" nudge.
|
|
16
|
+
*
|
|
17
|
+
* Short-circuits on unresolved tokens so env-agnostic stacks aren't
|
|
18
|
+
* spammed.
|
|
19
|
+
*/
|
|
20
|
+
export declare function warnIfNonUsdCurrency(scope: IConstruct, unit: string, context: string): void;
|
|
21
|
+
//# sourceMappingURL=currency.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"currency.d.ts","sourceRoot":"","sources":["../../src/currency.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAM7E;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAS3F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"currency.js","sourceRoot":"","sources":["../../src/currency.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAE1D;;;;;;GAMG;AACH,MAAM,UAAU,yBAAyB,CAAC,IAAY,EAAE,OAAe;IACrE,IAAI,yBAAyB,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO;IACrD,MAAM,IAAI,KAAK,CACb,GAAG,OAAO,MAAM,IAAI,mDAAmD;QACrE,oBAAoB,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAC9D,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAiB,EAAE,IAAY,EAAE,OAAe;IACnF,IAAI,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC;QAAE,OAAO;IACrC,IAAI,IAAI,KAAK,KAAK;QAAE,OAAO;IAC3B,WAAW,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,YAAY,CAChC,sCAAsC,EACtC,GAAG,OAAO,eAAe,IAAI,6DAA6D;QACxF,yFAAyF;QACzF,uCAAuC,CAC1C,CAAC;AACJ,CAAC"}
|