All Products
Search
Document Center

Resource Orchestration Service:ALIYUN::APIG::Route

更新时间:Jan 23, 2025

ALIYUN::APIG::Route is used to create a route for an HTTP API.

Syntax

{
  "Type": "ALIYUN::APIG::Route",
  "Properties": {
    "Backend": Map,
    "EnvironmentInfo": Map,
    "HttpApiId": String,
    "Match": Map,
    "RouteName": String,
    "Description": String,
    "DomainInfos": List,
    "DomainIds": List
  }
}

Properties

Property

Type

Required

Editable

Description

Constraint

Backend

Map

Yes

Yes

The backend service configurations of the route.

For more information, see Backend properties.

EnvironmentInfo

Map

Yes

No

The environment configurations.

For more information, see EnvironmentInfo properties.

HttpApiId

String

Yes

No

The ID of the HTTP API for which you want to create the route.

None.

Match

Map

Yes

Yes

The rules for matching the route.

For more information, see Match properties.

RouteName

String

Yes

No

The name of the route.

None.

Description

String

No

Yes

The description of the route.

None.

DomainInfos

List

No

Yes

Details of the domains.

None.

DomainIds

List

No

No

The IDs of the domains.

None.

Backend syntax

"Backend": {
  "Services": List,
  "Scene": String
}

Backend properties

Property

Type

Required

Editable

Description

Constraint

Services

List

Yes

Yes

The backend services.

You can specify up to 10 backend services. For more information, see Services properties.

Scene

String

Yes

Yes

The scenario of the backend service.

Valid values:

  • SingleService

  • MultiServiceByRatio

  • Mock

  • Redirect

Services syntax

"Services": [
  {
    "Version": String,
    "Port": Integer,
    "Protocol": String,
    "Weight": Integer,
    "Name": String,
    "ServiceId": String
  }
]

Services Properties

Property

Type

Required

Editable

Description

Constraint

Name

String

No

No

The name of the service.

None.

Port

Integer

No

No

The port of the service.

None.

Protocol

String

No

No

The protocol of the service.

Valid values:

  • HTTP

  • HTTPS

ServiceId

String

No

Yes

The ID of the service.

None.

Version

String

No

No

The version of the service.

None.

Weight

Integer

No

Yes

The percentage value of traffic.

Valid values: 0 to 100.

EnvironmentInfo syntax

"EnvironmentInfo": {
  "GatewayInfo": Map,
  "EnvironmentId": String,
  "Alias": String,
  "SubDomains": List,
  "Name": String
}

EnvironmentInfo properties

Property

Type

Required

Editable

Description

Constraint

EnvironmentId

String

Yes

No

The ID of the environment.

None.

Alias

String

No

No

The alias of the environment.

None.

GatewayInfo

Map

No

No

The gateway configurations.

For more information, see GatewayInfo properties.

Name

String

No

No

The name of the environment.

None.

SubDomains

List

No

No

The subdomains.

You can specify up to 10 subdomains. For more information, see GatewayInfo properties.

GatewayInfo syntax

"GatewayInfo": {
  "GatewayId": String,
  "Name": String
}

GatewayInfo properties

Property

Type

Required

Editable

Description

Constraint

GatewayId

String

No

No

The ID of the gateway.

None.

Name

String

No

No

The name of the gateway.

None.

SubDomains syntax

"SubDomains": [
  {
    "DomainId": String,
    "NetworkType": String,
    "Protocol": String,
    "Name": String
  }
]

SubDomains properties

Property

Type

Required

Editable

Description

Constraint

DomainId

String

No

No

The ID of the subdomain.

None.

NetworkType

String

No

No

The network access type.

None.

Name

String

No

No

The subdomain.

None.

Protocol

String

No

No

The network protocol supported by the subdomain.

Valid values:

  • HTTP

  • HTTPS

DomainInfos syntax

"DomainInfos": [
  {
    "DomainId": String,
    "Protocol": String,
    "Name": String
  }
]

DomainInfos properties

Property

Type

Required

Editable

Description

Constraint

DomainId

String

No

Yes

The ID of the domain.

None.

Name

String

No

No

The domain.

None.

Protocol

String

No

No

The network protocol supported by the domain.

Valid values:

  • HTTP

  • HTTPS

Match syntax

"Match": {
  "Path": Map,
  "Headers": List,
  "QueryParams": List,
  "Methods": List,
  "IgnoreUriCase": Boolean
}

Match properties

Property

Type

Required

Editable

Description

