全部產品
Search
文件中心

Elastic Compute Service:ModifyInstanceAttribute

更新時間:Jun 29, 2026

本介面用於修改一台 ECS 執行個體的部分屬性資訊,支援修改密碼、執行個體名稱、主機名稱、所屬安全性群組、執行個體的 MTU 以及使用者自訂資料等。

介面說明

被安全鎖定的執行個體不支援呼叫該介面。更多資訊,請參見資源安全鎖定對呼叫 API 的影響

調試

您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。

調試

授權資訊

下表是API對應的授權資訊,可以在RAM權限原則語句的Action元素中使用,用來給RAM使用者或RAM角色授予調用此API的許可權。具體說明如下:

  • 操作:是指具體的許可權點。

  • 存取層級:是指每個操作的存取層級,取值為寫入(Write)、讀取(Read)或列出(List)。

  • 資源類型:是指操作中支援授權的資源類型。具體說明如下:

    • 對於必選的資源類型,用前面加 * 表示。

    • 對於不支援資源級授權的操作,用全部資源表示。

  • 條件關鍵字:是指雲產品自身定義的條件關鍵字。

  • 關聯操作:是指成功執行操作所需要的其他許可權。操作者必須同時具備關聯操作的許可權,操作才能成功。

操作

存取層級

資源類型

條件關鍵字

關聯操作

ecs:ModifyInstanceAttribute

update

*Instance

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

SecurityGroup

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

  • ecs:tag
  • ecs:PasswordCustomized

請求參數

名稱

類型

必填

描述

樣本值

InstanceId

string

執行個體 ID。

i-bp67acfmxazb4ph****

Password

string

