ApplicationListenerRule
- class aws_cdk.aws_elasticloadbalancingv2.ApplicationListenerRule(scope, id, *, listener, priority, action=None, conditions=None, fixed_response=None, host_header=None, path_pattern=None, path_patterns=None, redirect_response=None, target_groups=None)
Bases:
Construct
Define a new listener rule.
- ExampleMetadata:
fixture=_generated
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: elbv2.ApplicationListener # application_target_group: elbv2.ApplicationTargetGroup # listener_action: elbv2.ListenerAction # listener_condition: elbv2.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.priority (
Union
[int
,float
]) – Priority of the rule. The rule with the lowest priority will be used for every request. Priorities must be unique.action (
Optional
[ListenerAction
]) – Action to perform when requests are received. Only one ofaction
,fixedResponse
,redirectResponse
ortargetGroups
can be specified. Default: - No actionconditions (
Optional
[Sequence
[ListenerCondition
]]) – Rule applies if matches the conditions. Default: - No conditions.fixed_response (
Union
[FixedResponse
,Dict
[str
,Any
],None
]) – (deprecated) Fixed response to return. Only one ofaction
,fixedResponse
,redirectResponse
ortargetGroups
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.redirect_response (
Union
[RedirectResponse
,Dict
[str
,Any
],None
]) – (deprecated) Redirect response to return. Only one ofaction
,fixedResponse
,redirectResponse
ortargetGroups
can be specified. Default: - No redirect response.target_groups (
Optional
[Sequence
[IApplicationTargetGroup
]]) – Target groups to forward requests to. Only one ofaction
,fixedResponse
,redirectResponse
ortargetGroups
can be specified. Implies aforward
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(*, status_code, content_type=None, message_body=None)
(deprecated) Add a fixed response.
- Parameters:
status_code (
str
) – (deprecated) The HTTP response code (2XX, 4XX or 5XX).content_type (
Optional
[ContentType
]) – (deprecated) The content type. Default: text/plainmessage_body (
Optional
[str
]) – (deprecated) The message. Default: no message
- Deprecated:
Use configureAction instead
- Stability:
deprecated
- Return type:
None
- add_redirect_response(*, status_code, host=None, path=None, port=None, protocol=None, query=None)
(deprecated) Add a redirect response.
- Parameters:
status_code (
str
) – (deprecated) The HTTP redirect code (HTTP_301 or HTTP_302).host (
Optional
[str
]) – (deprecated) The hostname. This component is not percent-encoded. The hostname can contain #{host}. Default: origin host of requestpath (
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 requestport (
Optional
[str
]) – (deprecated) The port. You can specify a value from 1 to 65535 or #{port}. Default: origin port of requestprotocol (
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 requestquery (
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
- 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.
- node
The construct tree node associated with this construct.
Static Methods
- classmethod is_construct(x)
Return whether the given object is a Construct.
- Parameters:
x (
Any
)- Return type:
bool