diff --git a/docs/content/providers/ecs.md b/docs/content/providers/ecs.md index 282da12aa..629a7a394 100644 --- a/docs/content/providers/ecs.md +++ b/docs/content/providers/ecs.md @@ -137,6 +137,70 @@ providers: # ... ``` +### `constraints` + +_Optional, Default=""_ + +The `constraints` option can be set to an expression that Traefik matches against the container labels (task), +to determine whether to create any route for that container. +If none of the container labels match the expression, no route for that container is created. +If the expression is empty, all detected containers are included. + +The expression syntax is based on the `Label("key", "value")`, and `LabelRegex("key", "value")` functions, +as well as the usual boolean logic, as shown in examples below. + +??? example "Constraints Expression Examples" + + ```toml + # Includes only containers having a label with key `a.label.name` and value `foo` + constraints = "Label(`a.label.name`, `foo`)" + ``` + + ```toml + # Excludes containers having any label with key `a.label.name` and value `foo` + constraints = "!Label(`a.label.name`, `value`)" + ``` + + ```toml + # With logical AND. + constraints = "Label(`a.label.name`, `valueA`) && Label(`another.label.name`, `valueB`)" + ``` + + ```toml + # With logical OR. + constraints = "Label(`a.label.name`, `valueA`) || Label(`another.label.name`, `valueB`)" + ``` + + ```toml + # With logical AND and OR, with precedence set by parentheses. + constraints = "Label(`a.label.name`, `valueA`) && (Label(`another.label.name`, `valueB`) || Label(`yet.another.label.name`, `valueC`))" + ``` + + ```toml + # Includes only containers having a label with key `a.label.name` and a value matching the `a.+` regular expression. + constraints = "LabelRegex(`a.label.name`, `a.+`)" + ``` + +For additional information, refer to [Restrict the Scope of Service Discovery](./overview.md#restrict-the-scope-of-service-discovery). + +```yaml tab="File (YAML)" +providers: + ecs: + constraints: "Label(`a.label.name`,`foo`)" + # ... +``` + +```toml tab="File (TOML)" +[providers.ecs] + constraints = "Label(`a.label.name`,`foo`)" + # ... +``` + +```bash tab="CLI" +--providers.ecs.constraints=Label(`a.label.name`,`foo`) +# ... +``` + ### `defaultRule` _Optional, Default=```Host(`{{ normalize .Name }}`)```_ diff --git a/docs/content/providers/overview.md b/docs/content/providers/overview.md index 8366d1155..de0af45fe 100644 --- a/docs/content/providers/overview.md +++ b/docs/content/providers/overview.md @@ -213,6 +213,7 @@ you can do so in two different ways: List of providers that support these features: - [Docker](./docker.md#exposedbydefault) +- [ECS](./ecs.md#exposedbydefault) - [Consul Catalog](./consul-catalog.md#exposedbydefault) - [Nomad](./nomad.md#exposedbydefault) - [Rancher](./rancher.md#exposedbydefault) @@ -223,6 +224,7 @@ List of providers that support these features: List of providers that support constraints: - [Docker](./docker.md#constraints) +- [ECS](./ecs.md#constraints) - [Consul Catalog](./consul-catalog.md#constraints) - [Nomad](./nomad.md#constraints) - [Rancher](./rancher.md#constraints)