ALIYUN::RDS::ReadOnlyDBInstance类型用于为关系型数据库RDS(Relational Database Service)实例创建一个只读实例。

语法

{
  "Type": "ALIYUN::RDS::ReadOnlyDBInstance",
  "Properties": {
    "Category": String,
    "VPCId": String,
    "DBInstanceDescription": String,
    "Tags": Map,
    "EngineVersion": String,
    "DBInstanceId": String,
    "PayType": String,
    "ZoneId": String,
    "ResourceGroupId": String,
    "DBInstanceStorage": Integer,
    "VSwitchId": String,
    "DBInstanceStorageType": String,
    "DBInstanceClass": String,
    "PrivateIpAddress": String,
    "PeriodType": String,
    "Period": Integer,
    "AutoRenew": Boolean
  }
}

属性

属性名称 类型 必须 允许更新 描述 约束
Category String 实例系列。 取值:
  • Basic:基础版。
  • HighAvailability(默认值):高可用版。
  • AlwaysOn:集群版。
VPCId String 只读实例的专有网络ID。
DBInstanceDescription String 实例描述。 长度为2~256个字符。以汉字、英文字母开头,不能以http://https://开头。可包含数字、汉字、英文字母、下划线(_)和短划线(-)。
Tags Map 实例标签。 实例标签是键值对形式,例如:
{"key1": "value1","key2": "value2", ... "key5": "value5"}
最多设置5个键值对。其中,key最大长度为64个字符,不能以http://https://开头;value最大长度为128个字符,不能以aliyunhttp://https://开头。
EngineVersion String 数据库版本号。 EngineVersion必须与主实例的版本保持一致。
取值:
  • MySQL数据库:
    • 5.6
    • 5.7
    • 8.0
  • SQL Server数据库:2017_ent
DBInstanceId String 主实例ID。
PayType String 付费类型。 仅支持按量付费。

取值:Postpaid。

ZoneId String 可用区ID。 可以通过接口DescribeRegions查看可用区列表。
ResourceGroupId String 资源组ID。
DBInstanceStorage Integer 存储空间。 单位:GB。

取值范围:5~3000,步长为5 GB。

不同版本实例,支持的取值范围不同。更多信息,请参见主实例规格列表
VSwitchId String 只读实例的交换机ID。
DBInstanceStorageType String 实例存储类型。 取值:
  • local_ssd或ephemeral_ssd:本地SSD盘。
  • cloud_ssd:SSD云盘。
  • cloud_essd:ESSD云盘。
说明 MySQL仅支持本地盘存储类型,SQL Server仅支持云盘存储类型。
DBInstanceClass String 实例规格。 更多信息,请参见主实例规格列表

建议只读实例规格不小于主实例规格,否则容易出现只读实例延迟高、负载高等现象。

PrivateIpAddress String 只读实例的内网IP。 需要在指定交换机的IP地址范围内,设置只读实例的内网IP。系统默认通过VPCId和VSwitchId自动分配。
PeriodType String 预付费实例类型。 取值:
  • Year:包年。
  • Month:包月。
Period Integer 购买时长。 取值范围:
  • 当参数PeriodType为Year时:1~3。
  • 当参数PeriodType为Month时:1~9。
AutoRenew Boolean 实例是否自动续费。

仅在创建包年包月实例时生效。

取值:
  • true:自动续费。
  • false(默认值):不自动续费。
说明
  • 按月购买,则自动续费周期为1个月。
  • 按年购买,则自动续费周期为1年。

返回值

Fn::GetAtt

  • ConnectionString:创建的只读实例内网数据库连接地址。
  • DBInstanceId:创建的只读实例ID。
  • Port:创建的只读实例内网数据库连接端口。

示例

