# RuleConditionProperty

Specifies a condition for a listener rule.

- Source: Generated at build time
- Type last changed: v2.221.0 · 24 Oct 2025

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_elasticloadbalancingv2 as elbv2 } from 'aws-cdk-lib';
const ruleConditionProperty: elbv2.CfnListenerRule.RuleConditionProperty = {
  field: 'field',
  hostHeaderConfig: {
    regexValues: ['regexValues'],
    values: ['values'],
  },
  httpHeaderConfig: {
    httpHeaderName: 'httpHeaderName',
    regexValues: ['regexValues'],
    values: ['values'],
  },
  httpRequestMethodConfig: {
    values: ['values'],
  },
  pathPatternConfig: {
    regexValues: ['regexValues'],
    values: ['values'],
  },
  queryStringConfig: {
    values: [{
      key: 'key',
      value: 'value',
    }],
  },
  regexValues: ['regexValues'],
  sourceIpConfig: {
    ipAddressType: 'ipAddressType',
    values: ['values'],
  },
  values: ['values'],
};
```

Python:

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

rule_condition_property = elbv2.CfnListenerRule.RuleConditionProperty(
    field="field",
    host_header_config=elbv2.CfnListenerRule.HostHeaderConfigProperty(
        regex_values=["regexValues"],
        values=["values"]
    ),
    http_header_config=elbv2.CfnListenerRule.HttpHeaderConfigProperty(
        http_header_name="httpHeaderName",
        regex_values=["regexValues"],
        values=["values"]
    ),
    http_request_method_config=elbv2.CfnListenerRule.HttpRequestMethodConfigProperty(
        values=["values"]
    ),
    path_pattern_config=elbv2.CfnListenerRule.PathPatternConfigProperty(
        regex_values=["regexValues"],
        values=["values"]
    ),
    query_string_config=elbv2.CfnListenerRule.QueryStringConfigProperty(
        values=[elbv2.CfnListenerRule.QueryStringKeyValueProperty(
            key="key",
            value="value"
        )]
    ),
    regex_values=["regexValues"],
    source_ip_config=elbv2.CfnListenerRule.SourceIpConfigProperty(
        ip_address_type="ipAddressType",
        values=["values"]
    ),
    values=["values"]
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.elasticloadbalancingv2.*;

RuleConditionProperty ruleConditionProperty = RuleConditionProperty.builder()
        .field("field")
        .hostHeaderConfig(HostHeaderConfigProperty.builder()
                .regexValues(List.of("regexValues"))
                .values(List.of("values"))
                .build())
        .httpHeaderConfig(HttpHeaderConfigProperty.builder()
                .httpHeaderName("httpHeaderName")
                .regexValues(List.of("regexValues"))
                .values(List.of("values"))
                .build())
        .httpRequestMethodConfig(HttpRequestMethodConfigProperty.builder()
                .values(List.of("values"))
                .build())
        .pathPatternConfig(PathPatternConfigProperty.builder()
                .regexValues(List.of("regexValues"))
                .values(List.of("values"))
                .build())
        .queryStringConfig(QueryStringConfigProperty.builder()
                .values(List.of(QueryStringKeyValueProperty.builder()
                        .key("key")
                        .value("value")
                        .build()))
                .build())
        .regexValues(List.of("regexValues"))
        .sourceIpConfig(SourceIpConfigProperty.builder()
                .ipAddressType("ipAddressType")
                .values(List.of("values"))
                .build())
        .values(List.of("values"))
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.ElasticLoadBalancingV2;

var ruleConditionProperty = new RuleConditionProperty {
    Field = "field",
    HostHeaderConfig = new HostHeaderConfigProperty {
        RegexValues = new [] { "regexValues" },
        Values = new [] { "values" }
    },
    HttpHeaderConfig = new HttpHeaderConfigProperty {
        HttpHeaderName = "httpHeaderName",
        RegexValues = new [] { "regexValues" },
        Values = new [] { "values" }
    },
    HttpRequestMethodConfig = new HttpRequestMethodConfigProperty {
        Values = new [] { "values" }
    },
    PathPatternConfig = new PathPatternConfigProperty {
        RegexValues = new [] { "regexValues" },
        Values = new [] { "values" }
    },
    QueryStringConfig = new QueryStringConfigProperty {
        Values = new [] { new QueryStringKeyValueProperty {
            Key = "key",
            Value = "value"
        } }
    },
    RegexValues = new [] { "regexValues" },
    SourceIpConfig = new SourceIpConfigProperty {
        IpAddressType = "ipAddressType",
        Values = new [] { "values" }
    },
    Values = new [] { "values" }
};
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

ruleConditionProperty := &RuleConditionProperty{
	Field: jsii.String("field"),
	HostHeaderConfig: &HostHeaderConfigProperty{
		RegexValues: []*string{
			jsii.String("regexValues"),
		},
		Values: []*string{
			jsii.String("values"),
		},
	},
	HttpHeaderConfig: &HttpHeaderConfigProperty{
		HttpHeaderName: jsii.String("httpHeaderName"),
		RegexValues: []*string{
			jsii.String("regexValues"),
		},
		Values: []*string{
			jsii.String("values"),
		},
	},
	HttpRequestMethodConfig: &HttpRequestMethodConfigProperty{
		Values: []*string{
			jsii.String("values"),
		},
	},
	PathPatternConfig: &PathPatternConfigProperty{
		RegexValues: []*string{
			jsii.String("regexValues"),
		},
		Values: []*string{
			jsii.String("values"),
		},
	},
	QueryStringConfig: &QueryStringConfigProperty{
		Values: []interface{}{
			&QueryStringKeyValueProperty{
				Key: jsii.String("key"),
				Value: jsii.String("value"),
			},
		},
	},
	RegexValues: []*string{
		jsii.String("regexValues"),
	},
	SourceIpConfig: &SourceIpConfigProperty{
		IpAddressType: jsii.String("ipAddressType"),
		Values: []*string{
			jsii.String("values"),
		},
	},
	Values: []*string{
		jsii.String("values"),
	},
}
```

