class ApplicationListenerRule (construct)
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.ElasticLoadBalancingV2.ApplicationListenerRule |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awselasticloadbalancingv2#ApplicationListenerRule |
Java | software.amazon.awscdk.services.elasticloadbalancingv2.ApplicationListenerRule |
Python | aws_cdk.aws_elasticloadbalancingv2.ApplicationListenerRule |
TypeScript (source) | aws-cdk-lib » aws_elasticloadbalancingv2 » ApplicationListenerRule |
Implements
IConstruct, IDependable
Define a new listener rule.
Example
declare const cluster: ecs.Cluster;
declare const taskDefinition: ecs.TaskDefinition;
declare const blueTargetGroup: elbv2.ApplicationTargetGroup;
declare const greenTargetGroup: elbv2.ApplicationTargetGroup;
declare const prodListenerRule: elbv2.ApplicationListenerRule;
const service = new ecs.FargateService(this, 'Service', {
cluster,
taskDefinition,
deploymentStrategy: ecs.DeploymentStrategy.LINEAR,
linearConfiguration: {
stepPercent: 10.0,
stepBakeTime: Duration.minutes(5),
},
});
const target = service.loadBalancerTarget({
containerName: 'web',
containerPort: 80,
alternateTarget: new ecs.AlternateTarget('AlternateTarget', {
alternateTargetGroup: greenTargetGroup,
productionListener: ecs.ListenerRuleConfiguration.applicationListenerRule(prodListenerRule),
}),
});
target.attachToApplicationTargetGroup(blueTargetGroup);
Initializer
new ApplicationListenerRule(scope: Construct, id: string, props: ApplicationListenerRuleProps)
Parameters
- scope
Construct - id
string - props
ApplicationListener Rule Props
Construct Props
| Name | Type | Description |
|---|---|---|
| listener | IApplication | The listener to attach the rule to. |
| priority | number | Priority of the rule. |
| action? | Listener | Action to perform when requests are received. |
| conditions? | Listener[] | Rule applies if matches the conditions. |
| target | IApplication[] | Target groups to forward requests to. |
listener
Type:
IApplication
The listener to attach the rule to.
priority
Type:
number
Priority of the rule.
The rule with the lowest priority will be used for every request.
Priorities must be unique.
action?
Type:
Listener
(optional, default: No action)
Action to perform when requests are received.
Only one of action, fixedResponse, redirectResponse or targetGroups can be specified.
conditions?
Type:
Listener[]
(optional, default: No conditions.)
Rule applies if matches the conditions.
targetGroups?
Type:
IApplication[]
(optional, default: No target groups.)
Target groups to forward requests to.
Only one of action, fixedResponse, redirectResponse or targetGroups can be specified.
Implies a forward action.
Properties
| Name | Type | Description |
|---|---|---|
| listener | string | The ARN of this rule. |
| node | Node | The tree node. |
listenerRuleArn
Type:
string
The ARN of this rule.
node
Type:
Node
The tree node.
Methods
| Name | Description |
|---|---|
| add | Add a non-standard condition to this rule. |
| configure | Configure the action to perform for this rule. |
| to | Returns a string representation of this construct. |
| with(...mixins) | Applies one or more mixins to this construct. |
addCondition(condition)
public addCondition(condition: ListenerCondition): void
Parameters
- condition
ListenerCondition
Add a non-standard condition to this rule.
configureAction(action)
public configureAction(action: ListenerAction): void
Parameters
- action
ListenerAction
Configure the action to perform for this rule.
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.
with(...mixins)
public with(...mixins: IMixin[]): IConstruct
Parameters
- mixins
IMixin— The mixins to apply.
Returns
Applies one or more mixins to this construct.
Mixins are applied in order. The list of constructs is captured at the
start of the call, so constructs added by a mixin will not be visited.
Use multiple with() calls if subsequent mixins should apply to added
constructs.

.NET
Go
Java
Python
TypeScript (