fbpx
POSThttps://api.spotinst.io/loadBalancer/routingRule?accountId={ACCOUNT_ID}

Create a new routing rule

URL Parameters

Parameter Type Description
ACCOUNT_ID String

Account ID from Spotinst console

Example: act-12345
Request

Headers
{
  "Content-Type": "application/json",
  "Authorization": "Bearer ${token}"
}
Body
Copied!
Downloaded!
{
  "routingRule": {
    "balancerId": "lb-12345",
    "route": "PathRegexp(`/`)",
    "targetSetIds": [
      "ts-12345",
      "ts-67890"
    ],
    "middlewareIds": [
      "mw-23456",
      "mw-7890"
    ],
    "listenerId": "ls-12345",
    "priority": 2,
    "tags": [
      {
        "key": "Environment",
        "value": "Production"
      }
    ]
  }
}

Body Attributes


  • routingRule.balancerId * String
    The id of the balancer
  • routingRule.route * String
    Route defines a simple language for matching HTTP requests and route the traffic accordingly. Route provides series of matchers that follow the syntax: Path matcher: — Path("/foo/bar") // trie-based PathRegexp(“/foo/.*”) // regexp-based Method matcher: — Method(“GET”) // trie-based MethodRegexp(“POST|PUT”) // regexp based Header matcher: — Header(“Content-Type”, “application/json”) // trie-based HeaderRegexp(“Content-Type”, “application/.*”) // regexp based Matchers can be combined using && operator: — Method(“POST”) && Path("/v1")
  • routingRule.targetSetIds * String
    The id of the Target Set
  • routingRule.middlewareIds * String
    The id of the Middleware
  • routingRule.listenerId * String
    The id of the Listener
  • routingRule.tags.key String
    The tag’s key
  • routingRule.tags.value String
    The tag’s key
  • routingRule.priority Integer
    The priority of the created Routing Rule
    Example: 2
    Default: 1
  • routingRule.strategy String
    Balancing strategy. Could be one of the following: ROUNDROBIN, RANDOM, LEASTCONN, IPHASH
    Example: LEASTCONN
    Default: ROUNDROBIN
Response - 200

Headers
{
  "Content-Type": "application/json"
}
Body
Copied!
Downloaded!
{
  "status": {
    "code": 200,
    "message": "OK"
  },
  "kind": "spotinst:lb:routingRule",
  "items": [
    {
      "id": "rr-12345",
      "balancerId": "lb-12345",
      "protocol": "HTTP",
      "route": "PathRegexp(`/`)",
      "targetSetIds": [
        "ts-12345",
        "ts-67890"
      ],
      "middlewareIds": [
        "mw-23456",
        "mw-7890"
      ],
      "listenerId": "ls-12345",
      "tags": [
        {
          "key": "Environment",
          "value": "Production"
        }
      ],
      "listenerId": "ls-12345",
      "strategy": "ROUNDROBIN",
      "priority": 2
    }
  ],
  "count": 1
}