Skip to content
v2.275.0

AutoRollbackConfig Struct ​

The configuration for automatically rolling back deployments in a given Deployment Group.

Example ​

ts
import * as autoscaling from 'aws-cdk-lib/aws-autoscaling';
import * as cloudwatch from 'aws-cdk-lib/aws-cloudwatch';

declare const application: codedeploy.ServerApplication;
declare const asg: autoscaling.AutoScalingGroup;
declare const alarm: cloudwatch.Alarm;
const deploymentGroup = new codedeploy.ServerDeploymentGroup(this, 'CodeDeployDeploymentGroup', {
  application,
  deploymentGroupName: 'MyDeploymentGroup',
  autoScalingGroups: [asg],
  // adds User Data that installs the CodeDeploy agent on your auto-scaling groups hosts
  // default: true
  installAgent: true,
  // adds EC2 instances matching tags
  ec2InstanceTags: new codedeploy.InstanceTagSet(
    {
      // any instance with tags satisfying
      // key1=v1 or key1=v2 or key2 (any value) or value v3 (any key)
      // will match this group
      'key1': ['v1', 'v2'],
      'key2': [],
      '': ['v3'],
    },
  ),
  // adds on-premise instances matching tags
  onPremiseInstanceTags: new codedeploy.InstanceTagSet(
    // only instances with tags (key1=v1 or key1=v2) AND key2=v3 will match this set
    {
      'key1': ['v1', 'v2'],
    },
    {
      'key2': ['v3'],
    },
  ),
  // CloudWatch alarms
  alarms: [alarm],
  // whether to ignore failure to fetch the status of alarms from CloudWatch
  // default: false
  ignorePollAlarmsFailure: false,
  // whether to skip the step of checking CloudWatch alarms during the deployment process
  // default: false
  ignoreAlarmConfiguration: false,
  // auto-rollback configuration
  autoRollback: {
    failedDeployment: true, // default: true
    stoppedDeployment: true, // default: false
    deploymentInAlarm: true, // default: true if you provided any alarms, false otherwise
  },
  // whether the deployment group was configured to have CodeDeploy install a termination hook into an Auto Scaling group
  // default: false
  terminationHook: true,
});

Properties ​

deploymentInAlarmoptionalbooleandeployment_in_alarmoptionalbooldeploymentInAlarmoptionalBooleanDeploymentInAlarmoptionalboolDeploymentInAlarmoptional*bool#
Whether to automatically roll back a deployment during which one of the configured CloudWatch alarms for this Deployment Group went off.

Default: true if you've provided any Alarms with the alarms property, false otherwise

failedDeploymentoptionalbooleanfailed_deploymentoptionalboolfailedDeploymentoptionalBooleanFailedDeploymentoptionalboolFailedDeploymentoptional*bool= true#
Whether to automatically roll back a deployment that fails.
stoppedDeploymentoptionalbooleanstopped_deploymentoptionalboolstoppedDeploymentoptionalBooleanStoppedDeploymentoptionalboolStoppedDeploymentoptional*bool= false#
Whether to automatically roll back a deployment that was manually stopped.