JSON格式

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "PeriodType": {
      "Type": "String",
      "Description": "Charge period for created instances.",
      "AllowedValues": [
        "Month",
        "Year"
      ],
      "Default": "Month"
    },
    "Category": {
      "Type": "String",
      "Description": "The edition of the instance. Valid values:\n- Basic\n- HighAvailability\n- AlwaysOn",
      "AllowedValues": [
        "Basic",
        "HighAvailability",
        "AlwaysOn"
      ]
    },
    "EngineVersion": {
      "Type": "String",
      "Description": "The version of the database. The database and the master instance must have the same database version. Valid values:\n- 5.6\n- 5.7\n- 8.0\n- 2017_ent",
      "AllowedValues": [
        "5.6",
        "5.7",
        "8.0",
        "2017_ent"
      ]
    },
    "PrivateIpAddress": {
      "Type": "String",
      "Description": "The private IP address of the read-only instance. It must be within the IP address range provided by the switch. The system automatically assigns an IP address based on the VPCId and VSwitchId by default."
    },
    "ZoneId": {
      "Type": "String",
      "Description": "The ID of the zone. You can call the DescribeRegions API operation to view the latest zones."
    },
    "ResourceGroupId": {
      "Type": "String",
      "Description": "Resource group id."
    },
    "VPCId": {
      "Type": "String",
      "Description": "The ID of the VPC."
    },
    "DBInstanceClass": {
      "Type": "String",
      "Description": "The type of the instance. For more information, see Instance type list. The type of the read-only instance must be no less than that of the master instance. Otherwise, the read-only instance incurs high latency and high load."
    },
    "VSwitchId": {
      "Type": "String",
      "Description": "The ID of the VSwitch."
    },
    "AutoRenew": {
      "Type": "Boolean",
      "Description": "Specifies whether to enable auto-renewal. Valid values: true and false. Note\n:Monthly subscription: The auto-renewal cycle is one month.\nAnnual subscription: The auto-renewal cycle is one year.",
      "AllowedValues": [
        "True",
        "true",
        "False",
        "false"
      ]
    },
    "Period": {
      "Type": "Number",
      "Description": "Prepaid time period. While choose by pay by month, it could be from 1 to 9. While choose pay by year, it could be from 1 to 3.",
      "MinValue": 1,
      "MaxValue": 9,
      "Default": 1
    },
    "PayType": {
      "Type": "String",
      "Description": "The billing method. Valid value: Postpaid, Prepaid.",
      "AllowedValues": [
        "Prepaid",
        "Postpaid"
      ],
      "Default": "Postpaid"
    },
    "DBInstanceStorageType": {
      "Type": "String",
      "Description": "The storage type of the instance. Valid values:\n- local_ssd/ephemeral_ssd: local SSDs.\n- cloud_ssd: SSDs.\n- cloud_essd: ESSDs.",
      "AllowedValues": [
        "local_ssd",
        "ephemeral_ssd",
        "cloud_ssd",
        "cloud_essd"
      ]
    },
    "DBInstanceId": {
      "Type": "String",
      "Description": "The ID of the master instance."
    },
    "DBInstanceStorage": {
      "Type": "Number",
      "Description": "The storage space of the instance. Value range: 5 to 3000. The value must be a multiple of 5. Unit: GB."
    },
    "DBInstanceDescription": {
      "Type": "String",
      "Description": "Description of created database instance."
    },
    "Tags": {
      "Type": "Json",
      "Description": "The tags of an instance.\nYou should input the information of the tag with the format of the Key-Value, such as {\"key1\":\"value1\",\"key2\":\"value2\", ... \"key5\":\"value5\"}.\nAt most 5 tags can be specified.\nKey\nIt can be up to 64 characters in length.\nCannot begin with aliyun.\nCannot begin with http:// or https://.\nCannot be a null string.\nValue\nIt can be up to 128 characters in length.\nCannot begin with aliyun.\nCannot begin with http:// or https://.\nCan be a null string."
    }
  },
  "Resources": {
    "ReadOnlyDBInstance": {
      "Type": "ALIYUN::RDS::ReadOnlyDBInstance",
      "Properties": {
        "PeriodType": {
          "Ref": "PeriodType"
        },
        "Category": {
          "Ref": "Category"
        },
        "EngineVersion": {
          "Ref": "EngineVersion"
        },
        "PrivateIpAddress": {
          "Ref": "PrivateIpAddress"
        },
        "ZoneId": {
          "Ref": "ZoneId"
        },
        "ResourceGroupId": {
          "Ref": "ResourceGroupId"
        },
        "VPCId": {
          "Ref": "VPCId"
        },
        "DBInstanceClass": {
          "Ref": "DBInstanceClass"
        },
        "VSwitchId": {
          "Ref": "VSwitchId"
        },
        "AutoRenew": {
          "Ref": "AutoRenew"
        },
        "Period": {
          "Ref": "Period"
        },
        "PayType": {
          "Ref": "PayType"
        },
        "DBInstanceStorageType": {
          "Ref": "DBInstanceStorageType"
        },
        "DBInstanceId": {
          "Ref": "DBInstanceId"
        },
        "DBInstanceStorage": {
          "Ref": "DBInstanceStorage"
        },
        "DBInstanceDescription": {
          "Ref": "DBInstanceDescription"
        },
        "Tags": {
          "Ref": "Tags"
        }
      }
    }
  },
  "Outputs": {
    "DBInstanceId": {
      "Description": "The instance id of created database instance.",
      "Value": {
        "Fn::GetAtt": [
          "ReadOnlyDBInstance",
          "DBInstanceId"
        ]
      }
    },
    "Port": {
      "Description": "Intranet port of created DB instance.",
      "Value": {
        "Fn::GetAtt": [
          "ReadOnlyDBInstance",
          "Port"
        ]
      }
    },
    "ConnectionString": {
      "Description": "DB instance connection url by Intranet.",
      "Value": {
        "Fn::GetAtt": [
          "ReadOnlyDBInstance",
          "ConnectionString"
        ]
      }
    }
  }
}

