aws-cdk-lib.aws_ecs.DeploymentAlarmConfig

interface DeploymentAlarmConfig

LanguageType name
.NETAmazon.CDK.AWS.ECS.DeploymentAlarmConfig
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsecs#DeploymentAlarmConfig
Javasoftware.amazon.awscdk.services.ecs.DeploymentAlarmConfig
Pythonaws_cdk.aws_ecs.DeploymentAlarmConfig
TypeScript (source)aws-cdk-lib » aws_ecs » DeploymentAlarmConfig

Configuration for deployment alarms.

Example

import * as cw from 'aws-cdk-lib/aws-cloudwatch';
declare const cluster: ecs.Cluster;
declare const taskDefinition: ecs.TaskDefinition;
declare const elbAlarm: cloudwatch.Alarm;
const service = new ecs.FargateService(this, 'Service', {
  cluster,
  taskDefinition,
  deploymentAlarms: {
    alarms: [elbAlarm.alarmName]
    behavior: AlarmBehavior.ROLLBACK_ON_ALARM,
  },
});

// Defining a deployment alarm after the service has been created
const cpuAlarmName =  'MyCpuMetricAlarm';
new cw.Alarm(this, 'CPUAlarm', {
  alarmName: cpuAlarmName,
  metric: service.metricCpuUtilization(),
  evaluationPeriods: 2,
  threshold: 80,
});
service.enableDeploymentAlarms([cpuAlarmName], AlarmBehavior.FAIL_ON_ALARM);

Properties

NameTypeDescription
alarmNamesstring[]List of alarm names to monitor during deployments.
behavior?AlarmBehaviorDefault rollback on alarm.

alarmNames

Type: string[]

List of alarm names to monitor during deployments.


behavior?

Type: AlarmBehavior (optional, default: AlarmBehavior.ROLLBACK_ON_ALARM)

Default rollback on alarm.