enum Protocol
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.ElasticLoadBalancingV2.Protocol |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awselasticloadbalancingv2#Protocol |
Java | software.amazon.awscdk.services.elasticloadbalancingv2.Protocol |
Python | aws_cdk.aws_elasticloadbalancingv2.Protocol |
TypeScript (source) | aws-cdk-lib » aws_elasticloadbalancingv2 » Protocol |
Backend protocol for network load balancers and health checks.
Example
import { Certificate } from 'aws-cdk-lib/aws-certificatemanager';
import { InstanceType } from 'aws-cdk-lib/aws-ec2';
import { Cluster, ContainerImage } from 'aws-cdk-lib/aws-ecs';
import { ApplicationProtocol,Protocol, SslPolicy } from 'aws-cdk-lib/aws-elasticloadbalancingv2';
import { PublicHostedZone } from 'aws-cdk-lib/aws-route53';
const vpc = new ec2.Vpc(this, 'Vpc', { maxAzs: 1 });
const loadBalancedFargateService = new ecsPatterns.ApplicationMultipleTargetGroupsFargateService(this, 'myService', {
cluster: new ecs.Cluster(this, 'EcsCluster', { vpc }),
memoryLimitMiB: 256,
taskImageOptions: {
image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
},
enableExecuteCommand: true,
loadBalancers: [
{
name: 'lb',
idleTimeout: Duration.seconds(400),
domainName: 'api.example.com',
domainZone: new PublicHostedZone(this, 'HostedZone', { zoneName: 'example.com' }),
listeners: [
{
name: 'listener',
protocol: ApplicationProtocol.HTTPS,
certificate: Certificate.fromCertificateArn(this, 'Cert', 'helloworld'),
sslPolicy: SslPolicy.TLS12_EXT,
},
],
},
{
name: 'lb2',
idleTimeout: Duration.seconds(120),
domainName: 'frontend.com',
domainZone: new PublicHostedZone(this, 'HostedZone', { zoneName: 'frontend.com' }),
listeners: [
{
name: 'listener2',
protocol: ApplicationProtocol.HTTPS,
certificate: Certificate.fromCertificateArn(this, 'Cert2', 'helloworld'),
sslPolicy: SslPolicy.TLS12_EXT,
},
],
},
],
targetGroups: [
{
containerPort: 80,
listener: 'listener',
},
{
containerPort: 90,
pathPattern: 'a/b/c',
priority: 10,
listener: 'listener',
},
{
containerPort: 443,
listener: 'listener2',
},
{
containerPort: 80,
pathPattern: 'a/b/c',
priority: 10,
listener: 'listener2',
},
],
});
loadBalancedFargateService.targetGroups[0].configureHealthCheck({
port: '8050',
protocol: Protocol.HTTP,
healthyThresholdCount: 2,
unhealthyThresholdCount: 2,
timeout: Duration.seconds(10),
interval: Duration.seconds(30),
healthyHttpCodes: '200',
});
loadBalancedFargateService.targetGroups[1].configureHealthCheck({
port: '8050',
protocol: Protocol.HTTP,
healthyThresholdCount: 2,
unhealthyThresholdCount: 2,
timeout: Duration.seconds(10),
interval: Duration.seconds(30),
healthyHttpCodes: '200',
});
Members
Name | Description |
---|---|
HTTP | HTTP (ALB health checks and NLB health checks). |
HTTPS | HTTPS (ALB health checks and NLB health checks). |
TCP | TCP (NLB, NLB health checks). |
TLS | TLS (NLB). |
UDP | UDP (NLB). |
TCP_UDP | Listen to both TCP and UDP on the same port (NLB). |
HTTP
HTTP (ALB health checks and NLB health checks).
HTTPS
HTTPS (ALB health checks and NLB health checks).
TCP
TCP (NLB, NLB health checks).
TLS
TLS (NLB).
UDP
UDP (NLB).
TCP_UDP
Listen to both TCP and UDP on the same port (NLB).