全部产品
Search
文档中心

资源编排:ALIYUN::GPDB::Account

更新时间:Jul 15, 2026

ALIYUN::GPDB::Account类型用于创建数据库实例账号。

语法

{
  "Type": "ALIYUN::GPDB::Account",
  "Properties": {
    "AccountDescription": String,
    "DBInstanceId": String,
    "AccountPassword": String,
    "AccountType": String,
    "AccountName": String
  }
}

属性

属性名称

类型

必须

允许更新

描述

约束

AccountName

String

数据库账号名称。

AccountPassword

String

数据库账号名称的密码。

限制:

  • 密码由大写字母、小写字母、数字以及特殊符号组成。

    特殊符号包含:(!)、(@)、(#)、($)、(%)、(^)、(&)、(*)(())、(_)、(+)、(-)、(=)

  • 密码长度为8~32个字符。

DBInstanceId

String

数据库实例ID。

AccountDescription

String

数据库账号描述。

AccountType

String

账号类型。

取值说明:

  • Normal:普通账号。

  • Super:高权限账号。

返回值

Fn::GetAtt

  • DBInstanceId:数据库实例ID。

  • AccountName:数据库实例账号名称。

示例

场景 1 :为AnalyticDB PostgreSQL实例创建普通数据库账号。

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: 为AnalyticDB PostgreSQL实例创建普通数据库账号。
  en: Create a normal database account for an AnalyticDB for PostgreSQL instance.
Parameters:
  DBInstanceId:
    Type: String
    Label:
      zh-cn: GPDB实例ID
      en: GPDB Instance ID
    Description:
      zh-cn: 已有的AnalyticDB PostgreSQL实例ID。
      en: The ID of an existing AnalyticDB for PostgreSQL instance.
  AccountName:
    Type: String
    Label:
      zh-cn: 账号名称
      en: Account Name
    Description:
      zh-cn: >-
        数据库账号名称,2~16个字符,
        由小写字母、数字和下划线组成,
        以小写字母开头,以小写字母或数字结尾,
        不能以gp开头。
      en: >-
        Account name, 2-16 characters,
        consisting of lowercase letters, digits and underscores,
        starting with a lowercase letter and ending with a lowercase letter or digit.
    AllowedPattern: '^(?!gp)[a-z][a-z0-9_]{0,14}[a-z0-9]$'
  AccountPassword:
    Type: String
    Label:
      zh-cn: 账号密码
      en: Account Password
    Description:
      zh-cn: >-
        数据库账号密码,8~32个字符,
        至少包含大写字母、小写字母、数字和特殊字符中的三种。
      en: >-
        Account password, 8-32 characters,
        must contain at least three of: uppercase, lowercase, digits, special characters.
    NoEcho: true
    MinLength: 8
    MaxLength: 32
Resources:
  Account:
    Type: ALIYUN::GPDB::Account
    Properties:
      DBInstanceId:
        Ref: DBInstanceId
      AccountName:
        Ref: AccountName
      AccountPassword:
        Ref: AccountPassword
Outputs:
  AccountName:
    Label:
      zh-cn: 账号名称
      en: Account Name
    Description:
      zh-cn: 创建成功的数据库账号名称。
      en: The name of the created database account.
    Value:
      Fn::GetAtt:
        - Account
        - AccountName
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "为AnalyticDB PostgreSQL实例创建普通数据库账号。",
    "en": "Create a normal database account for an AnalyticDB for PostgreSQL instance."
  },
  "Parameters": {
    "DBInstanceId": {
      "Type": "String",
      "Label": {
        "zh-cn": "GPDB实例ID",
        "en": "GPDB Instance ID"
      },
      "Description": {
        "zh-cn": "已有的AnalyticDB PostgreSQL实例ID。",
        "en": "The ID of an existing AnalyticDB for PostgreSQL instance."
      }
    },
    "AccountName": {
      "Type": "String",
      "Label": {
        "zh-cn": "账号名称",
        "en": "Account Name"
      },
      "Description": {
        "zh-cn": "数据库账号名称,2~16个字符,由小写字母、数字和下划线组成,以小写字母开头,以小写字母或数字结尾,不能以gp开头。",
        "en": "Account name, 2-16 characters, consisting of lowercase letters, digits and underscores, starting with a lowercase letter and ending with a lowercase letter or digit."
      },
      "AllowedPattern": "^(?!gp)[a-z][a-z0-9_]{0,14}[a-z0-9]$"
    },
    "AccountPassword": {
      "Type": "String",
      "Label": {
        "zh-cn": "账号密码",
        "en": "Account Password"
      },
      "Description": {
        "zh-cn": "数据库账号密码,8~32个字符,至少包含大写字母、小写字母、数字和特殊字符中的三种。",
        "en": "Account password, 8-32 characters, must contain at least three of: uppercase, lowercase, digits, special characters."
      },
      "NoEcho": true,
      "MinLength": 8,
      "MaxLength": 32
    }
  },
  "Resources": {
    "Account": {
      "Type": "ALIYUN::GPDB::Account",
      "Properties": {
        "DBInstanceId": {
          "Ref": "DBInstanceId"
        },
        "AccountName": {
          "Ref": "AccountName"
        },
        "AccountPassword": {
          "Ref": "AccountPassword"
        }
      }
    }
  },
  "Outputs": {
    "AccountName": {
      "Label": {
        "zh-cn": "账号名称",
        "en": "Account Name"
      },
      "Description": {
        "zh-cn": "创建成功的数据库账号名称。",
        "en": "The name of the created database account."
      },
      "Value": {
        "Fn::GetAtt": [
          "Account",
          "AccountName"
        ]
      }
    }
  }
}