執行個體的密碼。支援長度為 8~30 個字元,必須同時包含大小寫英文字母、數字和特殊符號中的三類字元。特殊符號可以是:()`~!@#$%^&*-_+=|{}[]:;'<>,.?/ 。Windows 執行個體不能以斜線號(/)為密碼首字元。使用該參數時請注意:

  • 執行個體不能處於啟動中(Starting)狀態。

  • 重新啟動執行個體後生效。您可以在 ECS 控制台重新啟動(具體操作,請參見重新啟動執行個體)或者呼叫 RebootInstance 重新啟動,在作業系統內部重新啟動不能生效。

說明

如果傳入 Password 參數,建議您使用 HTTPS 協定傳送請求,避免密碼洩露。

Test123456&$

HostName

string

作業系統的主機名稱。使用該參數時請注意:

  • 執行個體不能處於建立中(Pending)或啟動中(Starting)的狀態,否則可能出現主機名稱以及 /etc/hosts 設定失效等情況。您可以呼叫 DescribeInstances 查詢執行個體目前的狀態資訊。

  • 重新啟動執行個體後生效。您可以在 ECS 控制台重新啟動(具體操作,請參見重新啟動執行個體)或者呼叫 RebootInstance 重新啟動,在作業系統內部重新啟動不能生效。

不同作業系統主機名稱存在以下限制:

  • Windows Server 系統:長度為 2-15 個字元,允許使用大小寫字母、數字或短劃線(-)。不能以短劃線(-)開頭或結尾,不能連續使用短劃線(-),也不能僅使用數字。

  • 其他類型執行個體(Linux 等):長度為 2-64 個字元,允許使用半形句號(.)分隔字元成多段,每段允許使用大小寫字母、數字或連字號(-),但不能連續使用半形句號(.)或短劃線(-)。不能以半形句號(.)或短劃線(-)開頭或結尾。

testHostName

InstanceName

string

執行個體名稱。長度為 2~128 個英文或中文字元。必須以大小寫字母或中文開頭,不能以 http://https:// 開頭。可以包含數字、半形冒號(:)、底線(_)或者短劃線(-)。

testInstanceName

Description

string

執行個體描述。長度為 2~256 個英文或中文字元,不能以 http://https:// 開頭。

testInstanceDescription

UserData

string

執行個體自訂資料,建議 Base64 編碼後傳入。使用該參數時請注意:

  • 執行個體必須滿足自訂資料使用限制。更多資訊,請參見產生執行個體自訂資料

  • 重新啟動執行個體後,執行個體上將展示新的自訂資料,但不會運行資料。

說明

編碼前,原始資料不能超過 32 KB。建議不要明文傳入敏感資訊,例如密碼和私密金鑰等。如果必須傳入敏感資訊,建議您加密後再以 Base64 編碼傳入,在執行個體內部以同樣的方式解密。

ZWNobyBoZWxsbyBlY3Mh

Recyclable

boolean

說明

該參數正在邀測中,暫不開放使用。

true

CreditSpecification

string

修改突發效能執行個體的運行模式。取值範圍:

  • Standard:標準模式。

  • Unlimited:無效能約束模式。

關於突發效能執行個體運行模式的更多資訊,請參見什麼是突發效能執行個體

Standard

DeletionProtection

boolean

執行個體釋放保護屬性。指定是否支援透過控制台或 API( DeleteInstance )釋放執行個體。

說明

該屬性僅適用於隨用隨付執行個體,且只能限制手動釋放操作,對系統釋放操作不生效。

false

NetworkInterfaceQueueNumber

integer

主網路卡佇列數。使用該參數時請注意:

  • 執行個體必須為已停止(Stopped)狀態。

  • 不能超過執行個體規格允許的單塊網路卡最大佇列數,執行個體的所有網路卡累加佇列數不能超過執行個體規格允許的佇列數總配額。執行個體規格的單塊網路卡最大佇列數和總配額可以透過 DescribeInstanceTypes 查詢。

  • 當取值為 -1 時,將重設主網路卡佇列數為對應執行個體規格的預設值。執行個體規格的彈性網路卡預設佇列數可以透過 DescribeInstanceTypes 查詢。

8

SecurityGroupIds

array

執行個體重新加入的安全性群組 ID 陣列。使用該參數時請注意:

  • 陣列內的安全性群組 ID 不能重複,陣列長度與執行個體能夠加入安全性群組配額有關。更多資訊,請參見使用限制

  • 執行個體會離開目前的安全性群組,如需保留設定,您需要在陣列中添加目前的安全性群組 ID。

  • 支援切換安全性群組類型,但設定的安全性群組列表中不能同時包含普通安全性群組和企業安全性群組。

  • 安全性群組必須和執行個體屬於同一個 VPC。

說明

修改安全性群組後很快會生效於對應的執行個體,但可能有較小的延遲。

sg-bp15ed6xe1yxeycg7o****

string

安全性群組 ID。

sg-bp15ed6xe1yxeycg7o****

RemoteConnectionOptions

object

說明

該參數正在邀測中,暫不開放使用。

Password

string

說明

該參數正在邀測中,暫不開放使用。

hide

Type

string

說明

該參數正在邀測中,暫不開放使用。

hide

EnableJumboFrame

boolean

執行個體 MTU 是否開啟 Jumbo frame 通訊模式,取值範圍:

  • true:開啟。

  • false:不開啟。

使用該參數時請注意:

  • 執行個體必須處於運行中(Running)或者已停止(Stopped)狀態。

  • 執行個體必須為虛擬專有網路(Virtual Private Cloud, VPC)下的 ECS 執行個體。

  • 開啟 Jumbo Frame 特性後,執行個體的 MTU 值將變為 8500,關閉後則回退為 1500。 目前僅部分規格支援開啟 Jumbo frame。更多資訊,請參見 ECS 執行個體 MTU

false

CpuOptions.Core

integer

CPU 核心數。該參數不支援自訂設定,只能採用預設值。

2

CpuOptions.ThreadsPerCore

integer

CPU 執行緒數。ECS 執行個體的 vCPU 數=CpuOptions.Core 取值*CpuOptions.ThreadsPerCore 取值。

  • CpuOptions.ThreadsPerCore=1 表示關閉 CPU 超執行緒。

  • 僅部分執行個體規格支援設定 CPU 執行緒數。

2

CpuOptions.TopologyType

string

執行個體的 CPU 拓撲類型。取值範圍:

  • ContinuousCoreToHTMapping:執行個體的 CPU 拓撲中,執行個體的同一個 Core 的 HT 是連續的。

  • DiscreteCoreToHTMapping:執行個體的同一個 Core 的 HT 是離散的。

預設值:無。

使用該參數時請注意:

  • 執行個體必須為已停止(Stopped)狀態。

說明

僅部分執行個體規格族支援使用本參數,具體支援執行個體規格族請參見查看和修改 CPU 拓撲結構

DiscreteCoreToHTMapping

PrivateDnsNameOptions

object

執行個體的私網網域名稱設定資訊集合。

關於私網網域名稱解析,請參見 ECS 私網網域名稱解析

EnableInstanceIdDnsARecord

boolean

開啟/關閉執行個體 ID 類型的網域名稱到 IPv4 的解析。可能值:

  • true:開啟。

  • false:關閉。

預設值:false。

false

EnableInstanceIdDnsAAAARecord

boolean

開啟/關閉執行個體 ID 類型的網域名稱到 IPv6 的解析。可能值:

  • true:開啟。

  • false:關閉。

預設值:false。

false

EnableIpDnsARecord

boolean

開啟/關閉 IP 類型的網域名稱到 IPv4 的解析。可能值:

  • true:開啟。

  • false:關閉。

預設值:false。

false

EnableIpDnsPtrRecord

boolean

開啟/關閉 IPv4 到 IP 類型的網域名稱解析。可能值:

  • true:開啟。

  • false:關閉。

預設值:false。

false

HostnameType

string

主機名稱類型,可能值:

  • Custom:自訂。

  • IpBased:基於 IP 格式的主機。

  • InstanceIdBased:基於執行個體 ID 格式的主機名稱。

預設值:Custom。

Custom

CpuOptions

object

NestedVirtualization

string

說明

該參數正在邀測中,暫未開放使用。

enabled

EnableNetworkEncryption

boolean

開啟/關閉 VPC 網路流量加密,可能值:

  • true:開啟。

  • false:關閉。

說明

該參數正在邀測中,暫未開放使用。

true

返回參數

名稱

類型

描述

樣本值

object

RequestId

string

請求 ID。

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

樣本

正常返回樣本

JSON格式

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

錯誤碼

HTTP status code

錯誤碼

錯誤資訊

描述

400 InvalidInstanceName.Malformed The specified parameter "InstanceName" is not valid.
400 InvalidDescription.Malformed The specified parameter "Description" is not valid.
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.
400 InvalidParameter.CreditSpecification The specified CreditSpecification is not supported in this region.
400 InvalidInstanceStatus.CreditSpecRestricted The current status of the resource does not support this operation.
400 InvalidInstanceStatus.NotRunning The current status of the resource is invalid, you can only do this operation when instance is running.
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
400 InvalidParameter The specified parameter is not valid.
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.
400 InvalidParameter.CpuOptionsTopologyType The specified parameter CpuOptions.TopologyType: %s is not valid.
400 InvalidInstanceType.NotSupportCpuOptionsTopologyType The specified instance type does not support CpuOptions.TopologyType: %s.
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.
400 InvalidStatus.StoppedRequired The current state of the resource does not support this operation, it can only be operated in a stopped state.
400 InvalidParameter.CpuOptionsTurboMode The specified parameter TurboMode is not valid.
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".
400 InvalidInstanceType.GpuOptionsConfidentialComputingUnsupported The specified instance type does not support the confidential computing mode.
400 InvalidParameter.GpuOptionsConfidentialComputing The specified parameter confidential computing mode is not valid.
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.
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.
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
403 InvalidChargeType.ValueNotSupported Deletion protection is only valid for postPaid instance, not for prePaid or spot instance.
403 InvalidUser.Unauthorized The user is not authorized
403 EnterpriseGroupLimited.MutliGroupType The specified instance can not join multi SecurityGroup types.
403 SecurityGroupInstanceLimitExceed %s
403 InstanceNotInSecurityGroup The instance not in the group.
403 InvalidOperation.InvalidRegion %s
403 InvalidOperation.ResourceManagedByCloudProduct %s
403 InvalidParameter.InvalidEniQueueNumber %s
403 InvalidOperation.MaxEniQueueNumberExceeded %s
403 InvalidOperation.ExceedInstanceTypeQueueNumber %s
403 InvalidOperation.InstanceTypeNotSupportHighPerformanceTrafficMode %s
403 InvalidParameter.InvalidQueuePairNumber %s
403 InvalidOperation.MaxEniQueuePairNumberExceed %s
403 InvalidOperation.EniQueuePairNumberOverflow %s
403 AclLimitExceed %s
403 InvalidInstanceType.CpuOptionsThreadsPerCoreUnsupported 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.
403 InvalidParameter.CpuOptionsThreadsPerCore The specified parameter CpuOptions.ThreadsPerCore is not valid.
403 InvalidOperation.UserNotSupportNetworkEncryption User not support network encryption.
403 InvalidOperation.InstanceTypeNotSupportNetworkEncryption The specified instance type does not support network encryption.
404 InvalidInstanceId.NotFound The specified InstanceId does not exist.
404 InvalidSecurityGroupId.NotFound The specified SecurityGroupId does not exist.
404 Credit.NotFound The specified 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.
404 InvalidSecurityGroupType.NotSupportClassic The specified SecurityGroupIds have classic group type.
404 InvalidSecurityGroupVpc.NotBelongToOneVpc The specified SecurityGroupIds are belong to different vpc.

訪問錯誤中心查看更多錯誤碼。

變更歷史

更多資訊,參考變更詳情