Skip to content

cdk-constructs 0.0.205

Install from the command line:
Learn more about npm packages
$ npm install @elisasre/cdk-constructs@0.0.205
Install via package.json:
"@elisasre/cdk-constructs": "0.0.205"

About this version

Constructs for AWS CDK

Usage

Add @elisasre/cdk-constructs as a dependency of your CDK project and import the desired construct.

Alarm with tags

Alarm with tags extends the standard CDK alarm construct by allowing tagging of alarms, which Cloudformation does not currently support out of the box.

Creating a tagged alarm

declare const fn: lambda.Function;

const minuteErrorRate = fn.metricErrors({
  statistic: cloudwatch.Stats.AVERAGE,
  period: Duration.minutes(1),
  label: 'Lambda failure rate'
});

const alarm = new AlarmWithTags(this, 'myalarm', {
    evaluationPeriods: 3,
    metric: minuteErrorRate,
    threshold: 1,
    comparisonOperator: cloudwatch.ComparisonOperator.GREATER_THAN_THRESHOLD,
});

Tags.of(alarm).add('foo', 'bar');

Tagging an existing alarm

declare const fn: lambda.Function;

const minuteErrorRate = fn.metricErrors({
  statistic: cloudwatch.Stats.AVERAGE,
  period: Duration.minutes(1),
  label: 'Lambda failure rate'
});

const alarm = minuteErrorRate.createAlarm(this, 'myalarm', {
    evaluationPeriods: 3,
    threshold: 1,
    comparisonOperator: cloudwatch.ComparisonOperator.GREATER_THAN_THRESHOLD,
});

const myTaggedAlarm = AlarmWithTags.fromArn(this, 'myalarmwithtags', alarm.alarmArn);

Tags.of(myTaggedAlarm).add('foo', 'bar');

API reference

Details


Assets

  • cdk-constructs-0.0.205.tgz

Download activity

  • Total downloads 0
  • Last 30 days 0
  • Last week 0
  • Today 0