场景 2 :为AnalyticDB PostgreSQL实例创建高权限管理账号。

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: 为AnalyticDB PostgreSQL实例创建高权限管理账号。
  en: Create a privileged Super account for an AnalyticDB for PostgreSQL instance.
Parameters:
  DBInstanceId:
    Type: String
    Label:
      zh-cn: GPDB实例ID
      en: GPDB Instance ID
    Description:
      zh-cn: 已有的AnalyticDB PostgreSQL实例ID。
      en: The ID of an existing AnalyticDB for PostgreSQL instance.
  AccountName:
    Type: String
    Label:
      zh-cn: 管理员账号名称
      en: Admin Account Name
    Description:
      zh-cn: >-
        高权限账号名称,2~16个字符,
        由小写字母、数字和下划线组成,
        不能以gp开头。
      en: >-
        Super account name, 2-16 characters,
        consisting of lowercase letters, digits and underscores.
    Default: admin_user
    AllowedPattern: '^(?!gp)[a-z][a-z0-9_]{0,14}[a-z0-9]$'
  AccountPassword:
    Type: String
    Label:
      zh-cn: 账号密码
      en: Account Password
    Description:
      zh-cn: >-
        高权限账号密码,8~32个字符,
        至少包含大写字母、小写字母、数字和特殊字符中的三种。
      en: >-
        Super account password, 8-32 characters,
        must contain at least three of: uppercase, lowercase, digits, special characters.
    NoEcho: true
    MinLength: 8
    MaxLength: 32
  AccountDescription:
    Type: String
    Label:
      zh-cn: 账号描述
      en: Account Description
    Description:
      zh-cn: 数据库管理员账号的描述信息。
      en: The description of the database administrator account.
    Default: GPDB高权限管理账号
Resources:
  SuperAccount:
    Type: ALIYUN::GPDB::Account
    Properties:
      DBInstanceId:
        Ref: DBInstanceId
      AccountName:
        Ref: AccountName
      AccountPassword:
        Ref: AccountPassword
      AccountType: Super
      AccountDescription:
        Ref: AccountDescription
