ROS integration example

更新时间:
复制 MD 格式

A RAM user can use ROS to add a new user to DMS.

Create a RAM user and grant permissions

  1. Create a RAM user.

    1. Go to the Users page and click Create User.

    2. Set Logon Name to dms_test and for Access Mode, select Programmatic Access.

    3. Click OK. Record the UID of the RAM user.

  2. Grant permissions to the RAM user.

    1. Go to the Users page. In the Actions column of the target RAM user, click Add Permissions.

    2. Search for the AliyunDMSFullAccess and AliyunROSFullAccess policies.

      Note

      This example uses the AliyunDMSFullAccess policy, which grants permission to manage DMS resources.

      In production, select only the required permissions or create custom fine-grained policies. For more information, see identity management.

    3. Click Confirm to grant the permissions.

Procedure

  1. Log on to the ROS console. In the top navigation bar, select a region from the region drop-down list.

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

    • Specify Template: Select Select an Existing Template.

    • Template Import Method: Select Enter Template Content.

  3. In the Template Content section, select ROS and enter the following code.

    This example includes only a few key parameters, such as Uid, UserName, and RoleNames. For a full list of template parameters, see ALIYUN::DMS::User.

    YAML format

    ROSTemplateFormatVersion: '2015-09-01'
    Parameters:
     Status:
      Type: String
      Description: UserStatus
     Uid:
      Type: String
      Description: UserAliYunUid
     UserName:
      Type: String
      Description: UserNickName
     RoleNames:
      Type: Json
      Description: UserRole
     Mobile:
      Type: String
      Description: UserMobile
     Tid:
      Type: String
      Description: ''
    Resources:
     DMSEnterpriseUser:
      Type: 'ALIYUN::DMS::User'
      Properties:
       Status:
        Ref: Status
       Uid:
        Ref: Uid
       UserName:
        Ref: UserName
       RoleNames:
        Ref: RoleNames
       Mobile:
        Ref: Mobile
       Tid:
        Ref: Tid
    Outputs:
     Uid:
      Description: UserAliYunUid
      Value:
       'Fn::GetAtt':
        - DMSEnterpriseUser
        - Uid
     UserName:
      Description: UserNickName
      Value:
       'Fn::GetAtt':
        - DMSEnterpriseUser
        - UserName
     RoleNames:
      Description: UserRole
      Value:
       'Fn::GetAtt':
        - DMSEnterpriseUser
        - RoleNames
     UserId:
      Description: UserId
      Value:
       'Fn::GetAtt':
        - DMSEnterpriseUser
        - UserId
     RoleIds:
      Description: UserRoleId
      Value:
       'Fn::GetAtt':
        - DMSEnterpriseUser
        - RoleIds
     Mobile:
      Description: UserMobile
      Value:
       'Fn::GetAtt':
        - DMSEnterpriseUser
        - Mobile
     ParentUid:
      Description: ParentAliYunUid
      Value:
       'Fn::GetAtt':
        - DMSEnterpriseUser
        - ParentUid

    JSON format

    {
      "ROSTemplateFormatVersion": "2015-09-01",
      "Parameters": {
        "Status": {
          "Type": "String",
          "Description": "UserStatus"
        },
        "Uid": {
          "Type": "String",
          "Description": "UserAliYunUid"
        },
        "UserName": {
          "Type": "String",
          "Description": "UserNickName"
        },
        "RoleNames": {
          "Type": "Json",
          "Description": "UserRole"
        },
        "Mobile": {
          "Type": "String",
          "Description": "UserMobile"
        },
        "Tid": {
          "Type": "String",
          "Description": ""
        }
      },
      "Resources": {
        "DMSEnterpriseUser": {
          "Type": "ALIYUN::DMS::User",
          "Properties": {
            "Status": {
              "Ref": "Status"
            },
            "Uid": {
              "Ref": "Uid"
            },
            "UserName": {
              "Ref": "UserName"
            },
            "RoleNames": {
              "Ref": "RoleNames"
            },
            "Mobile": {
              "Ref": "Mobile"
            },
            "Tid": {
              "Ref": "Tid"
            }
          }
        }
      },
      "Outputs": {
        "Uid": {
          "Description": "UserAliYunUid",
          "Value": {
            "Fn::GetAtt": [
              "DMSEnterpriseUser",
              "Uid"
            ]
          }
        },
        "UserName": {
          "Description": "UserNickName",
          "Value": {
            "Fn::GetAtt": [
              "DMSEnterpriseUser",
              "UserName"
            ]
          }
        },
        "RoleNames": {
          "Description": "UserRole",
          "Value": {
            "Fn::GetAtt": [
              "DMSEnterpriseUser",
              "RoleNames"
            ]
          }
        },
        "UserId": {
          "Description": "UserId",
          "Value": {
            "Fn::GetAtt": [
              "DMSEnterpriseUser",
              "UserId"
            ]
          }
        },
        "RoleIds": {
          "Description": "UserRoleId",
          "Value": {
            "Fn::GetAtt": [
              "DMSEnterpriseUser",
              "RoleIds"
            ]
          }
        },
        "Mobile": {
          "Description": "UserMobile",
          "Value": {
            "Fn::GetAtt": [
              "DMSEnterpriseUser",
              "Mobile"
            ]
          }
        },
        "ParentUid": {
          "Description": "ParentAliYunUid",
          "Value": {
            "Fn::GetAtt": [
              "DMSEnterpriseUser",
              "ParentUid"
            ]
          }
        }
      }
    }
  4. Click Create to deploy the stack.

  5. After the stack is created, go to the Stack Information and Outputs tabs to view the stack status and outputs.

  6. After the stack is created, you can view the user in DMS using the DMS console, OpenAPI, or an SDK. For information about how to view users in the DMS console, see User management.

    The created user dms_testuser appears in the user list with the Standard User and DBA roles.