AlarmBehavior Enum
Deployment behavior when an ECS Service Deployment Alarm is triggered.
Example
ts
import * as cw from 'aws-cdk-lib/aws-cloudwatch';
declare const cluster: ecs.Cluster;
declare const taskDefinition: ecs.TaskDefinition;
declare const elbAlarm: cw.Alarm;
const service = new ecs.FargateService(this, 'Service', {
cluster,
taskDefinition,
minHealthyPercent: 100,
deploymentAlarms: {
alarmNames: [elbAlarm.alarmName],
behavior: ecs.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], {
behavior: ecs.AlarmBehavior.FAIL_ON_ALARM,
});
Members
| Member | Description |
|---|---|
ROLLBACK_ON_ALARM | ROLLBACK_ON_ALARM causes the service to roll back to the previous deployment when any deployment alarm enters the 'Alarm' state. |
FAIL_ON_ALARM | FAIL_ON_ALARM causes the deployment to fail immediately when any deployment alarm enters the 'Alarm' state. |
Referenced by
DeploymentAlarmOptions.behaviorbehaviorbehaviorBehaviorBehavior