Outputs:
  DBInstanceId:
    Label:
      zh-cn: GPDB实例ID
      en: GPDB Instance ID
    Description:
      zh-cn: 账号所属的数据库实例ID。
      en: The ID of the database instance the account belongs to.
    Value:
      Fn::GetAtt:
        - SuperAccount
        - DBInstanceId
  AccountName:
    Label:
      zh-cn: 管理员账号名称
      en: Admin Account Name
    Description:
      zh-cn: 创建成功的高权限管理账号名称。
      en: The name of the created privileged account.
    Value:
      Fn::GetAtt:
        - SuperAccount
        - AccountName
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "为AnalyticDB PostgreSQL实例创建高权限管理账号。",
    "en": "Create a privileged Super account for an AnalyticDB for PostgreSQL instance."
  },
  "Parameters": {
    "DBInstanceId": {
      "Type": "String",
      "Label": {
        "zh-cn": "GPDB实例ID",
        "en": "GPDB Instance ID"
      },
      "Description": {
        "zh-cn": "已有的AnalyticDB PostgreSQL实例ID。",
        "en": "The ID of an existing AnalyticDB for PostgreSQL instance."
      }
    },
    "AccountName": {
      "Type": "String",
      "Label": {
        "zh-cn": "管理员账号名称",
        "en": "Admin Account Name"
      },
      "Description": {
        "zh-cn": "高权限账号名称,2~16个字符,由小写字母、数字和下划线组成,不能以gp开头。",
        "en": "Super account name, 2-16 characters, consisting of lowercase letters, digits and underscores."
      },
      "Default": "admin_user",
      "AllowedPattern": "^(?!gp)[a-z][a-z0-9_]{0,14}[a-z0-9]$"
    },
    "AccountPassword": {
      "Type": "String",
      "Label": {
        "zh-cn": "账号密码",
        "en": "Account Password"
      },
      "Description": {
        "zh-cn": "高权限账号密码,8~32个字符,至少包含大写字母、小写字母、数字和特殊字符中的三种。",
        "en": "Super account password, 8-32 characters, must contain at least three of: uppercase, lowercase, digits, special characters."
      },
      "NoEcho": true,
      "MinLength": 8,
      "MaxLength": 32
    },
    "AccountDescription": {
      "Type": "String",
      "Label": {
        "zh-cn": "账号描述",
        "en": "Account Description"
      },
      "Description": {
        "zh-cn": "数据库管理员账号的描述信息。",
        "en": "The description of the database administrator account."
      },
      "Default": "GPDB高权限管理账号"
    }
  },
  "Resources": {
    "SuperAccount": {
      "Type": "ALIYUN::GPDB::Account",
      "Properties": {
        "DBInstanceId": {
          "Ref": "DBInstanceId"
        },
        "AccountName": {
          "Ref": "AccountName"
        },
        "AccountPassword": {
          "Ref": "AccountPassword"
        },
        "AccountType": "Super",
        "AccountDescription": {
          "Ref": "AccountDescription"
        }
      }
    }
  },
  "Outputs": {
    "DBInstanceId": {
      "Label": {
        "zh-cn": "GPDB实例ID",
        "en": "GPDB Instance ID"
      },
      "Description": {
        "zh-cn": "账号所属的数据库实例ID。",
        "en": "The ID of the database instance the account belongs to."
      },
      "Value": {
        "Fn::GetAtt": [
          "SuperAccount",
          "DBInstanceId"
        ]
      }
    },
    "AccountName": {
      "Label": {
        "zh-cn": "管理员账号名称",
        "en": "Admin Account Name"
      },
      "Description": {
        "zh-cn": "创建成功的高权限管理账号名称。",
        "en": "The name of the created privileged account."
      },
      "Value": {
        "Fn::GetAtt": [
          "SuperAccount",
          "AccountName"
        ]
      }
    }
  }
}

场景 3 :为AnalyticDB PostgreSQL实例同时创建管理账号和只读业务账号,实现权限分离。

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: 为AnalyticDB PostgreSQL实例同时创建管理账号和业务账号,实现权限分离。
  en: Create both a Super admin account and a Normal business account for privilege separation.
