Skip to content

Creates a rule for the specified listener

Description

Creates a rule for the specified listener. The listener must be associated with an Application Load Balancer or a dual-stack Network Load Balancer.

Each rule consists of a priority, one or more actions, and one or more conditions. Rules are evaluated in priority order, from the lowest value to the highest value. When the conditions for a rule are met, its actions are performed. If the conditions for no rules are met, the actions for the default rule are performed. For more information, see Listener rules in the Application Load Balancers Guide or Listener rules in the Network Load Balancers Guide.

Usage

elbv2_create_rule(ListenerArn, Conditions, Priority, Actions, Tags,
  Transforms)

Arguments

  • ListenerArn

    [required] The Amazon Resource Name (ARN) of the listener.

  • Conditions

    [required] The conditions.

  • Priority

    [required] The rule priority. A listener can't have multiple rules with the same priority.

  • Actions

    [required] The actions.

  • Tags

    The tags to assign to the rule.

  • Transforms

    The transforms to apply to requests that match this rule. You can add one host header rewrite transform and one URL rewrite transform.

Value

A list with the following syntax:

list(
  Rules = list(
    list(
      RuleArn = "string",
      Priority = "string",
      Conditions = list(
        list(
          Field = "string",
          Values = list(
            "string"
          ),
          HostHeaderConfig = list(
            Values = list(
              "string"
            ),
            RegexValues = list(
              "string"
            )
          ),
          PathPatternConfig = list(
            Values = list(
              "string"
            ),
            RegexValues = list(
              "string"
            )
          ),
          HttpHeaderConfig = list(
            HttpHeaderName = "string",
            Values = list(
              "string"
            ),
            RegexValues = list(
              "string"
            )
          ),
          QueryStringConfig = list(
            Values = list(
              list(
                Key = "string",
                Value = "string"
              )
            )
          ),
          HttpRequestMethodConfig = list(
            Values = list(
              "string"
            )
          ),
          SourceIpConfig = list(
            Values = list(
              "string"
            ),
            IpAddressType = "ipv4"|"ipv6"
          ),
          RegexValues = list(
            "string"
          )
        )
      ),
      Actions = list(
        list(
          Type = "forward"|"authenticate-oidc"|"authenticate-cognito"|"redirect"|"fixed-response"|"jwt-validation",
          TargetGroupArn = "string",
          AuthenticateOidcConfig = list(
            Issuer = "string",
            AuthorizationEndpoint = "string",
            TokenEndpoint = "string",
            UserInfoEndpoint = "string",
            ClientId = "string",
            ClientSecret = "string",
            SessionCookieName = "string",
            Scope = "string",
            SessionTimeout = 123,
            AuthenticationRequestExtraParams = list(
              "string"
            ),
            OnUnauthenticatedRequest = "deny"|"allow"|"authenticate",
            UseExistingClientSecret = TRUE|FALSE
          ),
          AuthenticateCognitoConfig = list(
            UserPoolArn = "string",
            UserPoolClientId = "string",
            UserPoolDomain = "string",
            SessionCookieName = "string",
            Scope = "string",
            SessionTimeout = 123,
            AuthenticationRequestExtraParams = list(
              "string"
            ),
            OnUnauthenticatedRequest = "deny"|"allow"|"authenticate"
          ),
          Order = 123,
          RedirectConfig = list(
            Protocol = "string",
            Port = "string",
            Host = "string",
            Path = "string",
            Query = "string",
            StatusCode = "HTTP_301"|"HTTP_302"
          ),
          FixedResponseConfig = list(
            MessageBody = "string",
            StatusCode = "string",
            ContentType = "string"
          ),
          ForwardConfig = list(
            TargetGroups = list(
              list(
                TargetGroupArn = "string",
                Weight = 123
              )
            ),
            TargetGroupStickinessConfig = list(
              Enabled = TRUE|FALSE,
              DurationSeconds = 123
            )
          ),
          JwtValidationConfig = list(
            JwksEndpoint = "string",
            Issuer = "string",
            AdditionalClaims = list(
              list(
                Format = "single-string"|"string-array"|"space-separated-values",
                Name = "string",
                Values = list(
                  "string"
                )
              )
            )
          )
        )
      ),
      IsDefault = TRUE|FALSE,
      Transforms = list(
        list(
          Type = "host-header-rewrite"|"url-rewrite",
          HostHeaderRewriteConfig = list(
            Rewrites = list(
              list(
                Regex = "string",
                Replace = "string"
              )
            )
          ),
          UrlRewriteConfig = list(
            Rewrites = list(
              list(
                Regex = "string",
                Replace = "string"
              )
            )
          )
        )
      )
    )
  )
)

