Skip to content
v2.274.0

TrafficShiftConfig Struct ​

Configuration for traffic shift during progressive deployments.

Example ​

ts
declare const cluster: ecs.Cluster;
declare const taskDefinition: ecs.TaskDefinition;
declare const blueTargetGroup: elbv2.ApplicationTargetGroup;
declare const greenTargetGroup: elbv2.ApplicationTargetGroup;
declare const prodListenerRule: elbv2.ApplicationListenerRule;

const service = new ecs.FargateService(this, 'Service', {
  cluster,
  taskDefinition,
  deploymentStrategy: ecs.DeploymentStrategy.LINEAR,
  linearConfiguration: {
    stepPercent: 10.0,
    stepBakeTime: Duration.minutes(5),
  },
});

const target = service.loadBalancerTarget({
  containerName: 'web',
  containerPort: 80,
  alternateTarget: new ecs.AlternateTarget('AlternateTarget', {
    alternateTargetGroup: greenTargetGroup,
    productionListener: ecs.ListenerRuleConfiguration.applicationListenerRule(prodListenerRule),
  }),
});

target.attachToApplicationTargetGroup(blueTargetGroup);

Properties ​

stepBakeTimeDurationstep_bake_timeDurationstepBakeTimeDurationStepBakeTimeDurationStepBakeTimeDuration#
The duration to wait between traffic shifting steps.

Default: Duration.minutes(6) for linear, Duration.minutes(10) for canary

Valid values are 0 to 1440 minutes (24 hours).

stepPercentnumberstep_percentint | floatstepPercentNumberStepPercentdoubleStepPercent*float64#
The percentage of production traffic to shift in each step.

Default: 10.0 for linear, 5.0 for canary

  • For linear deployment: multiples of 0.1 from 3.0 to 100.0
  • For canary deployment: multiples of 0.1 from 0.1 to 100.0