Skip to content
v2.277.0

ApplicationLoadBalancerProps Struct ​

Properties to define an application load balancer.

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_certificatemanager as certificatemanager } from 'aws-cdk-lib';
import { aws_ecs_patterns as ecs_patterns } from 'aws-cdk-lib';
import { aws_elasticloadbalancingv2 as elbv2 } from 'aws-cdk-lib';
import { aws_route53 as route53 } from 'aws-cdk-lib';

declare const certificate: certificatemanager.Certificate;
declare const hostedZone: route53.HostedZone;
const applicationLoadBalancerProps: ecs_patterns.ApplicationLoadBalancerProps = {
  listeners: [{
    name: 'name',

    // the properties below are optional
    certificate: certificate,
    port: 123,
    protocol: elbv2.ApplicationProtocol.HTTP,
    sslPolicy: elbv2.SslPolicy.RECOMMENDED_TLS,
  }],
  name: 'name',

  // the properties below are optional
  domainName: 'domainName',
  domainZone: hostedZone,
  idleTimeout: cdk.Duration.minutes(30),
  publicLoadBalancer: false,
};
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk
from aws_cdk import aws_certificatemanager as certificatemanager
from aws_cdk import aws_ecs_patterns as ecs_patterns
from aws_cdk import aws_elasticloadbalancingv2 as elbv2
from aws_cdk import aws_route53 as route53

# certificate: certificatemanager.Certificate
# hosted_zone: route53.HostedZone

application_load_balancer_props = ecs_patterns.ApplicationLoadBalancerProps(
    listeners=[ecs_patterns.ApplicationListenerProps(
        name="name",

        # the properties below are optional
        certificate=certificate,
        port=123,
        protocol=elbv2.ApplicationProtocol.HTTP,
        ssl_policy=elbv2.SslPolicy.RECOMMENDED_TLS
    )],
    name="name",

    # the properties below are optional
    domain_name="domainName",
    domain_zone=hosted_zone,
    idle_timeout=cdk.Duration.minutes(30),
    public_load_balancer=False
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;
import software.amazon.awscdk.services.certificatemanager.*;
import software.amazon.awscdk.services.ecs.patterns.*;
import software.amazon.awscdk.services.elasticloadbalancingv2.*;
import software.amazon.awscdk.services.route53.*;

Certificate certificate;
HostedZone hostedZone;

ApplicationLoadBalancerProps applicationLoadBalancerProps = ApplicationLoadBalancerProps.builder()
        .listeners(List.of(ApplicationListenerProps.builder()
                .name("name")

                // the properties below are optional
                .certificate(certificate)
                .port(123)
                .protocol(ApplicationProtocol.HTTP)
                .sslPolicy(SslPolicy.RECOMMENDED_TLS)
                .build()))
        .name("name")

        // the properties below are optional
        .domainName("domainName")
        .domainZone(hostedZone)
        .idleTimeout(Duration.minutes(30))
        .publicLoadBalancer(false)
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;
using Amazon.CDK.AWS.CertificateManager;
using Amazon.CDK.AWS.ECS.Patterns;
using Amazon.CDK.AWS.ElasticLoadBalancingV2;
using Amazon.CDK.AWS.Route53;

Certificate certificate;
HostedZone hostedZone;

var applicationLoadBalancerProps = new ApplicationLoadBalancerProps {
    Listeners = new [] { new ApplicationListenerProps {
        Name = "name",

        // the properties below are optional
        Certificate = certificate,
        Port = 123,
        Protocol = ApplicationProtocol.HTTP,
        SslPolicy = SslPolicy.RECOMMENDED_TLS
    } },
    Name = "name",

    // the properties below are optional
    DomainName = "domainName",
    DomainZone = hostedZone,
    IdleTimeout = Duration.Minutes(30),
    PublicLoadBalancer = false
};
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import cdk "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var certificate Certificate
var hostedZone HostedZone

applicationLoadBalancerProps := &ApplicationLoadBalancerProps{
	Listeners: []ApplicationListenerProps{
		&ApplicationListenerProps{
			Name: jsii.String("name"),

			// the properties below are optional
			Certificate: certificate,
			Port: jsii.Number(123),
			Protocol: awscdk.Aws_elasticloadbalancingv2.ApplicationProtocol_HTTP,
			SslPolicy: awscdk.*Aws_elasticloadbalancingv2.SslPolicy_RECOMMENDED_TLS,
		},
	},
	Name: jsii.String("name"),

	// the properties below are optional
	DomainName: jsii.String("domainName"),
	DomainZone: hostedZone,
	IdleTimeout: cdk.Duration_Minutes(jsii.Number(30)),
	PublicLoadBalancer: jsii.Boolean(false),
}

Properties ​

domainNameoptionalstringdomain_nameoptionalstrdomainNameoptionalStringDomainNameoptionalstringDomainNameoptional*string#
The domain name for the service, e.g. "api.example.com.".

Default: No domain name.

domainZoneoptionalIHostedZonedomain_zoneoptionalIHostedZonedomainZoneoptionalIHostedZoneDomainZoneoptionalIHostedZoneDomainZoneoptionalIHostedZone#
The Route53 hosted zone for the domain, e.g. "example.com.".

Default: No Route53 hosted domain zone.

idleTimeoutoptionalDurationidle_timeoutoptionalDurationidleTimeoutoptionalDurationIdleTimeoutoptionalDurationIdleTimeoutoptionalDuration#
The load balancer idle timeout, in seconds.

Default: CloudFormation sets idle timeout to 60 seconds

Can be between 1 and 4000 seconds.

Listeners (at least one listener) attached to this load balancer.
namestringnamestrnameStringNamestringName*stringrequired#
Name of the load balancer.
publicLoadBalanceroptionalbooleanpublic_load_balanceroptionalboolpublicLoadBalanceroptionalBooleanPublicLoadBalanceroptionalboolPublicLoadBalanceroptional*bool= true#
Determines whether the Load Balancer will be internet-facing.