All Products
Search
Document Center

Resource Orchestration Service:ALIYUN::POLARDB::Account

Last Updated:Feb 10, 2026

The ALIYUN::POLARDB::Account resource type creates accounts for PolarDB databases.

Syntax

{
  "Type": "ALIYUN::POLARDB::Account",
  "Properties": {
    "DBClusterId": String,
    "AccountDescription": String,
    "AccountName": String,
    "AccountPrivilege": String,
    "DBName": String,
    "AccountType": String,
    "PrivForAllDB": String,
    "AccountPassword": String
  }
}

Properties

Property name

Type

Required

Updatable

Description

Constraints

DBClusterId

String

Yes

No

The cluster ID.

None

AccountDescription

String

No

Yes

The account description.

Length is 2 to 256 characters. Cannot start withhttp:// orhttps://.

AccountName

String

Yes

No

The account name.

Length cannot exceed 16 characters. Start with a lowercase English letter. Can contain lowercase English letters, numbers, and underscores (_).

AccountPrivilege

String

No

No

The account privilege.

Values:

  • ReadWrite (default): Read and write.

  • ReadOnly: Read-only.

  • DMLOnly: DML only.

  • DDLOnly: DDL only.

Note

This parameter applies only to standard accounts for PolarDB for MySQL clusters.

DBName

String

No

No

The database name to grant access to.

Separate multiple database names with commas (,).

Note

This parameter applies only to standard accounts for PolarDB for MySQL clusters.

PrivForAllDB

String

No

No

Grant permissions for all existing databases and all newly added databases in the current cluster.

Values:

  • 0 or empty: Do not grant.

  • 1: Grant.

Note
  • The AccountPrivilege parameter must be provided to take effect.

  • When the parameter is set to 1, AccountPrivilege is granted to all databases.

AccountType

String

No

No

The account type.

Values:

  • Normal: Standard account.

  • Super (default): Privileged account.

AccountPassword

String

Yes

Yes

The password.

Length is 8 to 32 characters. Can contain English letters, numbers, and the following special characters:

!#$%^&*()_+-=

Return values

Fn::GetAtt

None

Examples

Scenario 1: Create a read-only standard account for a PolarDB database.

Quick create

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  DBClusterId:
    Type: String
    Description: The ID of the ApsaraDB for POLARDB cluster for which a database account is to be created.
    AssociationProperty: ALIYUN::POLARDB::DBCluster::DBClusterId
  AccountName:
    Type: String
    Description: The name of the database account to be used.
    Default: mytest
  AccountPassword:
    Type: String
    Description: |-
      The password of the database account. The password must comply with the following rules:
      - It must consist of uppercase letters, lowercase letters, digits, and special characters.
      - Special characters include exclamation points (!), number signs (#), dollar signs ($), percent signs (%), carets (^), ampersands (&), asterisks (*), parentheses (()), underscores (_), plus signs (+), hyphens (-), and equal signs (=).
      - It must be 8 to 32 characters in length.
    MinLength: 8
    MaxLength: 32
Resources:
  Account:
    Type: ALIYUN::POLARDB::Account
    Properties:
      DBClusterId:
        Ref: DBClusterId
      AccountName:
        Ref: AccountName
      AccountPrivilege: ReadOnly
      AccountPassword:
        Ref: AccountPassword
      AccountType: Normal
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "DBClusterId": {
      "Type": "String",
      "AssociationProperty":"ALIYUN::POLARDB::DBCluster::DBClusterId",
      "Description": "The ID of the ApsaraDB for POLARDB cluster for which a database account is to be created."
    },
    "AccountName": {
      "Type": "String",
      "Description": "The name of the database account to be used.",
      "Default": "mytest"
    },
    "AccountPassword": {
      "Type": "String",
      "Description": "The password of the database account. The password must comply with the following rules:\n- It must consist of uppercase letters, lowercase letters, digits, and special characters.\n- Special characters include exclamation points (!), number signs (#), dollar signs ($), percent signs (%), carets (^), ampersands (&), asterisks (*), parentheses (()), underscores (_), plus signs (+), hyphens (-), and equal signs (=).\n- It must be 8 to 32 characters in length.",
      "MinLength": 8,
      "MaxLength": 32
    }
  },
  "Resources": {
    "Account": {
      "Type": "ALIYUN::POLARDB::Account",
      "Properties": {
        "DBClusterId": {
          "Ref": "DBClusterId"
        },
        "AccountName": {
          "Ref": "AccountName"
        },
        "AccountPrivilege": "ReadOnly",
        "AccountPassword": {
          "Ref": "AccountPassword"
        },
        "AccountType": "Normal"
      }
    }
  }
}

