ALIYUN::Bailian::ApiKey

更新时间:
复制 MD 格式

ALIYUN::Bailian::ApiKey类型用于创建百炼ApiKey。

语法

{
  "Type": "ALIYUN::Bailian::ApiKey",
  "Properties": {
    "AuthSetModel": Map,
    "Description": String
  }
}

属性

属性名称

类型

必须

允许更新

描述

约束

AuthSetModel

Map

该认证方式的模型。

更多信息,请参见AuthSetModel属性

Description

String

API密钥的描述。

AuthSetModel语法

"AuthSetModel": {
  "AccessIps": List,
  "AuthSetMode": String
}

AuthSetModel属性

属性名称

类型

必须

允许更新

描述

约束

AccessIps

List

访问的IP地址。

AuthSetMode

String

该认证方式的模式。

取值:

  • Custom

  • All

返回值

Fn::GetAtt

  • ApiKeyId:API密钥的ID。

  • Key:API密钥的值。

示例

场景 1 :创建百炼API-KEY

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: 创建百炼API-KEY,用于调用通义千问等大模型API。
  en: Create a Bailian API key for calling large model APIs such as Qwen.
Parameters:
  ApiKeyDescription:
    Type: String
    Label:
      zh-cn: API-KEY描述
      en: API Key Description
    Description:
      zh-cn: API-KEY的描述信息,便于识别用途,1~128个字符。
      en: The description of the API key for identification, 1-128 characters.
    Default: 百炼平台大模型API-KEY
Resources:
  BailianApiKey:
    Type: ALIYUN::Bailian::ApiKey
    Properties:
      Description:
        Ref: ApiKeyDescription
Outputs:
  ApiKeyId:
    Label:
      zh-cn: API-KEY ID
      en: API Key ID
    Description:
      zh-cn: 创建的API-KEY唯一标识ID。
      en: The unique ID of the created API key.
    Value:
      Fn::GetAtt:
        - BailianApiKey
        - ApiKeyId
  ApiKey:
    Label:
      zh-cn: API-KEY
      en: API Key
    Description:
      zh-cn: 创建的API-KEY值,用于调用百炼大模型API,请妥善保管。
      en: The value of the created API key for calling Bailian model APIs. Keep it safe.
    Value:
      Fn::GetAtt:
        - BailianApiKey
        - Key
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "创建百炼API-KEY,用于调用通义千问等大模型API。",
    "en": "Create a Bailian API key for calling large model APIs such as Qwen."
  },
  "Parameters": {
    "ApiKeyDescription": {
      "Type": "String",
      "Label": {
        "zh-cn": "API-KEY描述",
        "en": "API Key Description"
      },
      "Description": {
        "zh-cn": "API-KEY的描述信息,便于识别用途,1~128个字符。",
        "en": "The description of the API key for identification, 1-128 characters."
      },
      "Default": "百炼平台大模型API-KEY"
    }
  },
  "Resources": {
    "BailianApiKey": {
      "Type": "ALIYUN::Bailian::ApiKey",
      "Properties": {
        "Description": {
          "Ref": "ApiKeyDescription"
        }
      }
    }
  },
  "Outputs": {
    "ApiKeyId": {
      "Label": {
        "zh-cn": "API-KEY ID",
        "en": "API Key ID"
      },
      "Description": {
        "zh-cn": "创建的API-KEY唯一标识ID。",
        "en": "The unique ID of the created API key."
      },
      "Value": {
        "Fn::GetAtt": [
          "BailianApiKey",
          "ApiKeyId"
        ]
      }
    },
    "ApiKey": {
      "Label": {
        "zh-cn": "API-KEY",
        "en": "API Key"
      },
      "Description": {
        "zh-cn": "创建的API-KEY值,用于调用百炼大模型API,请妥善保管。",
        "en": "The value of the created API key for calling Bailian model APIs. Keep it safe."
      },
      "Value": {
        "Fn::GetAtt": [
          "BailianApiKey",
          "Key"
        ]
      }
    }
  }
}

场景 2 :创建百炼API-KEY并配置IP访问白名单,限制仅指定IP可调用大模型API。

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: 创建百炼API-KEY并配置IP访问白名单,限制仅指定IP可调用大模型API。
  en: Create a Bailian API key with an IP whitelist to restrict model API access.
