AWS SDK Version 3 for .NET
API Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Container for the parameters to the CreateRule operation. Creates a rule for the specified listener. The listener must be associated with an Application Load Balancer.

Rules are evaluated in priority order, from the lowest value to the highest value. When the condition for a rule is met, the specified action is taken. If no conditions are met, the action for the default rule is taken. For more information, see Listener Rules in the Application Load Balancers Guide.

To view your current rules, use DescribeRules. To update a rule, use ModifyRule. To set the priorities of your rules, use SetRulePriorities. To delete a rule, use DeleteRule.

Inheritance Hierarchy

System.Object
  Amazon.Runtime.AmazonWebServiceRequest
    Amazon.ElasticLoadBalancingV2.AmazonElasticLoadBalancingV2Request
      Amazon.ElasticLoadBalancingV2.Model.CreateRuleRequest

Namespace: Amazon.ElasticLoadBalancingV2.Model
Assembly: AWSSDK.ElasticLoadBalancingV2.dll
Version: 3.x.y.z

Syntax

C#
public class CreateRuleRequest : AmazonElasticLoadBalancingV2Request
         IAmazonWebServiceRequest

The CreateRuleRequest type exposes the following members

Constructors

NameDescription
Public Method CreateRuleRequest()

Properties

NameTypeDescription
Public Property Actions System.Collections.Generic.List<Amazon.ElasticLoadBalancingV2.Model.Action>

Gets and sets the property Actions.

An action. Each action has the type forward and specifies a target group.

Public Property Conditions System.Collections.Generic.List<Amazon.ElasticLoadBalancingV2.Model.RuleCondition>

Gets and sets the property Conditions.

The conditions. Each condition specifies a field name and a single value.

If the field name is host-header, you can specify a single host name (for example, my.example.com). A host name is case insensitive, can be up to 128 characters in length, and can contain any of the following characters. Note that you can include up to three wildcard characters.

  • A-Z, a-z, 0-9

  • - .

  • * (matches 0 or more characters)

  • ? (matches exactly 1 character)

If the field name is path-pattern, you can specify a single path pattern. A path pattern is case sensitive, can be up to 128 characters in length, and can contain any of the following characters. Note that you can include up to three wildcard characters.

  • A-Z, a-z, 0-9

  • _ - . $ / ~ " ' @ : +

  • & (using &)

  • * (matches 0 or more characters)

  • ? (matches exactly 1 character)

Public Property ListenerArn System.String

Gets and sets the property ListenerArn.

The Amazon Resource Name (ARN) of the listener.

Public Property Priority System.Int32

Gets and sets the property Priority.

The priority for the rule. A listener can't have multiple rules with the same priority.

Examples

This example creates a rule that forwards requests to the specified target group if the URL contains the specified pattern (for example, /img/*).

To create a rule


var response = client.CreateRule(new CreateRuleRequest 
{
    Actions = new List {
        new Action {
            TargetGroupArn = "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067",
            Type = "forward"
        }
    },
    Conditions = new List {
        new RuleCondition {
            Field = "path-pattern",
            Values = new List {
                "/img/*"
            }
        }
    },
    ListenerArn = "arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2",
    Priority = 10
});

List rules = response.Rules;

            

Version Information

.NET Standard:
Supported in: 1.3

.NET Framework:
Supported in: 4.5, 4.0, 3.5

Portable Class Library:
Supported in: Windows Store Apps
Supported in: Windows Phone 8.1
Supported in: Xamarin Android
Supported in: Xamarin iOS (Unified)
Supported in: Xamarin.Forms