This topic describes how to use Alibaba Cloud SDK for Java to call the ModifyInstanceAttribute operation of ApsaraDB for Redis to modify the attributes of an ApsaraDB for Redis instance, including its name and password.


  • You must have an Alibaba Cloud account and an AccessKey pair (AccessKey ID and AccessKey secret) to use Alibaba Cloud SDK for Java. You can create and view your AccessKey pair on the AccessKey Management page in the Alibaba Cloud Management Console.
  • You have installed Alibaba Cloud SDK for Java. For more information about SDK versions, see Alibaba Cloud SDK.
            <! -- -->
            <! -- -->

Sample code

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.r_kvstore.model.v20150101.ModifyInstanceAttributeRequest;
import com.aliyuncs.r_kvstore.model.v20150101.ModifyInstanceAttributeResponse;

 * Call the ModifyInstanceAttribute operation to modify the attributes of an ApsaraDB for Redis instance, including its name and password.
public class ModifyInstanceAttribute {
    public static void main(String[] args) {
        // Initialize request parameters.
        DefaultProfile profile = DefaultProfile.getProfile(
                 "<your-region-id>", // The ID of the region.
                 "<your-access-key-id>", // The AccessKey ID.
                 "<your-access-key-secret>"); // The AccessKey secret.
        IAcsClient client = new DefaultAcsClient(profile);
        // Configure request parameters.
        ModifyInstanceAttributeRequest request = new ModifyInstanceAttributeRequest();
        // The ID of the instance that you want to modify.
        // The new instance name.
        // The new password of the instance.
        try {
            // Send a request to get a response.
            ModifyInstanceAttributeResponse response = client.getAcsResponse(request);
            // Process the response.
            System.out.println(new Gson().toJson(response));
        } catch (ClientException e) {
            System.out.println("ErrCode:" + e.getErrCode());
            System.out.println("ErrMsg:" + e.getErrMsg());
            System.out.println("RequestId:" + e.getRequestId());