ApplicationListenerRule

class aws_cdk.aws_elasticloadbalancingv2.ApplicationListenerRule(scope, id, *, listener, action=None, conditions=None, fixed_response=None, host_header=None, path_pattern=None, path_patterns=None, priority, redirect_response=None, target_groups=None)

Bases: aws_cdk.core.Construct

Define a new listener rule.

Example:

# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk.aws_elasticloadbalancingv2 as elbv2

# application_listener is of type ApplicationListener
# application_target_group is of type ApplicationTargetGroup
# listener_action is of type ListenerAction
# listener_condition is of type ListenerCondition

application_listener_rule = elbv2.ApplicationListenerRule(self, "MyApplicationListenerRule",
    listener=application_listener,
    priority=123,

    # the properties below are optional
    action=listener_action,
    conditions=[listener_condition],
    fixed_response=elbv2.FixedResponse(
        status_code="statusCode",

        # the properties below are optional
        content_type=elbv2.ContentType.TEXT_PLAIN,
        message_body="messageBody"
    ),
    host_header="hostHeader",
    path_pattern="pathPattern",
    path_patterns=["pathPatterns"],
    redirect_response=elbv2.RedirectResponse(
        status_code="statusCode",

        # the properties below are optional
        host="host",
        path="path",
        port="port",
        protocol="protocol",
        query="query"
    ),
    target_groups=[application_target_group]
)
Parameters
  • scope (Construct) –

  • id (str) –

  • listener (IApplicationListener) – The listener to attach the rule to.

  • action (Optional[ListenerAction]) – Action to perform when requests are received. Only one of action, fixedResponse, redirectResponse or targetGroups can be specified. Default: - No action

  • conditions (Optional[Sequence[ListenerCondition]]) – Rule applies if matches the conditions. Default: - No conditions.

  • fixed_response (Optional[FixedResponse]) – (deprecated) Fixed response to return. Only one of action, fixedResponse, redirectResponse or targetGroups can be specified. Default: - No fixed response.

  • host_header (Optional[str]) – (deprecated) Rule applies if the requested host matches the indicated host. May contain up to three ‘*’ wildcards. Default: - No host condition.

  • path_pattern (Optional[str]) – (deprecated) Rule applies if the requested path matches the given path pattern. Default: - No path condition.

  • path_patterns (Optional[Sequence[str]]) – (deprecated) Rule applies if the requested path matches any of the given patterns. Paths may contain up to three ‘*’ wildcards. Default: - No path conditions.

  • priority (Union[int, float]) – Priority of the rule. The rule with the lowest priority will be used for every request. Priorities must be unique.

  • redirect_response (Optional[RedirectResponse]) – (deprecated) Redirect response to return. Only one of action, fixedResponse, redirectResponse or targetGroups can be specified. Default: - No redirect response.

  • target_groups (Optional[Sequence[IApplicationTargetGroup]]) – Target groups to forward requests to. Only one of action, fixedResponse, redirectResponse or targetGroups can be specified. Implies a forward action. Default: - No target groups.

Methods

add_condition(condition)

Add a non-standard condition to this rule.

Parameters

condition (ListenerCondition) –

Return type

None

add_fixed_response(*, content_type=None, message_body=None, status_code)

(deprecated) Add a fixed response.

Parameters
  • content_type (Optional[ContentType]) – (deprecated) The content type. Default: text/plain

  • message_body (Optional[str]) – (deprecated) The message. Default: no message

  • status_code (str) – (deprecated) The HTTP response code (2XX, 4XX or 5XX).

Deprecated

Use configureAction instead

Stability

deprecated

Return type

None

add_redirect_response(*, host=None, path=None, port=None, protocol=None, query=None, status_code)

(deprecated) Add a redirect response.

Parameters
  • host (Optional[str]) – (deprecated) The hostname. This component is not percent-encoded. The hostname can contain #{host}. Default: origin host of request

  • path (Optional[str]) – (deprecated) The absolute path, starting with the leading “/”. This component is not percent-encoded. The path can contain #{host}, #{path}, and #{port}. Default: origin path of request

  • port (Optional[str]) – (deprecated) The port. You can specify a value from 1 to 65535 or #{port}. Default: origin port of request

  • protocol (Optional[str]) – (deprecated) The protocol. You can specify HTTP, HTTPS, or #{protocol}. You can redirect HTTP to HTTP, HTTP to HTTPS, and HTTPS to HTTPS. You cannot redirect HTTPS to HTTP. Default: origin protocol of request

  • query (Optional[str]) – (deprecated) The query parameters, URL-encoded when necessary, but not percent-encoded. Do not include the leading “?”, as it is automatically added. You can specify any of the reserved keywords. Default: origin query string of request

  • status_code (str) – (deprecated) The HTTP redirect code (HTTP_301 or HTTP_302).

Deprecated

Use configureAction instead

Stability

deprecated

Return type

None

add_target_group(target_group)

(deprecated) Add a TargetGroup to load balance to.

Parameters

target_group (IApplicationTargetGroup) –

Deprecated

Use configureAction instead

Stability

deprecated

Return type

None

configure_action(action)

Configure the action to perform for this rule.

Parameters

action (ListenerAction) –

Return type

None

set_condition(field, values=None)

(deprecated) Add a non-standard condition to this rule.

If the condition conflicts with an already set condition, it will be overwritten by the one you specified.

Parameters
  • field (str) –

  • values (Optional[Sequence[str]]) –

Deprecated

use addCondition instead.

Stability

deprecated

Return type

None

to_string()

Returns a string representation of this construct.

Return type

str

Attributes

listener_rule_arn

The ARN of this rule.

Return type

str

node

The construct tree node associated with this construct.

Return type

ConstructNode

Static Methods

classmethod is_construct(x)

Return whether the given object is a Construct.

Parameters

x (Any) –

Return type

bool