Create an account using a ROS template

更新时间:
复制 MD 格式

This topic describes how to use Resource Orchestration Service to create a privileged database account for an AnalyticDB for MySQL cluster.

Prerequisites

The RAM user must have the following permissions:

  • The AliyunROSFullAccess permission, which grants full permissions to manage Resource Orchestration Service (ROS).

  • The AliyunADBFullAccess permission, which grants full permissions to manage AnalyticDB for MySQL.

    Note

    For demonstration purposes, this example uses the AliyunADBFullAccess policy. In a production environment, grant only the required permissions before you call the API operations. For more information about permission policies for AnalyticDB for MySQL, see System policy reference for AnalyticDB for MySQL.

Procedure

  1. Log on to the ROS console. In the top navigation bar, select a region.

  2. In the left-side navigation pane, click Stack. Choose Create Stack > Use ROS.

    • For Specify Template, select Select an Existing Template.

    • For Template Import Method, select Input Template.

  3. For Template Content, select ROS, enter the template code, and then click Next.

    The following are sample ROS templates for creating a privileged database account. For more information, see ALIYUN::ADB::Account.

    YAML

    ROSTemplateFormatVersion: '2015-09-01'
    Parameters:
      DBClusterId:
        Type: String
        Description: The ID of the cluster.
      AccountPassword:
        Type: String
        Description: |-
          The password of the account.
          The password must contain uppercase letters, lowercase letters, digits, and special
          characters.
          Special characters include ! @ # $ % ^ * ()  _ + - and =
          The password must be 8 to 32 characters in length.
      AccountName:
        Type: String
        Description: The name of the account.
    Resources:
      Account:
        Type: ALIYUN::ADB::Account
        Properties:
          DBClusterId:
            Ref: DBClusterId
          AccountPassword:
            Ref: AccountPassword
          AccountName:
            Ref: AccountName
    Outputs:
      DBClusterId:
        Description: The ID of the cluster.
        Value:
          Fn::GetAtt:
            - Account
            - DBClusterId
      AccountType:
        Description: The type of the account.
        Value:
          Fn::GetAtt:
            - Account
            - AccountType
      AccountName:
        Description: The name of the account.
        Value:
          Fn::GetAtt:
            - Account
            - AccountName

    JSON

    {
      "ROSTemplateFormatVersion": "2015-09-01",
      "Parameters": {
        "DBClusterId": {
          "Type": "String",
          "Description": "The ID of the cluster."
        },
        "AccountPassword": {
          "Type": "String",
          "Description": "The password of the account.\nThe password must contain uppercase letters, lowercase letters, digits, and special\ncharacters.\nSpecial characters include ! @ # $ % ^ * ()  _ + - and =\nThe password must be 8 to 32 characters in length."
        },
        "AccountName": {
          "Type": "String",
          "Description": "The name of the account."
        }
      },
      "Resources": {
        "Account": {
          "Type": "ALIYUN::ADB::Account",
          "Properties": {
            "DBClusterId": {
              "Ref": "DBClusterId"
            },
            "AccountPassword": {
              "Ref": "AccountPassword"
            },
            "AccountName": {
              "Ref": "AccountName"
            }
          }
        }
      },
      "Outputs": {
        "DBClusterId": {
          "Description": "The ID of the cluster.",
          "Value": {
            "Fn::GetAtt": [
              "Account",
              "DBClusterId"
            ]
          }
        },
        "AccountType": {
          "Description": "The type of the account.",
          "Value": {
            "Fn::GetAtt": [
              "Account",
              "AccountType"
            ]
          }
        },
        "AccountName": {
          "Description": "The name of the account.",
          "Value": {
            "Fn::GetAtt": [
              "Account",
              "AccountName"
            ]
          }
        }
      }
    }
  4. On the Create Stack page, set the following parameters.

    Parameter

    Required

    Description

    Example

    Stack Name

    Yes

    The name of the stack.

    ADB_test_account

    DBClusterId

    Yes

    The cluster ID.

    amv-bp12vj6gwa2j****

    AccountPassword

    Yes

    The password of the database account.

    Password****

    AccountName

    Yes

    The name of the database account.

    test

  5. Click Create. The stack is successfully created when its Status changes to Created..image

  6. After the stack is created, click the Output tab to view the details of the database account. You can also view the account details in the AnalyticDB for MySQL console by following these steps:

    1. Log on to the AnalyticDB for MySQL console. In the upper-left corner of the console, select a region. In the left-side navigation pane, click Clusters. Find the cluster that you want to manage and click the cluster ID.

    2. In the left-side navigation pane, click Account Management to view the created database account.