Skip to content

Latest commit

 

History

History
46 lines (29 loc) · 1.9 KB

constructs.md

File metadata and controls

46 lines (29 loc) · 1.9 KB

Construct catalog

This library includes an Aspect and a collection of AWS CDK Level-2 Constructs with hard-limit monthly budget capabilities.

CostLimit Aspect

Using the exported CostLimit Aspect is the recommended way to enable cost-limit capabilities on your resources. If you'd however like not to use an Aspect, you can refer to the per service documentation

You can use the Aspect on any node to enable budget limits.

import { Aspects } from "aws-cdk-lib";
import { CostLimit } from "@revant-io/cdk-cost-limit";

declare const fn: lambda.Function;
declare const instance: ec2.Instance;

// Set a monthly budget of $1,00 for this specific Lambda function `fn`
Aspects.of(fn).add(new CostLimit({ budget: 100 }));

// Set a monthly budget of $20,00 for this specific EC2 instance `instance`
Aspects.of(instance).add(new CostLimit({ budget: 2000 }));

You can use this Aspect to set the same monthly budget limit on all supported resources of your stack.

import { Aspects } from "aws-cdk-lib";
import { CostLimit } from "@revant-io/cdk-cost-limit";

declare const stack: cdk.Stack;

// Set a monthly budget of $1,00 for each supported resources within `stack`
Aspects.of(stack).add(new CostLimit({ budget: 100 }));

How it works?

There are 3 levels of resources provisionned by this library: common resources, typology-specific resources and construct-specific resources. They all ensure supported constructs remain within budgets. The scope of responsability of each of those resources are detailed in the design principles.

Per-Service Level-2 Constructs

This collection of CDK constructs covers multiple AWS services and resource types.