LoadBalancerTargetOptions
- class aws_cdk.aws_ecs.LoadBalancerTargetOptions(*, container_name, alternate_target=None, container_port=None, protocol=None)
Bases:
objectProperties for defining an ECS target.
The port mapping for it must already have been created through addPortMapping().
- Parameters:
container_name (
str) – The name of the container.alternate_target (
Optional[IAlternateTarget]) – Alternate target configuration for blue/green deployments. Default: - No alternate target configurationcontainer_port (
Union[int,float,None]) – The port number of the container. Only applicable when using application/network load balancers. Default: - Container port of the first added port mapping.protocol (
Optional[Protocol]) – The protocol used for the port mapping. Only applicable when using application load balancers. Default: Protocol.TCP
- 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
Alternate target configuration for blue/green deployments.
- Default:
No alternate target configuration
- container_name
The name of the container.
- container_port
The port number of the container.
Only applicable when using application/network load balancers.
- Default:
Container port of the first added port mapping.
- protocol
The protocol used for the port mapping.
Only applicable when using application load balancers.
- Default:
Protocol.TCP