ALIYUN::FC::CustomDomain类型用于创建自定义域名。

语法

{
  "Type": "ALIYUN::FC::CustomDomain",
  "Properties": {
    "ApiVersion": String,
    "Protocol": String,
    "RouteConfig": Map,
    "CertConfig": Map,
    "DomainName": String
  }
}

属性

属性名称 类型 必须 允许更新 描述 约束
ApiVersion String API版本
Protocol String 协议类型 取值:
  • HTTP
  • HTTPS
RouteConfig Map 路由表配置 详情请参见RouteConfig属性
CertConfig Map 证书信息 详情请参见CertConfig属性
DomainName String 域名

RouteConfig语法

"RouteConfig": {
  "Routes": List
}

RouteConfig属性

属性名称 类型 必须 允许更新 描述 约束
Routes List 路由列表 详情请参见Routes属性

Routes语法

"Routes": [
  {
    "Path": String,
    "FunctionName": String,
    "ServiceName": String,
    "Qualifier": String
  }
]  

Routes属性

属性名称 类型 必须 允许更新 描述 约束
Path String 自定义域名的请求路径,例如:/login/*
Qualifier String 别名。
FunctionName String 请求路径对应的函数。
ServiceName String 函数所属服务。

CertConfig语法

"CertConfig": {
  "CertName": String,
  "PrivateKey": String,
  "Certificate": String
}

CertConfig属性

属性名称 类型 必须 允许更新 描述 约束
CertName String 证书的自定义名字
PrivateKey String 私钥 使用换行符\n写成一行。
Certificate String 证书内容 使用换行符\n写成一行。

返回值

Fn::GetAtt

  • DomainName:域名。
  • Domain:协议和域名。

示例

JSON格式

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "ApiVersion": {
      "Type": "String",
      "Description": "api version"
    },
    "CertConfig": {
      "Type": "Json",
      "Description": "certificate info"
    },
    "DomainName": {
      "Type": "String",
      "Description": "domain name"
    },
    "RouteConfig": {
      "Type": "Json",
      "Description": "Routing table: path to function mappingwhen a function is called with a custom domain name"
    },
    "Protocol": {
      "Type": "String",
      "Description": "HTTP or HTTP,HTTPS"
    }
  },
  "Resources": {
    "CustomDomain": {
      "Type": "ALIYUN::FC::CustomDomain",
      "Properties": {
        "ApiVersion": {
          "Ref": "ApiVersion"
        },
        "CertConfig": {
          "Ref": "CertConfig"
        },
        "DomainName": {
          "Ref": "DomainName"
        },
        "RouteConfig": {
          "Ref": "RouteConfig"
        },
        "Protocol": {
          "Ref": "Protocol"
        }
      }
    }
  },
  "Outputs": {
    "DomainName": {
      "Description": "The domain name",
      "Value": {
        "Fn::GetAtt": [
          "CustomDomain",
          "DomainName"
        ]
      }
    },
    "Domain": {
      "Description": "The domain with protocol.",
      "Value": {
        "Fn::GetAtt": [
          "CustomDomain",
          "Domain"
        ]
      }
    }
  }
}

YAML格式

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  ApiVersion:
    Type: String
    Description: api version
  CertConfig:
    Type: Json
    Description: certificate info
  DomainName:
    Type: String
    Description: domain name
  RouteConfig:
    Type: Json
    Description: >-
      Routing table: path to function mappingwhen a function is called with a
      custom domain name
  Protocol:
    Type: String
    Description: 'HTTP or HTTP,HTTPS'
Resources:
  CustomDomain:
    Type: 'ALIYUN::FC::CustomDomain'
    Properties:
      ApiVersion:
        Ref: ApiVersion
      CertConfig:
        Ref: CertConfig
      DomainName:
        Ref: DomainName
      RouteConfig:
        Ref: RouteConfig
      Protocol:
        Ref: Protocol
Outputs:
  DomainName:
    Description: The domain name
    Value:
      'Fn::GetAtt':
        - CustomDomain
        - DomainName
  Domain:
    Description: The domain with protocol.
    Value:
      'Fn::GetAtt':
        - CustomDomain
        - Domain