ALIYUN::REDIS::Account类型用于在Redis实例中创建有特定权限的账号。

语法

{
  "Type": "ALIYUN::REDIS::Account",
  "Properties": {
    "AccountDescription": String,
    "InstanceId": String,
    "AccountName": String,
    "AccountPrivilege": String,
    "AccountType": String,
    "AccountPassword": String
  }
}

属性

属性名称类型必须允许更新描述约束
AccountDescriptionString账号描述。长度为2~256个字符,以汉字和英文字母开头,不能以http: //https: //开头。可包含汉字、英文字母、短划线(-)和数字。
InstanceIdString实例ID。
AccountNameString账号名称。长度不超过16个字符,以小写英文字母开头。可包含小写英文字母、数字和下划线(_)。
AccountPrivilegeString账号权限。取值:
  • RoleReadOnly:只读。
  • RoleReadWrite(默认值):读写。
  • RoleRepl:复制。复制权限支持读写,且开放SYNC/PSYNC命令。目前仅支持在4.0标准版实例中创建有复制权限的账号。
AccountTypeString账号类型。取值:Normal(普通账号)。
AccountPasswordString账号密码。长度为8~32个字符,必须包含大写英文字母、小写英文字母、特殊字符和数字中至少三种,支持的特殊字符为:!@#$%^*()_+-=

返回值

Fn::GetAtt

  • InstanceId:实例ID。
  • AccountName:账号名称。

示例

  • YAML格式

    ROSTemplateFormatVersion: '2015-09-01'
    Parameters:
      InstanceId:
        Type: String
        Description: The ID of the instance for which you want to create the account.
    Resources:
      Account:
        Type: ALIYUN::REDIS::Account
        Properties:
          AccountDescription: Test Create Redis Account
          InstanceId:
            Ref: InstanceId
          AccountType: Normal
          AccountName: demo_redis
          AccountPrivilege: RoleReadWrite
          AccountPassword: Admin@123!
    Outputs:
      InstanceId:
        Description: The name of the instance.
        Value:
          Fn::GetAtt:
            - Account
            - InstanceId
      AccountName:
        Description: The name of the account.
        Value:
          Fn::GetAtt:
            - Account
            - AccountName
  • JSON格式

    {
      "ROSTemplateFormatVersion": "2015-09-01",
      "Parameters": {
        "InstanceId": {
          "Type": "String",
          "Description": "The ID of the instance for which you want to create the account."
        }
      },
      "Resources": {
        "Account": {
          "Type": "ALIYUN::REDIS::Account",
          "Properties": {
            "AccountDescription": "Test Create Redis Account",
            "InstanceId": {
              "Ref": "InstanceId"
            },
            "AccountType": "Normal",
            "AccountName": "demo_redis",
            "AccountPrivilege": "RoleReadWrite",
            "AccountPassword": "Admin@123!"
          }
        }
      },
      "Outputs": {
        "InstanceId": {
          "Description": "The name of the instance.",
          "Value": {
            "Fn::GetAtt": [
              "Account",
              "InstanceId"
            ]
          }
        },
        "AccountName": {
          "Description": "The name of the account.",
          "Value": {
            "Fn::GetAtt": [
              "Account",
              "AccountName"
            ]
          }
        }
      }
    }

更多示例,请参见创建云数据库Redis实例、设置Redis实例的IP白名单和创建有特定权限的账号的组合示例:JSON示例YAML示例