YAML格式

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  AutoRenew:
    AllowedValues:
    - 'True'
    - 'true'
    - 'False'
    - 'false'
    Description: 'Specifies whether to enable auto-renewal. Valid values: true and
      false. Note

      :Monthly subscription: The auto-renewal cycle is one month.

      Annual subscription: The auto-renewal cycle is one year.'
    Type: Boolean
  Category:
    AllowedValues:
    - Basic
    - HighAvailability
    - AlwaysOn
    Description: 'The edition of the instance. Valid values:

      - Basic

      - HighAvailability

      - AlwaysOn'
    Type: String
  DBInstanceClass:
    Description: The type of the instance. For more information, see Instance type
      list. The type of the read-only instance must be no less than that of the master
      instance. Otherwise, the read-only instance incurs high latency and high load.
    Type: String
  DBInstanceDescription:
    Description: Description of created database instance.
    Type: String
  DBInstanceId:
    Description: The ID of the master instance.
    Type: String
  DBInstanceStorage:
    Description: 'The storage space of the instance. Value range: 5 to 3000. The value
      must be a multiple of 5. Unit: GB.'
    Type: Number
  DBInstanceStorageType:
    AllowedValues:
    - local_ssd
    - ephemeral_ssd
    - cloud_ssd
    - cloud_essd
    Description: 'The storage type of the instance. Valid values:

      - local_ssd/ephemeral_ssd: local SSDs.

      - cloud_ssd: SSDs.

      - cloud_essd: ESSDs.'
    Type: String
  EngineVersion:
    AllowedValues:
    - '5.6'
    - '5.7'
    - '8.0'
    - 2017_ent
    Description: 'The version of the database. The database and the master instance
      must have the same database version. Valid values:

      - 5.6

      - 5.7

      - 8.0

      - 2017_ent'
    Type: String
  PayType:
    AllowedValues:
    - Prepaid
    - Postpaid
    Default: Postpaid
    Description: 'The billing method. Valid value: Postpaid, Prepaid.'
    Type: String
  Period:
    Default: 1
    Description: Prepaid time period. While choose by pay by month, it could be from
      1 to 9. While choose pay by year, it could be from 1 to 3.
    MaxValue: 9
    MinValue: 1
    Type: Number
  PeriodType:
    AllowedValues:
    - Month
    - Year
    Default: Month
    Description: Charge period for created instances.
    Type: String
  PrivateIpAddress:
    Description: The private IP address of the read-only instance. It must be within
      the IP address range provided by the switch. The system automatically assigns
      an IP address based on the VPCId and VSwitchId by default.
    Type: String
  ResourceGroupId:
    Description: Resource group id.
    Type: String
  Tags:
    Description: 'The tags of an instance.

      You should input the information of the tag with the format of the Key-Value,
      such as {"key1":"value1","key2":"value2", ... "key5":"value5"}.

      At most 5 tags can be specified.

      Key

      It can be up to 64 characters in length.

      Cannot begin with aliyun.

      Cannot begin with http:// or https://.

      Cannot be a null string.

      Value

      It can be up to 128 characters in length.

      Cannot begin with aliyun.

      Cannot begin with http:// or https://.

      Can be a null string.'
    Type: Json
  VPCId:
    Description: The ID of the VPC.
    Type: String
  VSwitchId:
    Description: The ID of the VSwitch.
    Type: String
  ZoneId:
    Description: The ID of the zone. You can call the DescribeRegions API operation
      to view the latest zones.
    Type: String
Resources:
  ReadOnlyDBInstance:
    Properties:
      AutoRenew:
        Ref: AutoRenew
      Category:
        Ref: Category
      DBInstanceClass:
        Ref: DBInstanceClass
      DBInstanceDescription:
        Ref: DBInstanceDescription
      DBInstanceId:
        Ref: DBInstanceId
      DBInstanceStorage:
        Ref: DBInstanceStorage
      DBInstanceStorageType:
        Ref: DBInstanceStorageType
      EngineVersion:
        Ref: EngineVersion
      PayType:
        Ref: PayType
      Period:
        Ref: Period
      PeriodType:
        Ref: PeriodType
      PrivateIpAddress:
        Ref: PrivateIpAddress
      ResourceGroupId:
        Ref: ResourceGroupId
      Tags:
        Ref: Tags
      VPCId:
        Ref: VPCId
      VSwitchId:
        Ref: VSwitchId
      ZoneId:
        Ref: ZoneId
    Type: ALIYUN::RDS::ReadOnlyDBInstance
Outputs:
  ConnectionString:
    Description: DB instance connection url by Intranet.
    Value:
      Fn::GetAtt:
      - ReadOnlyDBInstance
      - ConnectionString
  DBInstanceId:
    Description: The instance id of created database instance.
    Value:
      Fn::GetAtt:
      - ReadOnlyDBInstance
      - DBInstanceId
  Port:
    Description: Intranet port of created DB instance.
    Value:
      Fn::GetAtt:
      - ReadOnlyDBInstance
      - Port

更多示例,请参见创建RDS数据库实例、创建管理数据库的账号、授权账号访问数据库、修改数据库参数列表、修改实例访问白名单和在实例下创建数据库的组合示例:JSON示例YAML示例