Scenario 2: Create a privileged account for a PolarDB database.

Quick create

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  DBClusterId:
    Type: String
    Description: The ID of the ApsaraDB for POLARDB cluster for which a database account is to be created.
    AssociationProperty: ALIYUN::POLARDB::DBCluster::DBClusterId
  AccountName:
    Type: String
    Description: The name of the database account to be used.
    Default: mytest
  AccountPassword:
    Type: String
    Description: |-
      The password of the database account. The password must comply with the following rules:
      - It must consist of uppercase letters, lowercase letters, digits, and special characters.
      - Special characters include exclamation points (!), number signs (#), dollar signs ($), percent signs (%), carets (^), ampersands (&), asterisks (*), parentheses (()), underscores (_), plus signs (+), hyphens (-), and equal signs (=).
      - It must be 8 to 32 characters in length.
    MinLength: 8
    MaxLength: 32
Resources:
  Account:
    Type: ALIYUN::POLARDB::Account
    Properties:
      DBClusterId:
        Ref: DBClusterId
      AccountName:
        Ref: AccountName
      AccountPrivilege: ReadWrite
      AccountPassword:
        Ref: AccountPassword
      AccountType: Super
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "DBClusterId": {
      "Type": "String",
      "Description": "The ID of the ApsaraDB for POLARDB cluster for which a database account is to be created.",
      "AssociationProperty": "ALIYUN::POLARDB::DBCluster::DBClusterId"
    },
    "AccountName": {
      "Type": "String",
      "Description": "The name of the database account to be used.",
      "Default": "mytest"
    },
    "AccountPassword": {
      "Type": "String",
      "Description": "The password of the database account. The password must comply with the following rules:\n- It must consist of uppercase letters, lowercase letters, digits, and special characters.\n- Special characters include exclamation points (!), number signs (#), dollar signs ($), percent signs (%), carets (^), ampersands (&), asterisks (*), parentheses (()), underscores (_), plus signs (+), hyphens (-), and equal signs (=).\n- It must be 8 to 32 characters in length.",
      "MinLength": 8,
      "MaxLength": 32
    }
  },
  "Resources": {
    "Account": {
      "Type": "ALIYUN::POLARDB::Account",
      "Properties": {
        "DBClusterId": {
          "Ref": "DBClusterId"
        },
        "AccountName": {
          "Ref": "AccountName"
        },
        "AccountPrivilege": "ReadWrite",
        "AccountPassword": {
          "Ref": "AccountPassword"
        },
        "AccountType": "Super"
      }
    }
  }
}

Scenario 3: Easily implement multimodal intelligent retrieval using native SQL.

Quick create

