diff --git a/volcengine/ecs/ecs_instance/resource_volcengine_ecs_instance.go b/volcengine/ecs/ecs_instance/resource_volcengine_ecs_instance.go index 184a8682..2ba5e92d 100644 --- a/volcengine/ecs/ecs_instance/resource_volcengine_ecs_instance.go +++ b/volcengine/ecs/ecs_instance/resource_volcengine_ecs_instance.go @@ -294,9 +294,29 @@ func ResourceVolcengineEcsInstance() *schema.Resource { Schema: map[string]*schema.Schema{ "threads_per_core": { Type: schema.TypeInt, - Required: true, + Optional: true, + Computed: true, + ForceNew: true, + Description: "The per core of threads, only support for ebm. `1` indicates disabling hyper threading function.", + DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { + //暂时增加这个逻辑 在不包含ebm的情况下 忽略掉这个变化 目前这个方式比较hack 后续接口能力完善后改变一下 + if it, ok := d.Get("instance_type").(string); ok { + its := strings.Split(it, ".") + if len(its) == 3 && !strings.Contains(strings.ToLower(its[1]), "ebm") { + return true + } else { + return false + } + } else { + return true + } + }, + }, + "numa_per_socket": { + Type: schema.TypeInt, + Optional: true, ForceNew: true, - Description: "The per core of threads,only support for ebm.", + Description: "The number of subnuma in socket, only support for ebm. `1` indicates disabling SNC/NPS function. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields.", DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { //暂时增加这个逻辑 在不包含ebm的情况下 忽略掉这个变化 目前这个方式比较hack 后续接口能力完善后改变一下 if it, ok := d.Get("instance_type").(string); ok { diff --git a/volcengine/ecs/ecs_instance/service_volcengine_ecs_instance.go b/volcengine/ecs/ecs_instance/service_volcengine_ecs_instance.go index 29fe7b43..72d64476 100644 --- a/volcengine/ecs/ecs_instance/service_volcengine_ecs_instance.go +++ b/volcengine/ecs/ecs_instance/service_volcengine_ecs_instance.go @@ -152,6 +152,17 @@ func (s *VolcengineEcsService) ReadResource(resourceData *schema.ResourceData, i if len(data) == 0 { return data, fmt.Errorf("Ecs Instance %s not exist ", instanceId) } + + if numa := resourceData.Get("cpu_options.0.numa_per_socket"); numa != 0 { + if v, exist := data["CpuOptions"]; exist { + cpuOptions, ok := v.(map[string]interface{}) + if !ok { + return data, fmt.Errorf("CpuOptions is not map ") + } + cpuOptions["NumaPerSocket"] = numa + } + } + return data, nil } @@ -440,6 +451,9 @@ func (s *VolcengineEcsService) CreateResource(resourceData *schema.ResourceData, "threads_per_core": { TargetField: "ThreadsPerCore", }, + "numa_per_socket": { + TargetField: "NumaPerSocket", + }, }, }, "secondary_network_interfaces": { diff --git a/website/docs/r/ecs_instance.html.markdown b/website/docs/r/ecs_instance.html.markdown index 1671a96c..88fc56fe 100644 --- a/website/docs/r/ecs_instance.html.markdown +++ b/website/docs/r/ecs_instance.html.markdown @@ -115,7 +115,8 @@ SpotWithPriceLimit: spot instance with a set upper limit for bidding price. The `cpu_options` object supports the following: -* `threads_per_core` - (Required, ForceNew) The per core of threads,only support for ebm. +* `numa_per_socket` - (Optional, ForceNew) The number of subnuma in socket, only support for ebm. `1` indicates disabling SNC/NPS function. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields. +* `threads_per_core` - (Optional, ForceNew) The per core of threads, only support for ebm. `1` indicates disabling hyper threading function. The `data_volumes` object supports the following: