paws.networking (version 0.1.6)

elbv2_create_rule: 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.

Usage

elbv2_create_rule(ListenerArn, Conditions, Priority, Actions)

Arguments

ListenerArn

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

Conditions

[required] The conditions. Each rule can include zero or one of the following conditions: http-request-method, host-header, path-pattern, and source-ip, and zero or more of the following conditions: http-header and query-string.

Priority

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

Actions

[required] The actions. Each rule must include exactly one of the following types of actions: forward, fixed-response, or redirect, and it must be the last action to be performed.

If the action type is forward, you specify one or more target groups. The protocol of the target group must be HTTP or HTTPS for an Application Load Balancer. The protocol of the target group must be TCP, TLS, UDP, or TCP\_UDP for a Network Load Balancer.

[HTTPS listeners] If the action type is authenticate-oidc, you authenticate users through an identity provider that is OpenID Connect (OIDC) compliant.

[HTTPS listeners] If the action type is authenticate-cognito, you authenticate users through the user pools supported by Amazon Cognito.

[Application Load Balancer] If the action type is redirect, you redirect specified client requests from one URL to another.

[Application Load Balancer] If the action type is fixed-response, you drop specified client requests and return a custom HTTP response.

Request syntax

svc$create_rule(
  ListenerArn = "string",
  Conditions = list(
    list(
      Field = "string",
      Values = list(
        "string"
      ),
      HostHeaderConfig = list(
        Values = list(
          "string"
        )
      ),
      PathPatternConfig = list(
        Values = list(
          "string"
        )
      ),
      HttpHeaderConfig = list(
        HttpHeaderName = "string",
        Values = list(
          "string"
        )
      ),
      QueryStringConfig = list(
        Values = list(
          list(
            Key = "string",
            Value = "string"
          )
        )
      ),
      HttpRequestMethodConfig = list(
        Values = list(
          "string"
        )
      ),
      SourceIpConfig = list(
        Values = list(
          "string"
        )
      )
    )
  ),
  Priority = 123,
  Actions = list(
    list(
      Type = "forward"|"authenticate-oidc"|"authenticate-cognito"|"redirect"|"fixed-response",
      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
        )
      )
    )
  )
)

Details

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.

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.

Examples

Run this code
# NOT RUN {
# This example creates a rule that forwards requests to the specified
# target group if the URL contains the specified pattern (for example,
# /img/*).
# }
# NOT RUN {
svc$create_rule(
  Actions = list(
    list(
      TargetGroupArn = "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-t...",
      Type = "forward"
    )
  ),
  Conditions = list(
    list(
      Field = "path-pattern",
      Values = list(
        "/img/*"
      )
    )
  ),
  ListenerArn = "arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-ba...",
  Priority = 10L
)
# }
# NOT RUN {
# }

Run the code above in your browser using DataCamp Workspace