Class ApplicationLoadBalancer
Define an Application Load Balancer.
Inherited Members
Namespace: Amazon.CDK.AWS.ElasticLoadBalancingV2
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class ApplicationLoadBalancer : BaseLoadBalancer, IApplicationLoadBalancer, ILoadBalancerV2, IResource, IConstruct, IDependable, IConnectable
Syntax (vb)
Public Class ApplicationLoadBalancer Inherits BaseLoadBalancer Implements IApplicationLoadBalancer, ILoadBalancerV2, IResource, IConstruct, IDependable, IConnectable
Remarks
Resource: AWS::ElasticLoadBalancingV2::LoadBalancer
ExampleMetadata: infused
Examples
Vpc vpc;
var securityGroup1 = new SecurityGroup(this, "SecurityGroup1", new SecurityGroupProps { Vpc = vpc });
var lb = new ApplicationLoadBalancer(this, "LB", new ApplicationLoadBalancerProps {
Vpc = vpc,
InternetFacing = true,
SecurityGroup = securityGroup1
});
var securityGroup2 = new SecurityGroup(this, "SecurityGroup2", new SecurityGroupProps { Vpc = vpc });
lb.AddSecurityGroup(securityGroup2);
Synopsis
Constructors
ApplicationLoadBalancer(Construct, string, IApplicationLoadBalancerProps) | Define an Application Load Balancer. |
Properties
Connections | The network connections associated with this resource. |
IpAddressType | The IP Address Type for this load balancer. |
Listeners | A list of listeners that have been added to the load balancer. |
Metrics | All metrics available for this load balancer. |
PROPERTY_INJECTION_ID | Uniquely identifies this class. |
Methods
AddListener(string, IBaseApplicationListenerProps) | Add a new listener to this load balancer. |
AddRedirect(IApplicationLoadBalancerRedirectConfig?) | Add a redirection listener to this load balancer. |
AddSecurityGroup(ISecurityGroup) | Add a security group to this load balancer. |
FromApplicationLoadBalancerAttributes(Construct, string, IApplicationLoadBalancerAttributes) | Import an existing Application Load Balancer. |
FromLookup(Construct, string, IApplicationLoadBalancerLookupOptions) | Look up an application load balancer. |
LogAccessLogs(IBucket, string?) | Enable access logging for this load balancer. |
LogConnectionLogs(IBucket, string?) | Enable connection logging for this load balancer. |
Metric(string, IMetricOptions?) | (deprecated) Return the given named metric for this Application Load Balancer. |
MetricActiveConnectionCount(IMetricOptions?) | (deprecated) The total number of concurrent TCP connections active from clients to the load balancer and from the load balancer to targets. |
MetricClientTlsNegotiationErrorCount(IMetricOptions?) | (deprecated) The number of TLS connections initiated by the client that did not establish a session with the load balancer. |
MetricConsumedLCUs(IMetricOptions?) | (deprecated) The number of load balancer capacity units (LCU) used by your load balancer. |
MetricElbAuthError(IMetricOptions?) | (deprecated) The number of user authentications that could not be completed. |
MetricElbAuthFailure(IMetricOptions?) | (deprecated) The number of user authentications that could not be completed because the IdP denied access to the user or an authorization code was used more than once. |
MetricElbAuthLatency(IMetricOptions?) | (deprecated) The time elapsed, in milliseconds, to query the IdP for the ID token and user info. |
MetricElbAuthSuccess(IMetricOptions?) | (deprecated) The number of authenticate actions that were successful. |
MetricHttpCodeElb(HttpCodeElb, IMetricOptions?) | (deprecated) The number of HTTP 3xx/4xx/5xx codes that originate from the load balancer. |
MetricHttpCodeTarget(HttpCodeTarget, IMetricOptions?) | (deprecated) The number of HTTP 2xx/3xx/4xx/5xx response codes generated by all targets in the load balancer. |
MetricHttpFixedResponseCount(IMetricOptions?) | (deprecated) The number of fixed-response actions that were successful. |
MetricHttpRedirectCount(IMetricOptions?) | (deprecated) The number of redirect actions that were successful. |
MetricHttpRedirectUrlLimitExceededCount(IMetricOptions?) | (deprecated) The number of redirect actions that couldn't be completed because the URL in the response location header is larger than 8K. |
MetricIpv6ProcessedBytes(IMetricOptions?) | (deprecated) The total number of bytes processed by the load balancer over IPv6. |
MetricIpv6RequestCount(IMetricOptions?) | (deprecated) The number of IPv6 requests received by the load balancer. |
MetricNewConnectionCount(IMetricOptions?) | (deprecated) The total number of new TCP connections established from clients to the load balancer and from the load balancer to targets. |
MetricProcessedBytes(IMetricOptions?) | (deprecated) The total number of bytes processed by the load balancer over IPv4 and IPv6. |
MetricRejectedConnectionCount(IMetricOptions?) | (deprecated) The number of connections that were rejected because the load balancer had reached its maximum number of connections. |
MetricRequestCount(IMetricOptions?) | (deprecated) The number of requests processed over IPv4 and IPv6. |
MetricRuleEvaluations(IMetricOptions?) | (deprecated) The number of rules processed by the load balancer given a request rate averaged over an hour. |
MetricTargetConnectionErrorCount(IMetricOptions?) | (deprecated) The number of connections that were not successfully established between the load balancer and target. |
MetricTargetResponseTime(IMetricOptions?) | (deprecated) The time elapsed, in seconds, after the request leaves the load balancer until a response from the target is received. |
MetricTargetTLSNegotiationErrorCount(IMetricOptions?) | (deprecated) The number of TLS connections initiated by the load balancer that did not establish a session with the target. |
Constructors
ApplicationLoadBalancer(Construct, string, IApplicationLoadBalancerProps)
Define an Application Load Balancer.
public ApplicationLoadBalancer(Construct scope, string id, IApplicationLoadBalancerProps props)
Parameters
- scope Construct
- id string
- props IApplicationLoadBalancerProps
Remarks
Resource: AWS::ElasticLoadBalancingV2::LoadBalancer
ExampleMetadata: infused
Examples
Vpc vpc;
var securityGroup1 = new SecurityGroup(this, "SecurityGroup1", new SecurityGroupProps { Vpc = vpc });
var lb = new ApplicationLoadBalancer(this, "LB", new ApplicationLoadBalancerProps {
Vpc = vpc,
InternetFacing = true,
SecurityGroup = securityGroup1
});
var securityGroup2 = new SecurityGroup(this, "SecurityGroup2", new SecurityGroupProps { Vpc = vpc });
lb.AddSecurityGroup(securityGroup2);
Properties
Connections
The network connections associated with this resource.
public virtual Connections_ Connections { get; }
Property Value
Remarks
Resource: AWS::ElasticLoadBalancingV2::LoadBalancer
ExampleMetadata: infused
IpAddressType
The IP Address Type for this load balancer.
public virtual IpAddressType? IpAddressType { get; }
Property Value
Remarks
If the @aws-cdk/aws-elasticloadbalancingV2:albDualstackWithoutPublicIpv4SecurityGroupRulesDefault
feature flag is set (the default for new projects), and addListener()
is called with open: true
,
the load balancer's security group will automatically include both IPv4 and IPv6 ingress rules
when using IpAddressType.DUAL_STACK_WITHOUT_PUBLIC_IPV4
.
For existing projects that only have IPv4 rules, you can opt-in to IPv6 ingress rules by enabling the feature flag in your cdk.json file. Note that enabling this feature flag will modify existing security group rules.
Listeners
A list of listeners that have been added to the load balancer.
public virtual ApplicationListener[] Listeners { get; }
Property Value
Remarks
This list is only valid for owned constructs.
Metrics
All metrics available for this load balancer.
public virtual IApplicationLoadBalancerMetrics Metrics { get; }
Property Value
IApplicationLoadBalancerMetrics
Remarks
Resource: AWS::ElasticLoadBalancingV2::LoadBalancer
ExampleMetadata: infused
PROPERTY_INJECTION_ID
Uniquely identifies this class.
public static string PROPERTY_INJECTION_ID { get; }
Property Value
Remarks
Resource: AWS::ElasticLoadBalancingV2::LoadBalancer
ExampleMetadata: infused
Methods
AddListener(string, IBaseApplicationListenerProps)
Add a new listener to this load balancer.
public virtual ApplicationListener AddListener(string id, IBaseApplicationListenerProps props)
Parameters
- id string
- props IBaseApplicationListenerProps
Returns
Remarks
Resource: AWS::ElasticLoadBalancingV2::LoadBalancer
ExampleMetadata: infused
AddRedirect(IApplicationLoadBalancerRedirectConfig?)
Add a redirection listener to this load balancer.
public virtual ApplicationListener AddRedirect(IApplicationLoadBalancerRedirectConfig? props = null)
Parameters
Returns
Remarks
Resource: AWS::ElasticLoadBalancingV2::LoadBalancer
ExampleMetadata: infused
AddSecurityGroup(ISecurityGroup)
Add a security group to this load balancer.
public virtual void AddSecurityGroup(ISecurityGroup securityGroup)
Parameters
- securityGroup ISecurityGroup
Remarks
Resource: AWS::ElasticLoadBalancingV2::LoadBalancer
ExampleMetadata: infused
FromApplicationLoadBalancerAttributes(Construct, string, IApplicationLoadBalancerAttributes)
Import an existing Application Load Balancer.
public static IApplicationLoadBalancer FromApplicationLoadBalancerAttributes(Construct scope, string id, IApplicationLoadBalancerAttributes attrs)
Parameters
- scope Construct
- id string
- attrs IApplicationLoadBalancerAttributes
Returns
Remarks
Resource: AWS::ElasticLoadBalancingV2::LoadBalancer
ExampleMetadata: infused
FromLookup(Construct, string, IApplicationLoadBalancerLookupOptions)
Look up an application load balancer.
public static IApplicationLoadBalancer FromLookup(Construct scope, string id, IApplicationLoadBalancerLookupOptions options)
Parameters
- scope Construct
- id string
- options IApplicationLoadBalancerLookupOptions
Returns
Remarks
Resource: AWS::ElasticLoadBalancingV2::LoadBalancer
ExampleMetadata: infused
LogAccessLogs(IBucket, string?)
Enable access logging for this load balancer.
public override void LogAccessLogs(IBucket bucket, string? prefix = null)
Parameters
Overrides
Remarks
A region must be specified on the stack containing the load balancer; you cannot enable logging on environment-agnostic stacks. See https://docs.aws.amazon.com/cdk/latest/guide/environments.html
LogConnectionLogs(IBucket, string?)
Enable connection logging for this load balancer.
public virtual void LogConnectionLogs(IBucket bucket, string? prefix = null)
Parameters
Remarks
A region must be specified on the stack containing the load balancer; you cannot enable logging on environment-agnostic stacks.
See: https://docs.aws.amazon.com/cdk/latest/guide/environments.html
Metric(string, IMetricOptions?)
(deprecated) Return the given named metric for this Application Load Balancer.
[Obsolete("Use ``ApplicationLoadBalancer.metrics.custom`` instead")]
public virtual Metric Metric(string metricName, IMetricOptions? props = null)
Parameters
- metricName string
- props IMetricOptions
Returns
Remarks
Default: Average over 5 minutes
Stability: Deprecated
MetricActiveConnectionCount(IMetricOptions?)
(deprecated) The total number of concurrent TCP connections active from clients to the load balancer and from the load balancer to targets.
[Obsolete("Use ``ApplicationLoadBalancer.metrics.activeConnectionCount`` instead")]
public virtual Metric MetricActiveConnectionCount(IMetricOptions? props = null)
Parameters
- props IMetricOptions
Returns
Remarks
Default: Sum over 5 minutes
Stability: Deprecated
MetricClientTlsNegotiationErrorCount(IMetricOptions?)
(deprecated) The number of TLS connections initiated by the client that did not establish a session with the load balancer.
[Obsolete("Use ``ApplicationLoadBalancer.metrics.clientTlsNegotiationErrorCount`` instead")]
public virtual Metric MetricClientTlsNegotiationErrorCount(IMetricOptions? props = null)
Parameters
- props IMetricOptions
Returns
Remarks
Possible causes include a mismatch of ciphers or protocols.
Default: Sum over 5 minutes
Stability: Deprecated
MetricConsumedLCUs(IMetricOptions?)
(deprecated) The number of load balancer capacity units (LCU) used by your load balancer.
[Obsolete("Use ``ApplicationLoadBalancer.metrics.consumedLCUs`` instead")]
public virtual Metric MetricConsumedLCUs(IMetricOptions? props = null)
Parameters
- props IMetricOptions
Returns
Remarks
Default: Sum over 5 minutes
Stability: Deprecated
MetricElbAuthError(IMetricOptions?)
(deprecated) The number of user authentications that could not be completed.
[Obsolete("Use ``ApplicationLoadBalancer.metrics.elbAuthError`` instead")]
public virtual Metric MetricElbAuthError(IMetricOptions? props = null)
Parameters
- props IMetricOptions
Returns
Remarks
Because an authenticate action was misconfigured, the load balancer couldn't establish a connection with the IdP, or the load balancer couldn't complete the authentication flow due to an internal error.
Default: Sum over 5 minutes
Stability: Deprecated
MetricElbAuthFailure(IMetricOptions?)
(deprecated) The number of user authentications that could not be completed because the IdP denied access to the user or an authorization code was used more than once.
[Obsolete("Use ``ApplicationLoadBalancer.metrics.elbAuthFailure`` instead")]
public virtual Metric MetricElbAuthFailure(IMetricOptions? props = null)
Parameters
- props IMetricOptions
Returns
Remarks
Default: Sum over 5 minutes
Stability: Deprecated
MetricElbAuthLatency(IMetricOptions?)
(deprecated) The time elapsed, in milliseconds, to query the IdP for the ID token and user info.
[Obsolete("Use ``ApplicationLoadBalancer.metrics.elbAuthLatency`` instead")]
public virtual Metric MetricElbAuthLatency(IMetricOptions? props = null)
Parameters
- props IMetricOptions
Returns
Remarks
If one or more of these operations fail, this is the time to failure.
Default: Average over 5 minutes
Stability: Deprecated
MetricElbAuthSuccess(IMetricOptions?)
(deprecated) The number of authenticate actions that were successful.
[Obsolete("Use ``ApplicationLoadBalancer.metrics.elbAuthSuccess`` instead")]
public virtual Metric MetricElbAuthSuccess(IMetricOptions? props = null)
Parameters
- props IMetricOptions
Returns
Remarks
This metric is incremented at the end of the authentication workflow, after the load balancer has retrieved the user claims from the IdP.
Default: Sum over 5 minutes
Stability: Deprecated
MetricHttpCodeElb(HttpCodeElb, IMetricOptions?)
(deprecated) The number of HTTP 3xx/4xx/5xx codes that originate from the load balancer.
[Obsolete("Use ``ApplicationLoadBalancer.metrics.httpCodeElb`` instead")]
public virtual Metric MetricHttpCodeElb(HttpCodeElb code, IMetricOptions? props = null)
Parameters
- code HttpCodeElb
- props IMetricOptions
Returns
Remarks
This does not include any response codes generated by the targets.
Default: Sum over 5 minutes
Stability: Deprecated
MetricHttpCodeTarget(HttpCodeTarget, IMetricOptions?)
(deprecated) The number of HTTP 2xx/3xx/4xx/5xx response codes generated by all targets in the load balancer.
[Obsolete("Use ``ApplicationLoadBalancer.metrics.httpCodeTarget`` instead")]
public virtual Metric MetricHttpCodeTarget(HttpCodeTarget code, IMetricOptions? props = null)
Parameters
- code HttpCodeTarget
- props IMetricOptions
Returns
Remarks
This does not include any response codes generated by the load balancer.
Default: Sum over 5 minutes
Stability: Deprecated
MetricHttpFixedResponseCount(IMetricOptions?)
(deprecated) The number of fixed-response actions that were successful.
[Obsolete("Use ``ApplicationLoadBalancer.metrics.httpFixedResponseCount`` instead")]
public virtual Metric MetricHttpFixedResponseCount(IMetricOptions? props = null)
Parameters
- props IMetricOptions
Returns
Remarks
Default: Sum over 5 minutes
Stability: Deprecated
MetricHttpRedirectCount(IMetricOptions?)
(deprecated) The number of redirect actions that were successful.
[Obsolete("Use ``ApplicationLoadBalancer.metrics.httpRedirectCount`` instead")]
public virtual Metric MetricHttpRedirectCount(IMetricOptions? props = null)
Parameters
- props IMetricOptions
Returns
Remarks
Default: Sum over 5 minutes
Stability: Deprecated
MetricHttpRedirectUrlLimitExceededCount(IMetricOptions?)
(deprecated) The number of redirect actions that couldn't be completed because the URL in the response location header is larger than 8K.
[Obsolete("Use ``ApplicationLoadBalancer.metrics.httpRedirectUrlLimitExceededCount`` instead")]
public virtual Metric MetricHttpRedirectUrlLimitExceededCount(IMetricOptions? props = null)
Parameters
- props IMetricOptions
Returns
Remarks
Default: Sum over 5 minutes
Stability: Deprecated
MetricIpv6ProcessedBytes(IMetricOptions?)
(deprecated) The total number of bytes processed by the load balancer over IPv6.
[Obsolete("Use ``ApplicationLoadBalancer.metrics.ipv6ProcessedBytes`` instead")]
public virtual Metric MetricIpv6ProcessedBytes(IMetricOptions? props = null)
Parameters
- props IMetricOptions
Returns
Remarks
Default: Sum over 5 minutes
Stability: Deprecated
MetricIpv6RequestCount(IMetricOptions?)
(deprecated) The number of IPv6 requests received by the load balancer.
[Obsolete("Use ``ApplicationLoadBalancer.metrics.ipv6RequestCount`` instead")]
public virtual Metric MetricIpv6RequestCount(IMetricOptions? props = null)
Parameters
- props IMetricOptions
Returns
Remarks
Default: Sum over 5 minutes
Stability: Deprecated
MetricNewConnectionCount(IMetricOptions?)
(deprecated) The total number of new TCP connections established from clients to the load balancer and from the load balancer to targets.
[Obsolete("Use ``ApplicationLoadBalancer.metrics.newConnectionCount`` instead")]
public virtual Metric MetricNewConnectionCount(IMetricOptions? props = null)
Parameters
- props IMetricOptions
Returns
Remarks
Default: Sum over 5 minutes
Stability: Deprecated
MetricProcessedBytes(IMetricOptions?)
(deprecated) The total number of bytes processed by the load balancer over IPv4 and IPv6.
[Obsolete("Use ``ApplicationLoadBalancer.metrics.processedBytes`` instead")]
public virtual Metric MetricProcessedBytes(IMetricOptions? props = null)
Parameters
- props IMetricOptions
Returns
Remarks
Default: Sum over 5 minutes
Stability: Deprecated
MetricRejectedConnectionCount(IMetricOptions?)
(deprecated) The number of connections that were rejected because the load balancer had reached its maximum number of connections.
[Obsolete("Use ``ApplicationLoadBalancer.metrics.rejectedConnectionCount`` instead")]
public virtual Metric MetricRejectedConnectionCount(IMetricOptions? props = null)
Parameters
- props IMetricOptions
Returns
Remarks
Default: Sum over 5 minutes
Stability: Deprecated
MetricRequestCount(IMetricOptions?)
(deprecated) The number of requests processed over IPv4 and IPv6.
[Obsolete("Use ``ApplicationLoadBalancer.metrics.requestCount`` instead")]
public virtual Metric MetricRequestCount(IMetricOptions? props = null)
Parameters
- props IMetricOptions
Returns
Remarks
This count includes only the requests with a response generated by a target of the load balancer.
Default: Sum over 5 minutes
Stability: Deprecated
MetricRuleEvaluations(IMetricOptions?)
(deprecated) The number of rules processed by the load balancer given a request rate averaged over an hour.
[Obsolete("Use ``ApplicationLoadBalancer.metrics.ruleEvaluations`` instead")]
public virtual Metric MetricRuleEvaluations(IMetricOptions? props = null)
Parameters
- props IMetricOptions
Returns
Remarks
Default: Sum over 5 minutes
Stability: Deprecated
MetricTargetConnectionErrorCount(IMetricOptions?)
(deprecated) The number of connections that were not successfully established between the load balancer and target.
[Obsolete("Use ``ApplicationLoadBalancer.metrics.targetConnectionErrorCount`` instead")]
public virtual Metric MetricTargetConnectionErrorCount(IMetricOptions? props = null)
Parameters
- props IMetricOptions
Returns
Remarks
Default: Sum over 5 minutes
Stability: Deprecated
MetricTargetResponseTime(IMetricOptions?)
(deprecated) The time elapsed, in seconds, after the request leaves the load balancer until a response from the target is received.
[Obsolete("Use ``ApplicationLoadBalancer.metrics.targetResponseTime`` instead")]
public virtual Metric MetricTargetResponseTime(IMetricOptions? props = null)
Parameters
- props IMetricOptions
Returns
Remarks
Default: Average over 5 minutes
Stability: Deprecated
MetricTargetTLSNegotiationErrorCount(IMetricOptions?)
(deprecated) The number of TLS connections initiated by the load balancer that did not establish a session with the target.
[Obsolete("Use ``ApplicationLoadBalancer.metrics.targetTLSNegotiationErrorCount`` instead")]
public virtual Metric MetricTargetTLSNegotiationErrorCount(IMetricOptions? props = null)
Parameters
- props IMetricOptions
Returns
Remarks
Possible causes include a mismatch of ciphers or protocols.
Default: Sum over 5 minutes
Stability: Deprecated