class AlternateTarget
| Language | Type name | 
|---|---|
|  .NET | Amazon.CDK.AWS.ECS.AlternateTarget | 
|  Go | github.com/aws/aws-cdk-go/awscdk/v2/awsecs#AlternateTarget | 
|  Java | software.amazon.awscdk.services.ecs.AlternateTarget | 
|  Python | aws_cdk.aws_ecs.AlternateTarget | 
|  TypeScript (source) | aws-cdk-lib»aws_ecs»AlternateTarget | 
Implements
IAlternate
Configuration for alternate target groups used in blue/green deployments with load balancers.
Example
import * as lambda from 'aws-cdk-lib/aws-lambda';
declare const cluster: ecs.Cluster;
declare const taskDefinition: ecs.TaskDefinition;
declare const lambdaHook: lambda.Function;
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.BLUE_GREEN,
});
service.addLifecycleHook(new ecs.DeploymentLifecycleLambdaTarget(lambdaHook, 'PreScaleHook', {
  lifecycleStages: [ecs.DeploymentLifecycleStage.PRE_SCALE_UP],
}));
const target = service.loadBalancerTarget({
  containerName: 'nginx',
  containerPort: 80,
  protocol: ecs.Protocol.TCP,
  alternateTarget: new ecs.AlternateTarget('AlternateTarget', {
    alternateTargetGroup: greenTargetGroup,
    productionListener: ecs.ListenerRuleConfiguration.applicationListenerRule(prodListenerRule),
  }),
});
target.attachToApplicationTargetGroup(blueTargetGroup);
Initializer
new AlternateTarget(id: string, props: AlternateTargetProps)
Parameters
- id string
- props AlternateTarget Props 
Methods
| Name | Description | 
|---|---|
| bind(scope) | Bind this configuration to a service. | 
bind(scope)
public bind(scope: IConstruct): AlternateTargetConfig
Parameters
- scope IConstruct
Returns
Bind this configuration to a service.