Constraint

Path

Map

Yes

Yes

The rules for matching based on paths.

None.

Headers

List

No

Yes

The rules for matching based on HTTP request headers.

You can specify up to 10 rules.

IgnoreUriCase

Boolean

No

Yes

Specifies whether the path is case-insensitive.

None.

Methods

List

No

Yes

The request methods.

None.

QueryParams

List

No

Yes

The rules for matching based on Query request parameters.

You can specify up to 10 rules.

Path syntax

"Path": {
  "Type": String,
  "Value": String
}

Path properties

Property

Type

Required

Editable

Description

Constraint

Type

String

Yes

Yes

The type of matching based on the path.

Valid values:

  • Exact

  • Prefix

  • Regex

Value

String

Yes

Yes

The path.

None.

Headers syntax

"Headers": [
  {
    "Type": String,
    "Value": String,
    "Name": String
  }
]

Headers properties

Property

Type

Required

Editable

Description

Constraint

Name

String

No

Yes

The name of the header.

None.

Type

String

No

Yes

The type of matching based on the header.

Valid values:

  • Exact

  • Prefix

  • Regex

Value

String

No

Yes

The value of the header.

None.

QueryParams syntax

"QueryParams": [
  {
    "Type": String,
    "Value": String,
    "Name": String
  }
]

QueryParams properties

Property

Type

Required

Editable

Description

Constraint

Name

String

No

Yes

The name of the Query parameter.

None.

Type

String

No

Yes

The type of matching based on the Query parameter.

Valid values:

  • Exact

  • Prefix

  • Regex

Value

String

No

Yes

The value of the Query parameter.

None.

Return values

Fn::GetAtt

  • Backend: the backend service configurations of the route.

  • Description: the description of the route.

  • EnvironmentInfo: the environment configurations.

  • RouteName: the name of the route.

  • DomainInfos: details of the domains.

  • RouteId: the ID of the route.

  • Match: the rules for matching the route.

Examples

ROSTemplateFormatVersion: '2015-09-01'
Parameters: {}
Resources:
  ExtensionResource:
    Type: ALIYUN::APIG::Route
    Properties:
      HttpApiId: api-xxx
      EnvironmentInfo:
        EnvironmentId: env-xxxx
      RouteName: test123
      DomainIds:
        - d-xxxx
      Match:
        Path:
          Type: Prefix
          Value: /user
      Backend:
        Scene: SingleService
        Services:
          - Name: test1
            ServiceId: svc-xxxxx
            Port: 443
            Protocol: HTTPS
            Version: base
Outputs:
  Backend:
    Description: Backend services.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - Backend
  Description:
    Description: The description of route resource.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - Description
  EnvironmentInfo:
    Description: Environment information.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - EnvironmentInfo
  RouteName:
    Description: The name of the route.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - RouteName
  DomainInfos:
    Description: Domain items.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - DomainInfos
  RouteId:
    Description: The ID of route resource.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - RouteId
  Match:
    Description: The match rule of route resource.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - Match
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
  },
  "Resources": {
    "ExtensionResource": {
      "Type": "ALIYUN::APIG::Route",
      "Properties": {
        "HttpApiId": "api-xxx",
        "EnvironmentInfo": {
          "EnvironmentId": "env-xxxx"
        },
        "RouteName": "test123",
        "DomainIds": [
          "d-xxxx"
        ],
        "Match": {
          "Path": {
            "Type": "Prefix",
            "Value": "/user"
          }
        },
        "Backend": {
          "Scene": "SingleService",
          "Services": [
            {
              "Name": "test1",
              "ServiceId": "svc-xxxxx",
              "Port": 443,
              "Protocol": "HTTPS",
              "Version": "base"
            }
          ]
        }
      }
    }
  },
  "Outputs": {
    "Backend": {
      "Description": "Backend services.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "Backend"
        ]
      }
    },
    "Description": {
      "Description": "The description of route resource.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "Description"
        ]
      }
    },
    "EnvironmentInfo": {
      "Description": "Environment information.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "EnvironmentInfo"
        ]
      }
    },
    "RouteName": {
      "Description": "The name of the route.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "RouteName"
        ]
      }
    },
    "DomainInfos": {
      "Description": "Domain items.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "DomainInfos"
        ]
      }
    },
    "RouteId": {
      "Description": "The ID of route resource.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "RouteId"
        ]
      }
    },
    "Match": {
      "Description": "The match rule of route resource.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "Match"
        ]
      }
    }
  }
}