# Reference for the teleport\_login\_rule Terraform resource

This page describes the supported values of the teleport\_login\_rule resource of the Teleport Terraform provider.

## Example Usage

```
# Teleport Login Rule resource

resource "teleport_login_rule" "example" {
  metadata = {
    description = "Example Login Rule"
    labels = {
      "example" = "yes"
    }
  }

  version  = "v1"
  priority = 0

  # Either traits_map or traits_expression must be provided, but not both.
  traits_map = {
    "logins" = {
      values = [
        "external.logins",
        "external.username",
      ]
    }
    "groups" = {
      values = [
        "external.groups",
      ]
    }
  }
  #   # This traits_expression is functionally equivalent to the traits_map above.
  #   traits_expression = <<EOF
  # dict(
  #   pair("logins", union(external.logins, external.username))
  #   pair("groups", external.groups))
  # EOF
}

```

## Schema

### Required

- `priority` (Number) Priority is the priority of the login rule relative to other login rules in the same cluster. Login rules with a lower numbered priority will be evaluated first.
- `version` (String) Version is the resource version.

### Optional

- `metadata` (Attributes) Metadata is resource metadata. (see [below for nested schema](#nested-schema-for-metadata))
- `traits_expression` (String) TraitsExpression is a predicate expression which should return the desired traits for the user upon login.
- `traits_map` (Attributes Map) TraitsMap is a map of trait keys to lists of predicate expressions which should evaluate to the desired values for that trait. (see [below for nested schema](#nested-schema-for-traits_map))

### Nested Schema for `metadata`

Required:

- `name` (String) Name is an object name

Optional:

- `description` (String) Description is object description
- `expires` (String) Expires is a global expiry time header can be set on any resource in the system.
- `labels` (Map of String) Labels is a set of labels

### Nested Schema for `traits_map`

Optional:

- `values` (List of String)
