Protocol

class aws_cdk.aws_elasticloadbalancingv2.Protocol(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

Backend protocol for network load balancers and health checks.

ExampleMetadata:

infused

Example:

from aws_cdk.aws_certificatemanager import Certificate
from aws_cdk.aws_ec2 import InstanceType
from aws_cdk.aws_ecs import Cluster, ContainerImage
from aws_cdk.aws_elasticloadbalancingv2 import ApplicationProtocol, Protocol, SslPolicy
from aws_cdk.aws_route53 import PublicHostedZone

vpc = ec2.Vpc(self, "Vpc", max_azs=1)

load_balanced_fargate_service = ecs_patterns.ApplicationMultipleTargetGroupsFargateService(self, "myService",
    cluster=ecs.Cluster(self, "EcsCluster", vpc=vpc),
    memory_limit_mi_b=256,
    task_image_options=ecsPatterns.ApplicationLoadBalancedTaskImageProps(
        image=ecs.ContainerImage.from_registry("amazon/amazon-ecs-sample")
    ),
    enable_execute_command=True,
    load_balancers=[ecsPatterns.ApplicationLoadBalancerProps(
        name="lb",
        idle_timeout=Duration.seconds(400),
        domain_name="api.example.com",
        domain_zone=PublicHostedZone(self, "HostedZone", zone_name="example.com"),
        listeners=[ecsPatterns.ApplicationListenerProps(
            name="listener",
            protocol=ApplicationProtocol.HTTPS,
            certificate=Certificate.from_certificate_arn(self, "Cert", "helloworld"),
            ssl_policy=SslPolicy.TLS12_EXT
        )
        ]
    ), ecsPatterns.ApplicationLoadBalancerProps(
        name="lb2",
        idle_timeout=Duration.seconds(120),
        domain_name="frontend.com",
        domain_zone=PublicHostedZone(self, "HostedZone", zone_name="frontend.com"),
        listeners=[ecsPatterns.ApplicationListenerProps(
            name="listener2",
            protocol=ApplicationProtocol.HTTPS,
            certificate=Certificate.from_certificate_arn(self, "Cert2", "helloworld"),
            ssl_policy=SslPolicy.TLS12_EXT
        )
        ]
    )
    ],
    target_groups=[ecsPatterns.ApplicationTargetProps(
        container_port=80,
        listener="listener"
    ), ecsPatterns.ApplicationTargetProps(
        container_port=90,
        path_pattern="a/b/c",
        priority=10,
        listener="listener"
    ), ecsPatterns.ApplicationTargetProps(
        container_port=443,
        listener="listener2"
    ), ecsPatterns.ApplicationTargetProps(
        container_port=80,
        path_pattern="a/b/c",
        priority=10,
        listener="listener2"
    )
    ]
)

load_balanced_fargate_service.target_groups[0].configure_health_check(
    port="8050",
    protocol=Protocol.HTTP,
    healthy_threshold_count=2,
    unhealthy_threshold_count=2,
    timeout=Duration.seconds(10),
    interval=Duration.seconds(30),
    healthy_http_codes="200"
)

load_balanced_fargate_service.target_groups[1].configure_health_check(
    port="8050",
    protocol=Protocol.HTTP,
    healthy_threshold_count=2,
    unhealthy_threshold_count=2,
    timeout=Duration.seconds(10),
    interval=Duration.seconds(30),
    healthy_http_codes="200"
)

Attributes

HTTP

HTTP (ALB health checks and NLB health checks).

HTTPS

HTTPS (ALB health checks and NLB health checks).

TCP

TCP (NLB, NLB health checks).

TCP_UDP

Listen to both TCP and UDP on the same port (NLB).

TLS

TLS (NLB).

UDP

UDP (NLB).