## Properties

- `field`: string — The field in the HTTP request. The following are the possible values:.

  - `http-header`
  - `http-request-method`
  - `host-header`
  - `path-pattern`
  - `query-string`
  - `source-ip`

- `hostHeaderConfig`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnListenerRule.HostHeaderConfigProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.CfnListenerRule.HostHeaderConfigProperty.html) — Information for a host header condition.

  Specify only when `Field` is `host-header` .

- `httpHeaderConfig`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnListenerRule.HttpHeaderConfigProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.CfnListenerRule.HttpHeaderConfigProperty.html) — Information for an HTTP header condition.

  Specify only when `Field` is `http-header` .

- `httpRequestMethodConfig`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnListenerRule.HttpRequestMethodConfigProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.CfnListenerRule.HttpRequestMethodConfigProperty.html) — Information for an HTTP method condition.

  Specify only when `Field` is `http-request-method` .

- `pathPatternConfig`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnListenerRule.PathPatternConfigProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.CfnListenerRule.PathPatternConfigProperty.html) — Information for a path pattern condition.

  Specify only when `Field` is `path-pattern` .

- `queryStringConfig`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnListenerRule.QueryStringConfigProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.CfnListenerRule.QueryStringConfigProperty.html) — Information for a query string condition.

  Specify only when `Field` is `query-string` .

- `regexValues`: string[] — The regular expressions to match against the condition field.

  The maximum length of each string is 128 characters. Specify only when `Field` is `http-header` , `host-header` , or `path-pattern` .

- `sourceIpConfig`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnListenerRule.SourceIpConfigProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.CfnListenerRule.SourceIpConfigProperty.html) — Information for a source IP condition.

  Specify only when `Field` is `source-ip` .

- `values`: string[] — The condition value.

  Specify only when `Field` is `host-header` or `path-pattern` . Alternatively, to specify multiple host names or multiple path patterns, use `HostHeaderConfig` or `PathPatternConfig` .

  If `Field` is `host-header` and you're not using `HostHeaderConfig` , 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.

  - A-Z, a-z, 0-9
  - - .
  - * (matches 0 or more characters)
  - ? (matches exactly 1 character)

  If `Field` is `path-pattern` and you're not using `PathPatternConfig` , you can specify a single path pattern (for example, /img/*). A path pattern is case-sensitive, can be up to 128 characters in length, and can contain any of the following characters.

  - A-Z, a-z, 0-9
  - _ - . $ / ~ " ' @ : +
  - & (using &)
  - * (matches 0 or more characters)
  - ? (matches exactly 1 character)