Parameters:
  DBInstanceId:
    Type: String
    Label:
      zh-cn: GPDB实例ID
      en: GPDB Instance ID
    Description:
      zh-cn: 已有的AnalyticDB PostgreSQL实例ID。
      en: The ID of an existing AnalyticDB for PostgreSQL instance.
  AdminAccountName:
    Type: String
    Label:
      zh-cn: 管理员账号名称
      en: Admin Account Name
    Description:
      zh-cn: >-
        高权限管理员账号名称,2~16个字符,
        由小写字母、数字和下划线组成,不能以gp开头。
      en: >-
        Super admin account name, 2-16 characters,
        lowercase letters, digits and underscores, cannot start with gp.
    Default: db_admin
    AllowedPattern: '^(?!gp)[a-z][a-z0-9_]{0,14}[a-z0-9]$'
  AdminAccountPassword:
    Type: String
    Label:
      zh-cn: 管理员账号密码
      en: Admin Account Password
    Description:
      zh-cn: 管理员账号密码,8~32个字符。
      en: Admin account password, 8-32 characters.
    NoEcho: true
    MinLength: 8
    MaxLength: 32
  BizAccountName:
    Type: String
    Label:
      zh-cn: 业务账号名称
      en: Business Account Name
    Description:
      zh-cn: >-
        普通业务账号名称,2~16个字符,
        由小写字母、数字和下划线组成,不能以gp开头。
      en: >-
        Normal business account name, 2-16 characters,
        lowercase letters, digits and underscores, cannot start with gp.
    Default: biz_reader
    AllowedPattern: '^(?!gp)[a-z][a-z0-9_]{0,14}[a-z0-9]$'
  BizAccountPassword:
    Type: String
    Label:
      zh-cn: 业务账号密码
      en: Business Account Password
    Description:
      zh-cn: 业务账号密码,8~32个字符。
      en: Business account password, 8-32 characters.
    NoEcho: true
    MinLength: 8
    MaxLength: 32
Resources:
  AdminAccount:
    Type: ALIYUN::GPDB::Account
    Properties:
      DBInstanceId:
        Ref: DBInstanceId
      AccountName:
        Ref: AdminAccountName
      AccountPassword:
        Ref: AdminAccountPassword
      AccountType: Super
      AccountDescription: 数据库管理员账号,拥有实例管理和用户授权权限
  BizAccount:
    Type: ALIYUN::GPDB::Account
    DependsOn: AdminAccount
    Properties:
      DBInstanceId:
        Ref: DBInstanceId
      AccountName:
        Ref: BizAccountName
      AccountPassword:
        Ref: BizAccountPassword
      AccountType: Normal
      AccountDescription: 业务只读账号,仅用于数据查询和分析