ROSTemplateFormatVersion: '2015-09-01'
Description: Easily perform multimodal intelligent retrieval with native SQL.
Parameters:
  CommonName:
    Type: String
    Default: SmartSearch
  BucketName:
    AssociationProperty: AutoCompleteInput
    AssociationPropertyMetadata:
      Length: 6
      Prefix: test-bucket-
      CharacterClasses:
        - Class: lowercase
          min: 1
    Type: String
    Label: Bucket Name
  ZoneId:
    Type: String
    Label: Zone ID
    AssociationProperty: ALIYUN::ECS::Instance::ZoneId
  AccountName:
    Type: String
    Label: Database username
    Description: Must be 2 to 16 characters in length. It must start with a lowercase letter and can contain only lowercase letters, numbers, and underscores (_).
    ConstraintDescription: Must be 2 to 16 characters in length. It must start with a lowercase letter and can contain only lowercase letters, numbers, and underscores (_).
    AllowedPattern: '^[a-z][a-z0-9_]{0,30}[a-z0-9]$'
    Default: polar_ai
    MaxLength: 16
    MinLength: 2
  AccountPassword:
    Type: String
    Description: The database access password. It must be 8 to 32 characters in length and contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters (!@#$%^&*()_+-=).
    Label: Database password
    ConstraintDescription: The database access password. It must be 8 to 32 characters in length and contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters (!@#$%^&*()_+-=).
    AllowedPattern: '^[0-9A-Za-z_!@#$%^&*()_+\-=\+]+$'
    MinLength: 8
    MaxLength: 32
    NoEcho: true
  DBName:
    Type: String
    Label: Database Name
    AllowedPattern: ^[a-z][a-z0-9_-]{0,62}[a-z0-9]$
    Description: Must be up to 64 characters in length. It must start with a letter and end with a letter or a number. It can contain lowercase letters, numbers, hyphens (-), and underscores (_).
    ConstraintDescription: Must be up to 64 characters in length. It must start with a letter and end with a letter or a number. It can contain lowercase letters, numbers, hyphens (-), and underscores (_).
    Default: db-test
  PolarDBNodeClass:
    Type: String
    Label: PolarDB Node Specifications
    AssociationProperty: ALIYUN::POLARDB::DBCluster::DBNodeClass
    AssociationPropertyMetadata:
      ZoneId: ${ZoneId}
      DBVersion: "14"
      DBType: PostgreSQL
      PayType: Postpaid
      CommodityCode: polardb_payg
    Default: polar.pg.g2.2xlarge.c
Resources:
  VPC:
    Type: ALIYUN::ECS::VPC
    Properties:
      VpcName:
        Fn::Sub: VPC_${CommonName}
      CidrBlock: 192.168.0.0/16
  VSwitch:
    Type: ALIYUN::ECS::VSwitch
    Properties:
      VpcId:
        Ref: VPC
      CidrBlock: 192.168.1.0/24
      ZoneId:
        Ref: ZoneId
      VSwitchName:
        Fn::Sub: vsw_001_${CommonName}
  PolardbCluster:
    Type: ALIYUN::POLARDB::DBCluster
    Properties:
      VpcId:
        Ref: VPC
      SecurityIPList: 0.0.0.0/0
      DBType: PostgreSQL
      ClusterNetworkType: VPC
      ZoneId:
        Ref: ZoneId
      VSwitchId:
        Ref: VSwitch
      DBVersion: "14"
      CreationCategory: SENormal
      StorageSpace: 20
      HotStandbyCluster: 'OFF'
      DBNodeClass:
        Ref: PolarDBNodeClass
      PayType: Postpaid
      DBNodeNum: 2
      StorageType: ESSDPL1
  Account:
    Type: ALIYUN::POLARDB::Account
    Properties:
      DBClusterId:
        Ref: PolardbCluster
      AccountName:
        Ref: AccountName
      AccountPassword:
        Ref: AccountPassword
      AccountType: Super
  Database:
    DependsOn: Account
    Type: ALIYUN::POLARDB::Database
    Properties:
      CharacterSetName: utf8
      AccountPrivilege: ReadWrite
      AccountName:
        Ref: AccountName
      DBClusterId:
        Ref: PolardbCluster
      DBName:
        Ref: DBName
      Collate: C
      Ctype: C
  DBClusterEndpointAddress:
    Type: ALIYUN::POLARDB::DBClusterEndpointAddress
    DependsOn: Account
    Properties:
      DBClusterId:
        Ref: PolardbCluster
      DBEndpointId:
        Fn::GetAtt:
          - PolardbCluster
          - ClusterEndpointId
  OSSBucket:
    Type: ALIYUN::OSS::Bucket
    Properties:
      BucketName:
        Ref: BucketName
      DeletionForce: true
      RedundancyType: ZRS
Outputs:
  BucketName:
    Description: The name of the Object Storage Service (OSS) bucket.
    Value:
      Ref: BucketName
  AccountName:
    Description: The username for the PolarDB database.
    Value:
      Ref: AccountName
  AccountPassword:
    NoEcho: true
    Description: The password for the PolarDB database.
    Value:
      Ref: AccountPassword
  DBName:
    Description: The name of the PolarDB database.
    Value:
      Ref: DBName
  ConnectionString:
    Description: The public endpoint of the PolarDB database.
    Value:
      Fn::Sub: ${DBClusterEndpointAddress.ConnectionString}:5432
Metadata:
  ALIYUN::ROS::Interface:
    Outputs:
      - BucketName
      - AccountName
      - AccountPassword
      - DBName
      - ConnectionString
    ParameterGroups:
      - Parameters:
          - ZoneId
        Label:
          default: Basic network configuration
      - Parameters:
          - BucketName
        Label:
          default: Basic OSS configuration
      - Parameters:
          - PolarDBNodeClass
          - DBName
          - AccountName
          - AccountPassword
        Label:
          default: ApsaraDB PolarDB for PostgreSQL configuration
    TemplateTags:
      - acs:technical-solution:internet-application-development:Easily perform multimodal intelligent retrieval with native SQL-tech_solu_262
    Hidden:
      - CommonName
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": "Easily perform multimodal intelligent retrieval with native SQL.",
  "Parameters": {
    "CommonName": {
      "Type": "String",
      "Default": "SmartSearch"
    },
    "BucketName": {
      "AssociationProperty": "AutoCompleteInput",
      "AssociationPropertyMetadata": {
        "Length": 6,
        "Prefix": "test-bucket-",
        "CharacterClasses": [
          {
            "Class": "lowercase",
            "min": 1
          }
        ]
      },
      "Type": "String",
      "Label": "Bucket Name"
    },
    "ZoneId": {
      "Type": "String",
      "Label": "Zone ID",
      "AssociationProperty": "ALIYUN::ECS::Instance::ZoneId"
    },
    "AccountName": {
      "Type": "String",
      "Label": "Database username",
      "Description": "Must be 2 to 16 characters in length. It must start with a lowercase letter and can contain only lowercase letters, numbers, and underscores (_).",
      "ConstraintDescription": "Must be 2 to 16 characters in length. It must start with a lowercase letter and can contain only lowercase letters, numbers, and underscores (_).",
      "AllowedPattern": "^[a-z][a-z0-9_]{0,30}[a-z0-9]$",
      "Default": "polar_ai",
      "MaxLength": 16,
      "MinLength": 2
    },
    "AccountPassword": {
      "Type": "String",
      "Description": "The database access password. It must be 8 to 32 characters in length and contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters (!@#$%^&*()_+-=).",
      "Label": "Database password",
      "ConstraintDescription": "The database access password. It must be 8 to 32 characters in length and contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters (!@#$%^&*()_+-=).",
      "AllowedPattern": "^[0-9A-Za-z_!@#$%^&*()_+\\-=\\+]+$",
      "MinLength": 8,
      "MaxLength": 32,
      "NoEcho": true
    },
    "DBName": {
      "Type": "String",
      "Label": "Database Name",
      "AllowedPattern": "^[a-z][a-z0-9_-]{0,62}[a-z0-9]$",
      "Description": "Must be up to 64 characters in length. It must start with a letter and end with a letter or a number. It can contain lowercase letters, numbers, hyphens (-), and underscores (_).",
      "ConstraintDescription": "Must be up to 64 characters in length. It must start with a letter and end with a letter or a number. It can contain lowercase letters, numbers, hyphens (-), and underscores (_).",
      "Default": "db-test"
    },
    "PolarDBNodeClass": {
      "Type": "String",
      "Label": "PolarDB Node Specifications",
      "AssociationProperty": "ALIYUN::POLARDB::DBCluster::DBNodeClass",
      "AssociationPropertyMetadata": {
        "ZoneId": "${ZoneId}",
        "DBVersion": "14",
        "DBType": "PostgreSQL",
        "PayType": "Postpaid",
        "CommodityCode": "polardb_payg"
      },
      "Default": "polar.pg.g2.2xlarge.c"
    }
  },
  "Resources": {
    "VPC": {
      "Type": "ALIYUN::ECS::VPC",
      "Properties": {
        "VpcName": {
          "Fn::Sub": "VPC_${CommonName}"
        },
        "CidrBlock": "192.168.0.0/16"
      }
    },
    "VSwitch": {
      "Type": "ALIYUN::ECS::VSwitch",
      "Properties": {
        "VpcId": {
          "Ref": "VPC"
        },
        "CidrBlock": "192.168.1.0/24",
        "ZoneId": {
          "Ref": "ZoneId"
        },
        "VSwitchName": {
          "Fn::Sub": "vsw_001_${CommonName}"
        }
      }
    },
    "PolardbCluster": {
      "Type": "ALIYUN::POLARDB::DBCluster",
      "Properties": {
        "VpcId": {
          "Ref": "VPC"
        },
        "SecurityIPList": "0.0.0.0/0",
        "DBType": "PostgreSQL",
        "ClusterNetworkType": "VPC",
        "ZoneId": {
          "Ref": "ZoneId"
        },
        "VSwitchId": {
          "Ref": "VSwitch"
        },
        "DBVersion": "14",
        "CreationCategory": "SENormal",
        "StorageSpace": 20,
        "HotStandbyCluster": "OFF",
        "DBNodeClass": {
          "Ref": "PolarDBNodeClass"
        },
        "PayType": "Postpaid",
        "DBNodeNum": 2,
        "StorageType": "ESSDPL1"
      }
    },
    "Account": {
      "Type": "ALIYUN::POLARDB::Account",
      "Properties": {
        "DBClusterId": {
          "Ref": "PolardbCluster"
        },
        "AccountName": {
          "Ref": "AccountName"
        },
        "AccountPassword": {
          "Ref": "AccountPassword"
        },
        "AccountType": "Super"
      }
    },
    "Database": {
      "DependsOn": "Account",
      "Type": "ALIYUN::POLARDB::Database",
      "Properties": {
        "CharacterSetName": "utf8",
        "AccountPrivilege": "ReadWrite",
        "AccountName": {
          "Ref": "AccountName"
        },
        "DBClusterId": {
          "Ref": "PolardbCluster"
        },
        "DBName": {
          "Ref": "DBName"
        },
        "Collate": "C",
        "Ctype": "C"
      }
    },
    "DBClusterEndpointAddress": {
      "Type": "ALIYUN::POLARDB::DBClusterEndpointAddress",
      "DependsOn": "Account",
      "Properties": {
        "DBClusterId": {
          "Ref": "PolardbCluster"
        },
        "DBEndpointId": {
          "Fn::GetAtt": [
            "PolardbCluster",
            "ClusterEndpointId"
          ]
        }
      }
    },
    "OSSBucket": {
      "Type": "ALIYUN::OSS::Bucket",
      "Properties": {
        "BucketName": {
          "Ref": "BucketName"
        },
        "DeletionForce": true,
        "RedundancyType": "ZRS"
      }
    }
  },
  "Outputs": {
    "BucketName": {
      "Description": "The name of the Object Storage Service (OSS) bucket.",
      "Value": {
        "Ref": "BucketName"
      }
    },
    "AccountName": {
      "Description": "The username for the PolarDB database.",
      "Value": {
        "Ref": "AccountName"
      }
    },
    "AccountPassword": {
      "NoEcho": true,
      "Description": "The password for the PolarDB database.",
      "Value": {
        "Ref": "AccountPassword"
      }
    },
    "DBName": {
      "Description": "The name of the PolarDB database.",
      "Value": {
        "Ref": "DBName"
      }
    },
    "ConnectionString": {
      "Description": "The public endpoint of the PolarDB database.",
      "Value": {
        "Fn::Sub": "${DBClusterEndpointAddress.ConnectionString}:5432"
      }
    }
  },
  "Metadata": {
    "ALIYUN::ROS::Interface": {
      "Outputs": [
        "BucketName",
        "AccountName",
        "AccountPassword",
        "DBName",
        "ConnectionString"
      ],
      "ParameterGroups": [
        {
          "Parameters": [
            "ZoneId"
          ],
          "Label": {
            "default": "Basic network configuration"
          }
        },
        {
          "Parameters": [
            "BucketName"
          ],
          "Label": {
            "default": "Basic OSS configuration"
          }
        },
        {
          "Parameters": [
            "PolarDBNodeClass",
            "DBName",
            "AccountName",
            "AccountPassword"
          ],
          "Label": {
            "default": "ApsaraDB PolarDB for PostgreSQL configuration"
          }
        }
      ],
      "TemplateTags": [
        "acs:technical-solution:internet-application-development:Easily perform multimodal intelligent retrieval with native SQL-tech_solu_262"
      ],
      "Hidden": [
        "CommonName"
      ]
    }
  }
}

For more examples, see public templates that include this resource.