AlternateTargetProps

class aws_cdk.aws_ecs.AlternateTargetProps(*, role=None, test_listener=None, alternate_target_group, production_listener)

Bases: AlternateTargetOptions

Properties for AlternateTarget configuration.

Parameters:
  • role (Optional[IRole]) – The IAM role for the configuration. Default: - a new role will be created

  • test_listener (Optional[ListenerRuleConfiguration]) – The test listener configuration. Default: - none

  • alternate_target_group (ITargetGroupRef) – The alternate target group.

  • production_listener (ListenerRuleConfiguration) – The production listener rule ARN (ALB) or listener ARN (NLB).

ExampleMetadata:

infused

Example:

# cluster: ecs.Cluster
# task_definition: ecs.TaskDefinition
# blue_target_group: elbv2.ApplicationTargetGroup
# green_target_group: elbv2.ApplicationTargetGroup
# prod_listener_rule: elbv2.ApplicationListenerRule


service = ecs.FargateService(self, "Service",
    cluster=cluster,
    task_definition=task_definition,
    deployment_strategy=ecs.DeploymentStrategy.LINEAR,
    linear_configuration=ecs.TrafficShiftConfig(
        step_percent=10,
        step_bake_time=Duration.minutes(5)
    )
)

target = service.load_balancer_target(
    container_name="web",
    container_port=80,
    alternate_target=ecs.AlternateTarget("AlternateTarget",
        alternate_target_group=green_target_group,
        production_listener=ecs.ListenerRuleConfiguration.application_listener_rule(prod_listener_rule)
    )
)

target.attach_to_application_target_group(blue_target_group)

Attributes

alternate_target_group

The alternate target group.

production_listener

The production listener rule ARN (ALB) or listener ARN (NLB).

role

The IAM role for the configuration.

Default:
  • a new role will be created

test_listener

The test listener configuration.

Default:
  • none