ALIYUN::RDS::Database is used to create a database in an ApsaraDB for RDS instance.

Syntax

{
  "Type": "ALIYUN::RDS::Database",
  "Properties": {
    "CharacterSetName": String,
    "DBInstanceId": String,
    "DBDescription": String,
    "DBName": String
  }
}

Properties

Property Type Required Editable Description Constraint
CharacterSetName String Yes No The character set name of the instance. Valid values:
  • For ApsaraDB for MySQL instances or ApsaraDB for MariaDB instances, the valid values are utf8, gbk, latin1, and utf8mb4.
  • For ApsaraDB for SQL Server instances, the valid values are Chinese_PRC_CI_AS, Chinese_PRC_CS_AS, SQL_Latin1_General_CP1_CI_AS, SQL_Latin1_General_CP1_CS_AS, and Chinese_PRC_BIN.
  • For ApsaraDB for PostgreSQL instances, the valid values are KOI8U, UTF8, WIN866, WIN874, WIN1250, WIN1251, WIN1252, WIN1253, WIN1254, WIN1255, WIN1256, WIN1257, WIN1258, EUC_CN, EUC_KR, EUC_TW, EUC_JP, EUC_JIS_2004, KOI8R, MULE_INTERNAL, LATIN1, LATIN2, LATIN3, LATIN4, LATIN5, LATIN6, LATIN7, LATIN8, LATIN9, LATIN10, ISO_8859_5, ISO_8859_6, ISO_8859_7, ISO_8859_8, and SQL_ASCII.
DBInstanceId String Yes No The ID of the instance. None.
DBDescription String No Yes The description of the database. The description must be 2 to 256 characters in length The description must start with a letter and cannot start with http:// or https://. The description can contain letters, digits, underscores (_), and hyphens (-).
DBName String Yes No The name of the database. The name must be 2 to 64 characters in length and can contain lowercase letters, digits, underscores (_), and hyphens (-) The name must start with a lowercase letter and end with a lowercase letter or a digit.
Note Each database name must be unique within an instance.

Response parameters

Fn::GetAtt

  • DBInstanceId: the ID of the ApsaraDB for RDS instance.
  • DBName: the name of the database.

Examples

JSON format

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "CharacterSetName": {
      "Type": "String",
      "Description": "The character set you want to use for the database. Valid values:\nMySQL and MariaDB: utf8 | gbk | latin1 | utf8mb4.\nSQL Server: Chinese_PRC_CI_AS | Chinese_PRC_CS_AS | SQL_Latin1_General_CP1_CI_AS | SQL_Latin1_General_CP1_CS_AS\n| Chinese_PRC_BIN.\nPostgreSQL: KOI8U | UTF8 | WIN866 | WIN874 | WIN1250 | WIN1251 | WIN1252 | WIN1253 | WIN1254 |\nWIN1255 | WIN1256 | WIN1257 | WIN1258 | EUC_CN | EUC_KR | EUC_TW | EUC_JP | EUC_JIS_2004\n| KOI8R | MULE_INTERNAL | LATIN1 | LATIN2 | LATIN3 | LATIN4 | LATIN5 | LATIN6 | LATIN7\n| LATIN8 | LATIN9 | LATIN10 | ISO_8859_5 | ISO_8859_6 | ISO_8859_7 | ISO_8859_8 |\nSQL_ASCII."
    },
    "DBInstanceId": {
      "Type": "String",
      "Description": "The ID of the instance."
    },
    "DBDescription": {
      "Type": "String",
      "Description": "The description of the database. The description must be 2 to 256 characters in length.\nThe description must start with a letter and can contain letters, digits, underscores\n(_), and hyphens (-).\nNote The description cannot start with http:// or https://."
    },
    "DBName": {
      "Type": "String",
      "Description": "The name of the database you want to create.\nNote\nThe name must be 2 to 64 characters in length.\nThe name must start with a lowercase letter and end with a lowercase letter or digit.\nThe name can contain lowercase letters, digits, underscores (_), and hyphens (-).\nThe name must be unique in the instance.\nFor more information about invalid characters, see Forbidden keywords table."
    }
  },
  "Resources": {
    "Database": {
      "Type": "ALIYUN::RDS::Database",
      "Properties": {
        "CharacterSetName": {
          "Ref": "CharacterSetName"
        },
        "DBInstanceId": {
          "Ref": "DBInstanceId"
        },
        "DBDescription": {
          "Ref": "DBDescription"
        },
        "DBName": {
          "Ref": "DBName"
        }
      }
    }
  },
  "Outputs": {
    "DBInstanceId": {
      "Description": "The ID of the instance.",
      "Value": {
        "Fn::GetAtt": [
          "Database",
          "DBInstanceId"
        ]
      }
    },
    "DBName": {
      "Description": "The name of the database.",
      "Value": {
        "Fn::GetAtt": [
          "Database",
          "DBName"
        ]
      }
    }
  }
}

YAML format

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  CharacterSetName:
    Type: String
    Description: >-
      The character set you want to use for the database. Valid values:
      MySQL and MariaDB: utf8 | gbk | latin1 | utf8mb4.
      SQL Server: Chinese_PRC_CI_AS | Chinese_PRC_CS_AS |
      SQL_Latin1_General_CP1_CI_AS | SQL_Latin1_General_CP1_CS_AS
      | Chinese_PRC_BIN.
      PostgreSQL: KOI8U | UTF8 | WIN866 | WIN874 | WIN1250 | WIN1251 | WIN1252 |
      WIN1253 | WIN1254 |
      WIN1255 | WIN1256 | WIN1257 | WIN1258 | EUC_CN | EUC_KR | EUC_TW | EUC_JP
      | EUC_JIS_2004
      | KOI8R | MULE_INTERNAL | LATIN1 | LATIN2 | LATIN3 | LATIN4 | LATIN5 |
      LATIN6 | LATIN7
      | LATIN8 | LATIN9 | LATIN10 | ISO_8859_5 | ISO_8859_6 | ISO_8859_7 |
      ISO_8859_8 |
      SQL_ASCII.
  DBInstanceId:
    Type: String
    Description: The ID of the instance.
  DBDescription:
    Type: String
    Description: >-
      The description of the database. The description must be 2 to 256
      characters in length.
      The description must start with a letter and can contain letters, digits,
      underscores
      (_), and hyphens (-).
      Note The description cannot start with http:// or https://.
  DBName:
    Type: String
    Description: >-
      The name of the database you want to create.
      Note
      The name must be 2 to 64 characters in length.
      The name must start with a lowercase letter and end with a lowercase
      letter or digit.
      The name can contain lowercase letters, digits, underscores (_), and
      hyphens (-).
      The name must be unique in the instance.
      For more information about invalid characters, see Forbidden keywords
      table.
Resources:
  Database:
    Type: 'ALIYUN::RDS::Database'
    Properties:
      CharacterSetName:
        Ref: CharacterSetName
      DBInstanceId:
        Ref: DBInstanceId
      DBDescription:
        Ref: DBDescription
      DBName:
        Ref: DBName
Outputs:
  DBInstanceId:
    Description: The ID of the instance.
    Value:
      'Fn::GetAtt':
        - Database
        - DBInstanceId
  DBName:
    Description: The name of the database.
    Value:
      'Fn::GetAtt':
        - Database
        - DBName