enum AlarmBehavior
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.ECS.AlarmBehavior |
![]() | github.com/aws/aws-cdk-go/awscdk/v2/awsecs#AlarmBehavior |
![]() | software.amazon.awscdk.services.ecs.AlarmBehavior |
![]() | aws_cdk.aws_ecs.AlarmBehavior |
![]() | aws-cdk-lib » aws_ecs » AlarmBehavior |
Deployment behavior when an ECS Service Deployment Alarm is triggered.
Example
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
Name | 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. |
ROLLBACK_ON_ALARM
ROLLBACK_ON_ALARM causes the service to roll back to the previous deployment when any deployment alarm enters the 'Alarm' state.
The Cloudformation stack will be rolled back and enter state "UPDATE_ROLLBACK_COMPLETE".
FAIL_ON_ALARM
FAIL_ON_ALARM causes the deployment to fail immediately when any deployment alarm enters the 'Alarm' state.
In order to restore functionality, you must roll the stack forward by pushing a new version of the ECS service.