All Products
Search
Document Center

Elastic Compute Service:ModifyInstanceAttribute

Last Updated:May 28, 2026

This API modifies attributes of an ECS instance, such as the password, instance name, hostname, security group, MTU, and user data.

Operation description

This API call is not supported for instances protected by a resource security lock. For more information, see How resource security locks affect API calls.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

ecs:ModifyInstanceAttribute

update

*Instance

acs:ecs:{#regionId}:{#accountId}:instance/{#instanceId}

SecurityGroup

acs:ecs:{#regionId}:{#accountId}:securitygroup/{#SecurityGroupId}

  • ecs:tag
  • ecs:PasswordCustomized
None

Request parameters

Parameter

Type

Required

Description

Example

InstanceId

string

Yes

The ID of the instance.

i-bp67acfmxazb4ph****

Password

string

No

The password of the instance. The password must be 8 to 30 characters long and contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. The supported special characters are ()~!@#$%^&*-_+=|{}[]:;'<>,.?/. For a Windows instance, the password cannot start with a forward slash (/). Note the following when you use this parameter:

  • The instance cannot be in the Starting state.

  • The new password takes effect after you restart the instance from the ECS console (see Restart an instance) or by calling the RebootInstance operation. Restarting the instance from within its operating system does not apply the change.

Note

To prevent password exposure, send requests that include the Password parameter over HTTPS.

Test123456&$

HostName

string

No

The hostname of the operating system. Note the following when you use this parameter:

  • The instance cannot be in the Pending or Starting state. Otherwise, the specified hostname and the /etc/hosts configuration may not take effect. You can call the DescribeInstances operation to query the current state of the instance.

  • The new hostname takes effect after you restart the instance from the ECS console (see Restart an instance) or by calling the RebootInstance operation. Restarting the instance from within its operating system does not apply the change.

The hostname must meet the following requirements for different operating systems:

  • For Windows Server instances: The hostname must be 2 to 15 characters long and contain letters, digits, and hyphens (-). It cannot start or end with a hyphen, contain consecutive hyphens, or consist of only digits.

  • For other types of instances (such as Linux): The hostname must be 2 to 64 characters long. You can use periods (.) to separate the hostname into segments. Each segment can contain letters, digits, and hyphens (-). The hostname cannot start or end with a period or hyphen, and cannot contain consecutive periods or hyphens.

testHostName

InstanceName

string

No

The instance name. The name must be 2 to 128 characters long. It must start with a letter or a Chinese character and cannot start with http:// or https://. The name can contain digits, colons (:), underscores (_), and hyphens (-).

testInstanceName

Description

string

No

The instance description. The description must be 2 to 256 characters long and cannot start with http:// or https://.

testInstanceDescription

UserData

string

No

The user data of the instance. User data should be Base64-encoded before it is passed. Note the following when you use this parameter:

  • The user data must comply with the limits described in Generate user data.

  • After you restart the instance, the new user data is available on the instance but is not executed.

Note

The raw data cannot exceed 32 KB before being encoded. Do not pass confidential information, such as passwords and private keys, in plaintext. If you must pass confidential information, encrypt and then Base64-encode it. On the instance, decrypt the information by using the corresponding decryption method.

ZWNobyBoZWxsbyBlY3Mh

Recyclable

boolean

No

Note

This parameter is in invitation-only preview and is not publicly available.

true

CreditSpecification

string

No

The performance mode of the burstable performance instance. Valid values:

  • Standard: standard mode.

  • Unlimited: unlimited mode.

For more information about the performance modes of burstable performance instances, see Overview of burstable performance instances.

Standard

DeletionProtection

boolean

No

Specifies whether to enable deletion protection for the instance. This setting prevents the instance from being released from the console or by calling the DeleteInstance operation.

Note

This feature applies only to pay-as-you-go instances and protects instances only from manual release operations. It does not affect system-initiated release operations.

false

NetworkInterfaceQueueNumber

integer

No

The number of queues for the primary network interface. Note the following when you use this parameter:

  • The instance must be in the Stopped state.

  • The value cannot exceed the maximum number of queues that the instance type supports for a single network interface. The total number of queues across all network interfaces of the instance cannot exceed the total queue quota that the instance type supports. You can call the DescribeInstanceTypes operation to query the maximum number of queues per network interface and the total queue quota for an instance type.

  • If you set this parameter to -1, the number of queues for the primary network interface is reset to the default value for the instance type. You can call the DescribeInstanceTypes operation to query the default number of queues for an elastic network interface of an instance type.

8

SecurityGroupIds

array

No

The IDs of security groups to assign to the instance. Note the following when you use this parameter:

  • The security group IDs in the array must be unique. The number of security groups that an instance can join is limited. For more information, see Limits.

  • Specifying this parameter removes the instance from its current security groups. To retain existing security group associations, you must include their IDs in this array.

  • You can switch the security group type. However, the specified security groups cannot include both basic and enterprise security groups.

  • The security groups must belong to the same VPC as the instance.

  • This parameter is not supported for instances in the classic network.

Note

The change takes effect on the instance after a short delay.

sg-bp15ed6xe1yxeycg7o****

string

No

The ID of the security group.

sg-bp15ed6xe1yxeycg7o****

RemoteConnectionOptions

object

No

Note

This parameter is in invitation-only preview and is not publicly available.

Password

string

No

Note

This parameter is in invitation-only preview and is not publicly available.

hide

Type

string

No

Note

This parameter is in invitation-only preview and is not publicly available.

hide

EnableJumboFrame

boolean

No

Specifies whether to enable jumbo frames. When jumbo frames are enabled, the MTU of the instance is 8500. When jumbo frames are disabled, the MTU of the instance is 1500. Valid values:

  • true

  • false

Note the following when you use this parameter:

  • The instance must be in the Running or Stopped state.

  • The instance must be in a VPC.

  • Only some instance types support jumbo frames. For more information, see ECS instance MTU.

false

CpuOptions.Core

integer

No

The number of CPU cores. This parameter is not customizable and uses a default value.

2

CpuOptions.ThreadsPerCore

integer

No

The number of threads per core. The total number of vCPUs for an ECS instance is the value of CpuOptions.Core multiplied by the value of CpuOptions.ThreadsPerCore.

  • Setting CpuOptions.ThreadsPerCore to 1 disables hyper-threading.

  • Only some instance types support specifying the number of threads per core.

2

CpuOptions.TopologyType

string

No

The CPU topology type of the instance. Valid values:

  • ContinuousCoreToHTMapping: The hyper-threads of the same core are contiguous.

  • DiscreteCoreToHTMapping: The hyper-threads of the same core are discrete.

Default value: None.

Note the following when you use this parameter:

  • The instance must be in the Stopped state.

Note

This parameter is supported by only some instance families. See View and modify the CPU topology for a list of supported families.

DiscreteCoreToHTMapping

PrivateDnsNameOptions

object

No

The private DNS name settings for the instance.

For more information about private DNS name resolution, see ECS private DNS resolution .

EnableInstanceIdDnsARecord

boolean

No

Specifies whether to enable resolution of the instance ID-based domain name to an IPv4 address. Valid values:

  • true

  • false

Default value: false.

false

EnableInstanceIdDnsAAAARecord

boolean

No

Specifies whether to enable resolution of the instance ID-based domain name to an IPv6 address. Valid values:

  • true

  • false

Default value: false.

false

EnableIpDnsARecord

boolean

No

Specifies whether to enable resolution of the IP address-based domain name to an IPv4 address. Valid values:

  • true

  • false

Default value: false.

false

EnableIpDnsPtrRecord

boolean

No

Specifies whether to enable reverse DNS resolution of an IPv4 address to an IP address-based domain name. Valid values:

  • true

  • false

Default value: false.

false

HostnameType

string

No

The hostname type. Valid values:

  • Custom: a custom hostname.

  • IpBased: an IP address-based hostname.

  • InstanceIdBased: an instance ID-based hostname.

Default value: Custom.

Custom

CpuOptions

object

No

NestedVirtualization

string

No

Note

This parameter is in invitation-only preview and is not publicly available.

enabled

EnableNetworkEncryption

boolean

No

Specifies whether to enable VPC network traffic encryption. Valid values:

  • true

  • false

Note

This parameter is in invitation-only preview and is not publicly available.

true

Response elements

Element

Type

Description

Example

object

RequestId

string

The request ID.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

Examples

Success response

JSON format

{
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidInstanceName.Malformed The specified parameter "InstanceName" is not valid. The specified InstanceName parameter is invalid.
400 InvalidDescription.Malformed The specified parameter "Description" is not valid. The source description can be 2 to 256 characters in length. It cannot start with http:// and https://.
400 InvalidRemoteConnectionOptions.Password The remote connection password is invalid.
400 InvalidRemoteConnectionOptions.Type The remote connection type is invalid.
400 InstanceType.ValueNotSupported The instance type not supported.
400 OSType.ValueNotSupported The OS type is not supported.
400 InvalidHostPassword.Malformed The specified parameter "Password" is not valid.
400 InvalidHostName.Malformed The specified parameter "HostName" is not valid.
400 InvalidPassword.Malformed The specified parameter "Password" is not valid.
400 InvalidUserData.SizeExceeded The specified parameter "UserData" exceeds the size.
400 InvalidUserData.NotSupported TThe specified parameter "UserData" only support the vpc and IoOptimized Instance.
400 ImageNotSupportCloudInit The specified image does not support cloud-init.
400 ChargeTypeViolation Pay-As-You-Go instances do not support this operation.
400 InvalidParameter.RecycleBin You do not have permission to set recyclable properties. You are not authorized to perform the operation.
400 InvalidParameter.CreditSpecification The specified CreditSpecification is not supported in this region. The running mode of the specified burst performance instance is not supported in this zone.
400 InvalidInstanceStatus.CreditSpecRestricted The current status of the resource does not support this operation. The resource is in a state that does not support the current operation.
400 InvalidInstanceStatus.NotRunning The current status of the resource is invalid, you can only do this operation when instance is running. The resource is in a state that does not support the operation. Perform the operation when the instance is in the Running state.
400 InvalidNetworkType.NotSupported The classic networkType does not support to modify security group
400 InvalidOperation.EniCountExceeded =The maximum number of eni in a enterprise security group is exceeded.
400 JoinedGroupLimitExceed %s The maximum number of security groups to which the specified resource can be added has been reached. For more information, see the return value of the %s placeholder in the error message.
400 InvalidParameter The specified parameter is not valid. A specified parameter is invalid.
400 InvalidOperation.InvalidEcsState %s
400 InvalidParam.NotSupportJumboFrame Not support jumbo frame.
400 InvalidOperation.InstanceStatusNotSupport The instance status is not support modify mtu config.
400 InvalidOperation.InstanceStatusUnsupported The specified instance status does not support modification of cpu topology type. The specified instance status does not support modification of cpu topology type.
400 InvalidParameter.CpuOptionsTopologyType The specified parameter CpuOptions.TopologyType: %s is not valid. Illegal enumeration value for current CPU topology type
400 InvalidInstanceType.NotSupportCpuOptionsTopologyType The specified instance type does not support CpuOptions.TopologyType: %s. The current specification does not support the specified CPU topology type
400 InvalidAdditionalInfoPvdConfig.SizeExceeded The specified parameter AdditionalInfo.PvdConfig exceeds the size.
400 InvalidInstanceType.NotSupportHighDensityMode The specified instance type does not support the use of the high density mode. The current instance type does not support the cloud disk high-density mode.
400 InvalidStatus.StoppedRequired The current state of the resource does not support this operation, it can only be operated in a stopped state. The current state of the resource does not support this operation, only down state can operate
400 InvalidParameter.CpuOptionsTurboMode The specified parameter TurboMode is not valid. The specified parameter frequency mode is invalid
400 InvalidInstanceType.EnableNVSUnsupported The specified instance type does not support EnableNVS.
400 InvalidInstanceType.EnableVISSTUnsupported The specified instance type does not support EnableVISST.
400 InvalidInstanceType.EnableVRDTUnsupported The specified instance type does not support EnableVRDT.
400 InvalidInstanceType.SingleCoreMaxModeUnsupported The specified instance type does not support TurboMode: "SINGLE CORE MAX". The specified instance type does not support single-core maximum turbo mode
400 InvalidInstanceType.GpuOptionsConfidentialComputingUnsupported The specified instance type does not support the confidential computing mode. the current instance type does not support encrypted computing mode.
400 InvalidParameter.GpuOptionsConfidentialComputing The specified parameter confidential computing mode is not valid. The enum value of the GPU encryption computing mode of the current instance is invalid.
400 InvalidParameterAuthorized.GpuOptionsConfidentialComputing The specified parameter confidential computing mode is unauthorized.
400 InvalidParameter.CpuOptionsNestedVirtualization The specified parameter CpuOptions.NestedVirtualization: %s is not valid.
400 InvalidInstanceType.NotSupportCpuOptionsNestedVirtualization The specified instance type does not support CpuOptions.NestedVirtualization: %s. The specified instance type does not support CpuOptions.NestedVirtualization value.
500 InternalError The request processing has failed due to some unknown error.
403 IncorrectInstanceStatus The current status of the resource does not support this operation.
403 InstanceLockedForSecurity The specified operation is denied as your instance is locked for security reasons.
403 OperationDenied The instance amount in the specified SecurityGroup reach its limit. The maximum number of instances in the specified security group has been reached.
403 InvalidUserData.Forbidden User not authorized to input the parameter "UserData"please apply for permission "UserData"
403 InvalidUserData.Base64FormatInvalid The specified UserData is not valid An error occurred when the specified UserData parameter is encoded.
403 InvalidChargeType.ValueNotSupported Deletion protection is only valid for postPaid instance, not for prePaid or spot instance. Release protection can be enabled only for pay-as-you-go instances.
403 InvalidUser.Unauthorized The user is not authorized You are not authorized to perform this operation.
403 EnterpriseGroupLimited.MutliGroupType The specified instance can not join multi SecurityGroup types. The specified instance cannot belong to both a basic and an advanced security group. You can call the DescribeSecurityGroups operation to query the type of security groups.
403 SecurityGroupInstanceLimitExceed %s
403 InstanceNotInSecurityGroup The instance not in the group.
403 InvalidOperation.InvalidRegion %s
403 InvalidOperation.ResourceManagedByCloudProduct %s You cannot modify security groups managed by cloud services.
403 InvalidParameter.InvalidEniQueueNumber %s
403 InvalidOperation.MaxEniQueueNumberExceeded %s
403 InvalidOperation.ExceedInstanceTypeQueueNumber %s The maximum number of queues for all ENIs on an instance has been exceeded. For more information, see the return value of the %s placeholder in the error message.
403 InvalidOperation.InstanceTypeNotSupportHighPerformanceTrafficMode %s The instance type of the specified instance does not support the NIC of the RDMA communication mode.
403 InvalidParameter.InvalidQueuePairNumber %s
403 InvalidOperation.MaxEniQueuePairNumberExceed %s
403 InvalidOperation.EniQueuePairNumberOverflow %s
403 AclLimitExceed %s The number of ACL rules for an ENI or instance exceeds the upper limit.
403 InvalidInstanceType.CpuOptionsThreadsPerCoreUnsupported The current instance type does not support setting or modifying the CpuOptions.ThreadsPerCore parameter. The current instance type does not support setting or modifying the CpuOptions.ThreadsPerCore parameter.
403 InvalidParameter.CpuOptionsCore The specified parameter CpuOptions.Core is not valid. The specified parameter CpuOptions.Core is not valid.
403 InvalidParameter.CpuOptionsThreadsPerCore The specified parameter CpuOptions.ThreadsPerCore is not valid. The specified parameter CpuOptions.ThreadsPerCore is not valid.
403 InvalidOperation.UserNotSupportNetworkEncryption User not support network encryption. The user does not support specifying network traffic encryption parameters.
403 InvalidOperation.InstanceTypeNotSupportNetworkEncryption The specified instance type does not support network encryption. the specified instance type does not support vpc traffic encryption
404 InvalidInstanceId.NotFound The specified InstanceId does not exist. The specified instanceId is invalid.
404 InvalidSecurityGroupId.NotFound The specified SecurityGroupId does not exist. The specified security group does not exist in this account. Check whether the security group ID is correct.
404 Credit.NotFound The specified credit information does not exist. The specified burst performance instance credit information does not exist.
404 InvalidInstanceStatus.NeedRestart The current status of the resource is invalid, you can only do this operation after instance is restarted.
404 InvalidParameter.SecurityGroupIdRepeated The specified security group ids has repeated. Duplicate security group IDs are specified. Check whether the specified SecurityGroupIds.N parameter is valid.
404 InvalidSecurityGroupType.NotSupportClassic The specified SecurityGroupIds have classic group type. The specified security group is in the classic network. Check whether the specified SecurityGroupIds.N parameter is valid.
404 InvalidSecurityGroupVpc.NotBelongToOneVpc The specified SecurityGroupIds are belong to different vpc. The specified security groups belong to different VPCs. Check whether the specified SecurityGroupIds.N parameter is valid. You can call the DescribeSecurityGroups operation to query the VPCs to which the security groups belong.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.