Outputs:
  AdminAccountName:
    Label:
      zh-cn: 管理员账号
      en: Admin Account
    Description:
      zh-cn: 创建成功的高权限管理员账号名称。
      en: The name of the created Super admin account.
    Value:
      Fn::GetAtt:
        - AdminAccount
        - AccountName
  BizAccountName:
    Label:
      zh-cn: 业务账号
      en: Business Account
    Description:
      zh-cn: 创建成功的普通业务账号名称。
      en: The name of the created Normal business account.
    Value:
      Fn::GetAtt:
        - BizAccount
        - AccountName
  DBInstanceId:
    Label:
      zh-cn: GPDB实例ID
      en: GPDB Instance ID
    Description:
      zh-cn: 账号所属的数据库实例ID。
      en: The ID of the database instance.
    Value:
      Fn::GetAtt:
        - AdminAccount
        - DBInstanceId
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "为AnalyticDB PostgreSQL实例同时创建管理账号和业务账号,实现权限分离。",
    "en": "Create both a Super admin account and a Normal business account for privilege separation."
  },
  "Parameters": {
    "DBInstanceId": {
      "Type": "String",
      "Label": {
        "zh-cn": "GPDB实例ID",
        "en": "GPDB Instance ID"
      },
      "Description": {
        "zh-cn": "已有的AnalyticDB PostgreSQL实例ID。",
        "en": "The ID of an existing AnalyticDB for PostgreSQL instance."
      }
    },
    "AdminAccountName": {
      "Type": "String",
      "Label": {
        "zh-cn": "管理员账号名称",
        "en": "Admin Account Name"
      },
      "Description": {
        "zh-cn": "高权限管理员账号名称,2~16个字符,由小写字母、数字和下划线组成,不能以gp开头。",
        "en": "Super admin account name, 2-16 characters, lowercase letters, digits and underscores, cannot start with gp."
      },
      "Default": "db_admin",
      "AllowedPattern": "^(?!gp)[a-z][a-z0-9_]{0,14}[a-z0-9]$"
    },
    "AdminAccountPassword": {
      "Type": "String",
      "Label": {
        "zh-cn": "管理员账号密码",
        "en": "Admin Account Password"
      },
      "Description": {
        "zh-cn": "管理员账号密码,8~32个字符。",
        "en": "Admin account password, 8-32 characters."
      },
      "NoEcho": true,
      "MinLength": 8,
      "MaxLength": 32
    },
    "BizAccountName": {
      "Type": "String",
      "Label": {
        "zh-cn": "业务账号名称",
        "en": "Business Account Name"
      },
      "Description": {
        "zh-cn": "普通业务账号名称,2~16个字符,由小写字母、数字和下划线组成,不能以gp开头。",
        "en": "Normal business account name, 2-16 characters, lowercase letters, digits and underscores, cannot start with gp."
      },
      "Default": "biz_reader",
      "AllowedPattern": "^(?!gp)[a-z][a-z0-9_]{0,14}[a-z0-9]$"
    },
    "BizAccountPassword": {
      "Type": "String",
      "Label": {
        "zh-cn": "业务账号密码",
        "en": "Business Account Password"
      },
      "Description": {
        "zh-cn": "业务账号密码,8~32个字符。",
        "en": "Business account password, 8-32 characters."
      },
      "NoEcho": true,
      "MinLength": 8,
      "MaxLength": 32
    }
  },
  "Resources": {
    "AdminAccount": {
      "Type": "ALIYUN::GPDB::Account",
      "Properties": {
        "DBInstanceId": {
          "Ref": "DBInstanceId"
        },
        "AccountName": {
          "Ref": "AdminAccountName"
        },
        "AccountPassword": {
          "Ref": "AdminAccountPassword"
        },
        "AccountType": "Super",
        "AccountDescription": "数据库管理员账号,拥有实例管理和用户授权权限"
      }
    },
    "BizAccount": {
      "Type": "ALIYUN::GPDB::Account",
      "DependsOn": "AdminAccount",
      "Properties": {
        "DBInstanceId": {
          "Ref": "DBInstanceId"
        },
        "AccountName": {
          "Ref": "BizAccountName"
        },
        "AccountPassword": {
          "Ref": "BizAccountPassword"
        },
        "AccountType": "Normal",
        "AccountDescription": "业务只读账号,仅用于数据查询和分析"
      }
    }
  },
  "Outputs": {
    "AdminAccountName": {
      "Label": {
        "zh-cn": "管理员账号",
        "en": "Admin Account"
      },
      "Description": {
        "zh-cn": "创建成功的高权限管理员账号名称。",
        "en": "The name of the created Super admin account."
      },
      "Value": {
        "Fn::GetAtt": [
          "AdminAccount",
          "AccountName"
        ]
      }
    },
    "BizAccountName": {
      "Label": {
        "zh-cn": "业务账号",
        "en": "Business Account"
      },
      "Description": {
        "zh-cn": "创建成功的普通业务账号名称。",
        "en": "The name of the created Normal business account."
      },
      "Value": {
        "Fn::GetAtt": [
          "BizAccount",
          "AccountName"
        ]
      }
    },
    "DBInstanceId": {
      "Label": {
        "zh-cn": "GPDB实例ID",
        "en": "GPDB Instance ID"
      },
      "Description": {
        "zh-cn": "账号所属的数据库实例ID。",
        "en": "The ID of the database instance."
      },
      "Value": {
        "Fn::GetAtt": [
          "AdminAccount",
          "DBInstanceId"
        ]
      }
    }
  }
}