Request syntax

svc$create_rule(
  ListenerArn = "string",
  Conditions = list(
    list(
      Field = "string",
      Values = list(
        "string"
      ),
      HostHeaderConfig = list(
        Values = list(
          "string"
        ),
        RegexValues = list(
          "string"
        )
      ),
      PathPatternConfig = list(
        Values = list(
          "string"
        ),
        RegexValues = list(
          "string"
        )
      ),
      HttpHeaderConfig = list(
        HttpHeaderName = "string",
        Values = list(
          "string"
        ),
        RegexValues = list(
          "string"
        )
      ),
      QueryStringConfig = list(
        Values = list(
          list(
            Key = "string",
            Value = "string"
          )
        )
      ),
      HttpRequestMethodConfig = list(
        Values = list(
          "string"
        )
      ),
      SourceIpConfig = list(
        Values = list(
          "string"
        ),
        IpAddressType = "ipv4"|"ipv6"
      ),
      RegexValues = list(
        "string"
      )
    )
  ),
  Priority = 123,
  Actions = list(
    list(
      Type = "forward"|"authenticate-oidc"|"authenticate-cognito"|"redirect"|"fixed-response"|"jwt-validation",
      TargetGroupArn = "string",
      AuthenticateOidcConfig = list(
        Issuer = "string",
        AuthorizationEndpoint = "string",
        TokenEndpoint = "string",
        UserInfoEndpoint = "string",
        ClientId = "string",
        ClientSecret = "string",
        SessionCookieName = "string",
        Scope = "string",
        SessionTimeout = 123,
        AuthenticationRequestExtraParams = list(
          "string"
        ),
        OnUnauthenticatedRequest = "deny"|"allow"|"authenticate",
        UseExistingClientSecret = TRUE|FALSE
      ),
      AuthenticateCognitoConfig = list(
        UserPoolArn = "string",
        UserPoolClientId = "string",
        UserPoolDomain = "string",
        SessionCookieName = "string",
        Scope = "string",
        SessionTimeout = 123,
        AuthenticationRequestExtraParams = list(
          "string"
        ),
        OnUnauthenticatedRequest = "deny"|"allow"|"authenticate"
      ),
      Order = 123,
      RedirectConfig = list(
        Protocol = "string",
        Port = "string",
        Host = "string",
        Path = "string",
        Query = "string",
        StatusCode = "HTTP_301"|"HTTP_302"
      ),
      FixedResponseConfig = list(
        MessageBody = "string",
        StatusCode = "string",
        ContentType = "string"
      ),
      ForwardConfig = list(
        TargetGroups = list(
          list(
            TargetGroupArn = "string",
            Weight = 123
          )
        ),
        TargetGroupStickinessConfig = list(
          Enabled = TRUE|FALSE,
          DurationSeconds = 123
        )
      ),
      JwtValidationConfig = list(
        JwksEndpoint = "string",
        Issuer = "string",
        AdditionalClaims = list(
          list(
            Format = "single-string"|"string-array"|"space-separated-values",
            Name = "string",
            Values = list(
              "string"
            )
          )
        )
      )
    )
  ),
  Tags = list(
    list(
      Key = "string",
      Value = "string"
    )
  ),
  Transforms = list(
    list(
      Type = "host-header-rewrite"|"url-rewrite",
      HostHeaderRewriteConfig = list(
        Rewrites = list(
          list(
            Regex = "string",
            Replace = "string"
          )
        )
      ),
      UrlRewriteConfig = list(
        Rewrites = list(
          list(
            Regex = "string",
            Replace = "string"
          )
        )
      )
    )
  )
)

Examples

# This example creates a rule that forwards requests to the specified
# target group if the URL contains the specified pattern (for example,
# /img/*).
svc$create_rule(
  Actions = list(
    list(
      TargetGroupArn = "arn:aws:elasticloadbalancing:us-west-2:123456789012...",
      Type = "forward"
    )
  ),
  Conditions = list(
    list(
      Field = "path-pattern",
      Values = list(
        "/img/*"
      )
    )
  ),
  ListenerArn = "arn:aws:elasticloadbalancing:us-west-2:123456789012:listen...",
  Priority = 10L
)