ALIYUN::APIG::ApiAttachment

更新时间:2024-12-27 06:05:28

ALIYUN::APIG::ApiAttachment类型用于API挂载。

语法

{
  "Type": "ALIYUN::APIG::ApiAttachment",
  "Properties": {
    "BackendScene": String,
    "EnvironmentId": String,
    "HttpApiId": String,
    "ServiceConfigs": List,
    "Description": String,
    "DomainIds": List,
    "RouteId": String
  }
}

属性

属性名称

类型

必须

允许更新

描述

约束

属性名称

类型

必须

允许更新

描述

约束

BackendScene

String

发布场景。

取值:

  • MultiServiceByRatio

  • Mock

  • SingleService

  • MultiServiceByContent

EnvironmentId

String

环境 ID。

HttpApiId

String

HTTP API ID。

ServiceConfigs

List

服务配置列表。

更多信息,请参见ServiceConfigs属性

Description

String

描述。

DomainIds

List

用户自定义域名 ID 列表。

最多支持输入10组域名 ID。

RouteId

String

路由 ID。

ServiceConfigs语法

"ServiceConfigs": [
  {
    "Version": String,
    "Port": Integer,
    "Protocol": String,
    "Weight": Integer,
    "ServiceId": String,
    "Match": Map
  }
]

ServiceConfigs属性

属性名称

类型

必须

允许更新

描述

约束

属性名称

类型

必须

允许更新

描述

约束

ServiceId

String

服务 ID。

Weight

Integer

服务权重。

取值范围:1~100.

Match

Map

API部署中的匹配条件配置。

更多信息,请参见Match属性

Port

Integer

服务端口。

Protocol

String

域名支持的协议类型。

取值:

  • HTTP:仅支持 HTTP 协议。

  • HTTPS:仅支持 HTTPS 协议。

Version

String

服务的版本。

Match语法

"Match": {
  "DefaultMatch": Boolean,
  "Conditions": List
}

Match属性

属性名称

类型

必须

允许更新

描述

约束

属性名称

类型

必须

允许更新

描述

约束

Conditions

List

匹配条件配置。

更多信息,请参见Conditions属性

DefaultMatch

Boolean

是否默认匹配条件。

Conditions语法

"Conditions": [
  {
    "Operator": String,
    "Type": String,
    "Value": String,
    "Key": String
  }
]

Conditions属性

属性名称

类型

必须

允许更新

描述

约束

属性名称

类型

必须

允许更新

描述

约束

Key

String

匹配 Key。

Operator

String

操作符。

,支持精确匹配、前缀匹配、正则表达式三种方式。

枚举值:

  • Equal:equal。

  • Regex:regex。

  • Prefix:prefix。

Type

String

匹配类型。

支持 Query 参数或 Header 参数匹配。

Value

String

匹配值。

返回值

Fn::GetAtt

  • EnvironmentId:环境 id。

  • RouteId:路由 ID。

  • HttpApiId:路由所属的 HTTP API ID。

示例

YAML
JSON
ROSTemplateFormatVersion: '2015-09-01'
Parameters: {}
Resources:
  ExtensionResource:
    Type: ALIYUN::APIG::ApiAttachment
    Properties:
      EnvironmentId: env-csqxxxxx
      BackendScene: MultiServiceByRatio
      HttpApiId: api-csqxxxxx
      ServiceConfigs:
        - ServiceId: svc-csqp3xxxxx
          Weight: 100
      RouteId: hr-csuxxxxxx
Outputs:
  EnvironmentId:
    Description: The ID of the environment to which the API is to deploy.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - EnvironmentId
  RouteId:
    Description: The route ID. When publishing an HTTP API route, it must be passed in.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - RouteId
  HttpApiId:
    Description: The ID of the HTTP API.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - HttpApiId
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
  },
  "Resources": {
    "ExtensionResource": {
      "Type": "ALIYUN::APIG::ApiAttachment",
      "Properties": {
        "EnvironmentId": "env-csqxxxxx",
        "BackendScene": "MultiServiceByRatio",
        "HttpApiId": "api-csqxxxxx",
        "ServiceConfigs": [
          {
            "ServiceId": "svc-csqp3xxxxx",
            "Weight": 100
          }
        ],
        "RouteId": "hr-csuxxxxxx"
      }
    }
  },
  "Outputs": {
    "EnvironmentId": {
      "Description": "The ID of the environment to which the API is to deploy.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "EnvironmentId"
        ]
      }
    },
    "RouteId": {
      "Description": "The route ID. When publishing an HTTP API route, it must be passed in.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "RouteId"
        ]
      }
    },
    "HttpApiId": {
      "Description": "The ID of the HTTP API.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "HttpApiId"
        ]
      }
    }
  }
}                
  • 本页导读 (1)
  • 语法
  • 属性
  • ServiceConfigs语法
  • ServiceConfigs属性
  • Match语法
  • Match属性
  • Conditions语法
  • Conditions属性
  • 返回值
  • 示例