IMS CLI reference
Manage IMS (Identity Management Service) resources from the command line with Alibaba Cloud CLI. This topic uses the GetUser operation as an example to query RAM user details.
Before you begin
If you are new to Alibaba Cloud CLI, read What is Alibaba Cloud CLI?.
Step 1: Install Alibaba Cloud CLI
Install Alibaba Cloud CLI on your operating system:
-
Windows: Install the CLI on Windows.
-
macOS: Install the CLI on macOS.
Alternatively, debug commands in Cloud Shell. What is Cloud Shell?.
Step 2: Configure Alibaba Cloud CLI
An Alibaba Cloud account has full access to all API operations, which poses a security risk. Create a RAM identity, grant permissions based on the principle of least privilege, and use that identity to call API operations.
Configure identity credentials and a region ID before using Alibaba Cloud CLI. Multiple credential types are supported (Configure and manage identity credentials). These steps use AK-based credentials as an example.
-
Create a RAM user and an AccessKey for identity credentials. Create a RAM user. Create an AccessKey.
-
Grant the RAM user read-only access to IMS by attaching the
AliyunRAMReadOnlyAccesspolicy. Manage RAM user permissions. -
Find an available region ID. Alibaba Cloud CLI sends requests to the specified region. Endpoints.
NoteAdd the
--regionoption to a command to override the default region in your profile and environment variables. Command-line options. -
Configure an AK-based credential profile named
AkProfilewith the RAM user's AccessKey. Configure and manage identity credentials.
Step 3: Generate a sample CLI command
-
In OpenAPI Explorer, go to the GetUser page.
-
On the Parameters tab, enter request parameters, then click CLI Example to view the sample command.
-
Run or copy the sample command.
-
Click Run Command
to debug the command in Cloud Shell. -
Click Repeat
to copy the command to the clipboard, then paste it into a local shell.Note-
When pasting the command into a local shell, ensure correct parameter formatting. Parameter formats.
-
OpenAPI Explorer adds
--regionto the sample command by default, which overrides the region in your credentials and environment variables. Keep or remove this option as needed.
-
-
Step 4: Call IMS OpenAPI operations
Example 1: List supported IMS OpenAPI operations
Use --help to list IMS API operations. See also the API overview.
-
Run the command.
aliyun ims --help -
The command returns the following output.
Usage: aliyun ims <ApiName> --parameter1 value1 --parameter2 value2 ... Product: Ims (Resource Access Management (RAM) Identity Management) Version: 2019-08-15 Available Api List: AddClientIdToOIDCProvider Adds a client ID to an OIDC provider. AddFingerprintToOIDCProvider Adds a verification fingerprint to an OIDC provider. AddUserToGroup Adds a RAM user to a user group. BindMFADevice Binds an MFA device to a RAM user. ChangePassword Changes the console logon password for the current RAM user. CreateAccessKey Creates an AccessKey for an Alibaba Cloud account or a RAM user. CreateAppSecret Creates an app secret for an application. CreateApplication Creates an application. CreateGroup Creates a user group. CreateLoginProfile Creates a logon profile for a RAM user. CreateOIDCProvider Creates an OIDC provider to establish a trust relationship with an external IdP.
Example 2: Query a specific RAM user
Call the GetUser operation to query the RAM user with ID 20732900249392****.
-
Run the command.
aliyun ims GetUser --UserId 20732900249392**** -
The command returns the following output.
{ "User": { "DisplayName": "test", "UserPrincipalName": "test@example.onaliyun.com", "Email": "alice@example.com", "UpdateDate": "2020-10-13T07:39:22Z", "MobilePhone": "86-1868888****", "UserId": "20732900249392****", "Comments": "This is a cloud computing engineer.", "LastLoginDate": "2020-10-12T09:12:00Z", "CreateDate": "2020-10-12T09:12:00Z", "ProvisionType": "Manual", "Tags": { "Tag": [ { "TagKey": "operator", "TagValue": "alice" } ] } }, "RequestId": "4507D1CD-526A-4E2B-A1E2-3AB045D1EE0B" }NoteIf an operation returns an error, verify the request parameters based on the error code.
Use the request ID from the response with OpenAPI Troubleshoot for self-service diagnostics.