cost-monitoring-construct
Version:
A CDK construct that helps track applications' costs separately and receive alerts in case of unpredicted resource usage
53 lines (52 loc) • 2.27 kB
TypeScript
import { Stack, aws_sns as sns, aws_budgets as budgets } from "aws-cdk-lib";
import { Email } from "./utils";
export interface IBudgetStrategyProps {
monthlyLimitInDollars: number;
subscribers: Array<Email>;
defaultTopic?: string;
}
export declare abstract class IBudgetStrategy {
private props;
private _defaultTopic?;
protected stack: Stack;
/**
* defines the stratcure of a BudgetStategy class.
*
* @param construct - use to define it's resources inside it.
* @param props.monthlyBudget - montly budget in US Dollors.
* @param props.defaultTopic - default SNS topic name. Only if provided, the BudgetStratgy creates an SNS topic and send notifications to it.
* @param props.subscribers - list of email address that the BudgetStrategy will use to send alerts to.
*/
constructor(construct: Stack, props: IBudgetStrategyProps);
protected abstract createDailyBudgets(dailyLimit: number, subscribers: Array<budgets.CfnBudget.SubscriberProperty>): void;
protected abstract createMonthlyBudgets(monthlyLimit: number, subscribers: Array<budgets.CfnBudget.SubscriberProperty>): void;
protected abstract createQuarterlyBudgets(quarterlyLimit: number, subscribers: Array<budgets.CfnBudget.SubscriberProperty>): void;
protected abstract createYearlyBudgets(yearlyLimit: number, subscribers: Array<budgets.CfnBudget.SubscriberProperty>): void;
/**
* creates all the daily, monthly, quaryerly, and yearly budgets based on the implementation of the related methods.
*/
createBudgets(): void;
private createAllSubscribers;
private createSNSSubscriber;
private createEmailSubscribers;
/**
* Return default SNS topic only if the defultTopic prop has been passed when instantiating.
*/
get defaultTopic(): sns.Topic | undefined;
/**
* calculates daily limit based on the provided monthly limit.
*/
get dailyLimit(): number;
/**
* returns montly limit.
*/
get monthlyLimit(): number;
/**
* calculates quarterly limit based on the provided monthly limit.
*/
get quarterlyLimit(): number;
/**
* calculates yearly limit based on the provided daily budget.
*/
get yearlyLimit(): number;
}