Parameters:
  ApiKeyDescription:
    Type: String
    Label:
      zh-cn: API-KEY描述
      en: API Key Description
    Description:
      zh-cn: API-KEY的描述信息,便于识别用途,1~128个字符。
      en: The description of the API key for identification, 1-128 characters.
    Default: 百炼平台大模型API-KEY(IP白名单)
  AuthSetMode:
    Type: String
    Label:
      zh-cn: 访问控制模式
      en: Access Control Mode
    Description:
      zh-cn: >-
        API-KEY的访问控制模式。
        Custom:仅白名单内IP可调用;All:不限制IP。
      en: >-
        The access control mode of the API key.
        Custom: only whitelisted IPs can call; All: no IP restriction.
    Default: Custom
    AllowedValues:
      - Custom
      - All
  AccessIps:
    Type: Json
    Label:
      zh-cn: IP访问白名单
      en: IP Access Whitelist
    Description:
      zh-cn: >-
        允许调用该API-KEY的IP地址或CIDR段列表。
        访问控制模式为Custom时生效,默认0.0.0.0/0表示允许所有IP,请按需收敛。
      en: >-
        The IP addresses or CIDR blocks allowed to call this API key.
        Effective when the access control mode is Custom.
        Default 0.0.0.0/0 allows all IPs; narrow it down as needed.
    Default: ["0.0.0.0/0"]
    AssociationProperty: List[Parameter]
    AssociationPropertyMetadata:
      Parameter:
        Type: String
        Required: true
        Label:
          zh-cn: IP地址
          en: IP Address
Resources:
  BailianApiKey:
    Type: ALIYUN::Bailian::ApiKey
    Properties:
      Description:
        Ref: ApiKeyDescription
      AuthSetModel:
        AuthSetMode:
          Ref: AuthSetMode
        AccessIps:
          Ref: AccessIps
Outputs:
  ApiKeyId:
    Label:
      zh-cn: API-KEY ID
      en: API Key ID
    Description:
      zh-cn: 创建的API-KEY唯一标识ID。
      en: The unique ID of the created API key.
    Value:
      Fn::GetAtt:
        - BailianApiKey
        - ApiKeyId
  ApiKey:
    Label:
      zh-cn: API-KEY
      en: API Key
    Description:
      zh-cn: 创建的API-KEY值,用于调用百炼大模型API,请妥善保管。
      en: The value of the created API key for calling Bailian model APIs. Keep it safe.
    Value:
      Fn::GetAtt:
        - BailianApiKey
        - Key
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "创建百炼API-KEY并配置IP访问白名单,限制仅指定IP可调用大模型API。",
    "en": "Create a Bailian API key with an IP whitelist to restrict model API access."
  },
  "Parameters": {
    "ApiKeyDescription": {
      "Type": "String",
      "Label": {
        "zh-cn": "API-KEY描述",
        "en": "API Key Description"
      },
      "Description": {
        "zh-cn": "API-KEY的描述信息,便于识别用途,1~128个字符。",
        "en": "The description of the API key for identification, 1-128 characters."
      },
      "Default": "百炼平台大模型API-KEY(IP白名单)"
    },
    "AuthSetMode": {
      "Type": "String",
      "Label": {
        "zh-cn": "访问控制模式",
        "en": "Access Control Mode"
      },
      "Description": {
        "zh-cn": "API-KEY的访问控制模式。Custom:仅白名单内IP可调用;All:不限制IP。",
        "en": "The access control mode of the API key. Custom: only whitelisted IPs can call; All: no IP restriction."
      },
      "Default": "Custom",
      "AllowedValues": [
        "Custom",
        "All"
      ]
    },
    "AccessIps": {
      "Type": "Json",
      "Label": {
        "zh-cn": "IP访问白名单",
        "en": "IP Access Whitelist"
      },
      "Description": {
        "zh-cn": "允许调用该API-KEY的IP地址或CIDR段列表。访问控制模式为Custom时生效,默认0.0.0.0/0表示允许所有IP,请按需收敛。",
        "en": "The IP addresses or CIDR blocks allowed to call this API key. Effective when the access control mode is Custom. Default 0.0.0.0/0 allows all IPs; narrow it down as needed."
      },
      "Default": [
        "0.0.0.0/0"
      ],
      "AssociationProperty": "List[Parameter]",
      "AssociationPropertyMetadata": {
        "Parameter": {
          "Type": "String",
          "Required": true,
          "Label": {
            "zh-cn": "IP地址",
            "en": "IP Address"
          }
        }
      }
    }
  },
  "Resources": {
    "BailianApiKey": {
      "Type": "ALIYUN::Bailian::ApiKey",
      "Properties": {
        "Description": {
          "Ref": "ApiKeyDescription"
        },
        "AuthSetModel": {
          "AuthSetMode": {
            "Ref": "AuthSetMode"
          },
          "AccessIps": {
            "Ref": "AccessIps"
          }
        }
      }
    }
  },
  "Outputs": {
    "ApiKeyId": {
      "Label": {
        "zh-cn": "API-KEY ID",
        "en": "API Key ID"
      },
      "Description": {
        "zh-cn": "创建的API-KEY唯一标识ID。",
        "en": "The unique ID of the created API key."
      },
      "Value": {
        "Fn::GetAtt": [
          "BailianApiKey",
          "ApiKeyId"
        ]
      }
    },
    "ApiKey": {
      "Label": {
        "zh-cn": "API-KEY",
        "en": "API Key"
      },
      "Description": {
        "zh-cn": "创建的API-KEY值,用于调用百炼大模型API,请妥善保管。",
        "en": "The value of the created API key for calling Bailian model APIs. Keep it safe."
      },
      "Value": {
        "Fn::GetAtt": [
          "BailianApiKey",
          "Key"
        ]
      }
    }
  }
}