Todos os produtos
Search
Central de documentação

Resource Orchestration Service:ALIYUN::POLARDB::Account

Última atualização: Jun 27, 2026

Cria uma conta para um cluster PolarDB.

Sintaxe

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

Propriedades

Nome da propriedade

Tipo

Obrigatório

Atualizável

Descrição

Restrições

DBClusterId

String

Sim

Não

ID do cluster.

Nenhuma

AccountDescription

String

Não

Sim

Descrição da conta.

Deve ter de 2 a 256 caracteres. A descrição não pode começar comhttp:// ouhttps://.

AccountName

String

Sim

Não

Nome da conta.

Máximo de 16 caracteres. Deve começar com letra minúscula e conter apenas letras minúsculas, dígitos e sublinhados (_).

AccountPrivilege

String

Não

Não

Privilégio da conta.

Valores válidos:

  • ReadWrite (padrão): leitura e gravação.

  • ReadOnly: somente leitura.

  • DMLOnly: apenas DML.

  • DDLOnly: apenas DDL.

Nota

Aplica-se apenas a contas padrão em clusters PolarDB for MySQL.

DBName

String

Não

Não

Nome do banco de dados para concessão de acesso.

Separe os nomes por vírgulas (,) para especificar vários bancos de dados.

Nota

Aplica-se apenas a contas padrão em clusters PolarDB for MySQL.

PrivForAllDB

String

Não

Não

Concede permissões em todos os bancos de dados existentes e novos no cluster atual.

Valores válidos:

  • 0 ou vazio: não concede permissões.

  • 1: concede permissões.

Nota
  • Especifique o parâmetro AccountPrivilege para que este parâmetro tenha efeito.

  • Se definido como 1, o privilégio especificado em AccountPrivilege será concedido a todos os bancos de dados.

AccountType

String

Não

Não

Tipo da conta.

Valores válidos:

  • Normal: conta padrão.

  • Super (padrão): conta privilegiada.

AccountPassword

String

Sim

Sim

Senha da conta.

Deve ter de 8 a 32 caracteres. Pode conter letras, dígitos e os seguintes caracteres especiais:

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

Valores de retorno

Fn::GetAtt

Nenhum

Exemplos

Cenário 1: Criar uma conta padrão somente leitura para um banco de dados PolarDB

Criação rápida

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"
      }
    }
  }
}

Cenário 2: Criar uma conta privilegiada para um banco de dados PolarDB

Criação rápida

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"
      }
    }
  }
}

Cenário 3: Implementar recuperação inteligente multimodal com SQL nativo

Criação rápida

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"
      ]
    }
  }
}

Para mais exemplos, consulte os modelos públicos que incluem este recurso.