ApplicationListenerRule
- class aws_cdk.aws_elasticloadbalancingv2.ApplicationListenerRule(scope, id, *, listener, priority, action=None, conditions=None, target_groups=None)
Bases:
ConstructDefine a new listener rule.
- ExampleMetadata:
infused
Example:
import aws_cdk.aws_lambda as lambda_ # cluster: ecs.Cluster # task_definition: ecs.TaskDefinition # lambda_hook: lambda.Function # blue_target_group: elbv2.ApplicationTargetGroup # green_target_group: elbv2.ApplicationTargetGroup # prod_listener_rule: elbv2.ApplicationListenerRule service = ecs.FargateService(self, "Service", cluster=cluster, task_definition=task_definition, deployment_strategy=ecs.DeploymentStrategy.BLUE_GREEN ) service.add_lifecycle_hook(ecs.DeploymentLifecycleLambdaTarget(lambda_hook, "PreScaleHook", lifecycle_stages=[ecs.DeploymentLifecycleStage.PRE_SCALE_UP] )) target = service.load_balancer_target( container_name="nginx", container_port=80, protocol=ecs.Protocol.TCP, alternate_target=ecs.AlternateTarget("AlternateTarget", alternate_target_group=green_target_group, production_listener=ecs.ListenerRuleConfiguration.application_listener_rule(prod_listener_rule) ) ) target.attach_to_application_target_group(blue_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,redirectResponseortargetGroupscan be specified. Default: - No actionconditions (
Optional[Sequence[ListenerCondition]]) – Rule applies if matches the conditions. Default: - No conditions.target_groups (
Optional[Sequence[IApplicationTargetGroup]]) – Target groups to forward requests to. Only one ofaction,fixedResponse,redirectResponseortargetGroupscan be specified. Implies aforwardaction. Default: - No target groups.
Methods
- add_condition(condition)
Add a non-standard condition to this rule.
- Parameters:
condition (
ListenerCondition)- Return type:
None
- configure_action(action)
Configure the action to perform for this rule.
- Parameters:
action (
ListenerAction)- 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 tree node.
Static Methods
- classmethod is_construct(x)
Checks if
xis a construct.Use this method instead of
instanceofto properly detectConstructinstances, even when the construct library is symlinked.Explanation: in JavaScript, multiple copies of the
constructslibrary on disk are seen as independent, completely different libraries. As a consequence, the classConstructin each copy of theconstructslibrary is seen as a different class, and an instance of one class will not test asinstanceofthe other class.npm installwill not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of theconstructslibrary can be accidentally installed, andinstanceofwill behave unpredictably. It is safest to avoid usinginstanceof, and using this type-testing method instead.- Parameters:
x (
Any) – Any object.- Return type:
bool- Returns:
true if
xis an object created from a class which extendsConstruct.