All Products
Search
Document Center

Resource Orchestration Service:ALIYUN::PolarDBX::Database

更新時間:Jun 01, 2023

ALIYUN::PolarDBX::Database is used to create a database.

Syntax

{
  "Type": "ALIYUN::PolarDBX::Database",
  "Properties": {
    "CharacterSetName": String,
    "DBInstanceId": String,
    "Mode": String,
    "DatabaseName": String,
    "DatabaseDescription": String,
    "Accounts": List
  }
}

Properties

Property

Type

Required

Editable

Description

Constraint

CharacterSetName

String

Yes

No

The character set that the database supports.

Valid values:

  • utf8

  • gbk

  • latin1

  • utf8mb4

DBInstanceId

String

Yes

No

The ID of the PolarDB-X instance.

None.

Mode

String

No

No

The method in which you want to create the database.

Valid values:

  • auto: Databases in AUTO mode support automatic partitioning. You do not need to specify a partition key when you create a table.

  • drds: Databases in DRDS mode do not support automatic partitioning. You must specify a database shard key and a table shard key in the sharding syntax that is dedicated to PolarDB-X when you create a table.

DatabaseName

String

Yes

No

The name of the database.

None.

DatabaseDescription

String

No

Yes

The description of the database.

None.

Accounts

List

Yes

Yes

The accounts that are used to access the database.

For more information, see Accounts properties.

Accounts syntax

"Accounts": [
  {
    "AccountPrivilege": String,
    "AccountName": String
  }
]

Accounts properties

Property

Type

Required

Editable

Description

Constraint

AccountPrivilege

String

Yes

Yes

The permissions on the database that you want to grant to the account.

Valid values:

  • ReadWrite

  • ReadOnly

  • DMLOnly

  • DDLOnly

AccountName

String

Yes

Yes

The username of the account that is used to access the database.

None.

Return values

Fn::GetAtt

  • CharacterSetName: the character set that the database supports.

  • DBInstanceId: the ID of the PolarDB-X instance.

  • DatabaseName: the name of the database.

  • DatabaseDescription: the description of the database.

  • Accounts: the accounts that are used to access the database.

Examples

YAML format

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  CharacterSetName:
    Type: String
    Description: |-
      Character set, which supports the following character sets:
      - **utf8 * *
      - **gbk**
      - **latin1 * *
      - **utf8mb4 * *.
    AllowedValues:
      - utf8
      - gbk
      - latin1
      - utf8mb4
    Default: utf8
  DBInstanceId:
    Type: String
    Description: The ID of the instance.
    Default: drdshh****
  DatabaseName:
    Type: String
    Description: The name of the database.
    Default: test1
  Accounts:
    Type: Json
    Description: List of accounts.
    Default:
      - AccountPrivilege: ReadWrite
        AccountName: test1
Resources:
  ExtensionResource:
    Type: ALIYUN::PolarDBX::Database
    Properties:
      CharacterSetName:
        Ref: CharacterSetName
      DBInstanceId:
        Ref: DBInstanceId
      DatabaseName:
        Ref: DatabaseName
      Accounts:
        Ref: Accounts
Outputs:
  CharacterSetName:
    Description: Character set, which supports the following character sets:.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - CharacterSetName
  DBInstanceId:
    Description: The ID of the instance.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - DBInstanceId
  DatabaseName:
    Description: The name of the database.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - DatabaseName
  DatabaseDescription:
    Description: Database description information.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - DatabaseDescription
  Accounts:
    Description: List of accounts.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - Accounts

JSON format

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "CharacterSetName": {
      "Type": "String",
      "Description": "Character set, which supports the following character sets:\n- **utf8 * *\n- **gbk**\n- **latin1 * *\n- **utf8mb4 * *.",
      "AllowedValues": [
        "utf8",
        "gbk",
        "latin1",
        "utf8mb4"
      ],
      "Default": "utf8"
    },
    "DBInstanceId": {
      "Type": "String",
      "Description": "The ID of the instance.",
      "Default": "drdshh****"
    },
    "DatabaseName": {
      "Type": "String",
      "Description": "The name of the database.",
      "Default": "test1"
    },
    "Accounts": {
      "Type": "Json",
      "Description": "List of accounts.",
      "Default": [
        {
          "AccountPrivilege": "ReadWrite",
          "AccountName": "test1"
        }]
    }
  },
  "Resources": {
    "ExtensionResource": {
      "Type": "ALIYUN::PolarDBX::Database",
      "Properties": {
        "CharacterSetName": {
          "Ref": "CharacterSetName"
        },
        "DBInstanceId": {
          "Ref": "DBInstanceId"
        },
        "DatabaseName": {
          "Ref": "DatabaseName"
        },
        "Accounts": {
          "Ref": "Accounts"
        }
      }
    }
  },
  "Outputs": {
    "CharacterSetName": {
      "Description": "Character set, which supports the following character sets:.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "CharacterSetName"
        ]
      }
    },
    "DBInstanceId": {
      "Description": "The ID of the instance.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "DBInstanceId"
        ]
      }
    },
    "DatabaseName": {
      "Description": "The name of the database.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "DatabaseName"
        ]
      }
    },
    "DatabaseDescription": {
      "Description": "Database description information.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "DatabaseDescription"
        ]
      }
    },
    "Accounts": {
      "Description": "List of accounts.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "Accounts"
        ]
      }
    }
  }
}