Adds a user to a bastion host.

Usage notes

You can call this operation to add a user to a bastion host. You can add local users and Resource Access Management (RAM) users. After a Bastionhost administrator adds a user to a bastion host, the O&M personnel can log on to the bastion host as the user to perform O&M operations on the host on which they have permissions.

Limits

You can call this operation up to 10 times per second per account. If the number of the calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes CreateUser

The operation that you want to perform.

Set the value to CreateUser.

InstanceId String Yes bastionhost-cn-st220aw****

The ID of the bastion host to which you want to add a user.

Note You can call the DescribeInstances operation to query the ID of the bastion host.
Source String Yes Local

The source of the user that you want to add. Valid values:

  • Local: a local user
  • Ram: a RAM user
UserName String Yes abc_def

The logon name of the user that you want to add. The logon name can contain only letters, digits, and underscores (_) and can be up to 128 characters in length.

RegionId String No cn-hangzhou

The region ID of the bastion host to which you want to add a user.

Note For more information about the mapping between region IDs and region names, see Regions and zones.
DisplayName String No Bob

The display name of the user that you want to add. This display name can be up to 128 characters in length.

Password String No ****

The logon password of the user that you want to add. The logon password can be up to 128 characters in length.

Note This parameter is required if the Source parameter is set to Local.
Comment String No comment

The remarks of the user that you want to add. The remarks can be up to 500 characters in length.

Email String No 123@qq.com

The email address of the user that you want to add.

Mobile String No 1359999****

The mobile phone number of the user that you want to add.

SourceUserId String No 122748924538****

The unique identifier of the user that you want to add.

Note This parameter uniquely identifies a RAM user of the bastion host. This parameter is required if the Source parameter is set to Ram. You can call the ListUsers operation to obtain the unique identifier of the user from the UserId response parameter.
MobileCountryCode String No CN

The country where the mobile number of the user is registered. Default value: CN. Valid values:

  • CN: the Chinese mainland, whose country calling code is +86
  • HK: Hong Kong (China), whose country calling code is +852
  • MO: Macau (China), whose country calling code is +853
  • TW: Taiwan (China), whose country calling code is +886
  • RU: Russia, whose country calling code is +7
  • SG: Singapore, whose country calling code is +65
  • MY: Malaysia, whose country calling code is +60
  • ID: Indonesia, whose country calling code is +62
  • DE: Germany, whose country calling code is +49
  • AU: Australia, whose country calling code is +61
  • US: US, whose country calling code is +1
  • AE: United Arab Emirates, whose country calling code is +971
  • JP: Japan, whose country calling code is +81
  • GB: UK, whose country calling code is +44
  • IN: India, whose country calling code is +91
  • KR: Republic of Korea, whose country calling code is +82
  • PH: Philippines, whose country calling code is +63
  • CH: Switzerland, whose country calling code is +41
  • SE: Sweden, whose country calling code is +46

All Alibaba Cloud API operations must include common request parameters. For more information about common request parameters, see Common parameters.

For more information about sample requests, see the "Examples" section of this topic.

Response parameters

Parameter Type Example Description
RequestId String EC9BF0F4-8983-491A-BC8C-1B4DD94976DE

The ID of the request, which is used to locate and troubleshoot issues.

UserId String 1

The ID of the user.

Examples

Sample requests

http(s)://[Endpoint]/?Action=CreateUser
&InstanceId=bastionhost-cn-st220aw****
&Source=Local
&UserName=abc_def
&<Common request parameters>

Sample success responses

XML format

<CreateUserResponse>
      <RequestId>EC9BF0F4-8983-491A-BC8C-1B4DD94976DE</RequestId>
      <UserId>1</UserId>
</CreateUserResponse>

JSON format

{
	"RequestId": "EC9BF0F4-8983-491A-BC8C-1B4DD94976DE",
	"UserId": "1"
}

Error codes

HTTP status code Error code Error message Description
500 InternalError An unknown error occurred. The error message returned because an unknown error occurred.
400 InvalidParameter The argument is invalid. The error message returned because one or more parameters are invalid.
400 UserAlreadyExists The user already exists. The error message returned because the user that you want to add already exists.

For a list of error codes, visit the API Error Center.