diff --git a/common/common_volcengine_version.go b/common/common_volcengine_version.go index dd1521d3..7d8d8730 100644 --- a/common/common_volcengine_version.go +++ b/common/common_volcengine_version.go @@ -2,5 +2,5 @@ package common const ( TerraformProviderName = "terraform-provider-volcengine" - TerraformProviderVersion = "0.0.20" + TerraformProviderVersion = "0.0.21" ) diff --git a/example/esCloudInstance/main.tf b/example/esCloudInstance/main.tf index c15cd90f..36200008 100644 --- a/example/esCloudInstance/main.tf +++ b/example/esCloudInstance/main.tf @@ -2,15 +2,13 @@ resource "volcengine_escloud_instance" "foo" { instance_configuration { version = "V7_10" - region_id = "cn-xxx" - zone_id = "cn-xxx" zone_number = 1 enable_https = true admin_user_name = "admin" - admin_password = "xxxxxx" + admin_password = "xxxx" charge_type = "PostPaid" configuration_code = "es.standard" - enable_pure_master = false + enable_pure_master = true instance_name = "from-tf4" node_specs_assigns { type = "Master" @@ -21,8 +19,8 @@ resource "volcengine_escloud_instance" "foo" { } node_specs_assigns { type = "Hot" - number = 0 - resource_spec_name = "es.x4.medium" + number = 2 + resource_spec_name = "es.x4.large" storage_spec_name = "es.volume.essd.pl0" storage_size = 100 } diff --git a/volcengine/clb/certificate/resource_volcengine_certificate.go b/volcengine/clb/certificate/resource_volcengine_certificate.go index 3bb4a6eb..3d88a141 100644 --- a/volcengine/clb/certificate/resource_volcengine_certificate.go +++ b/volcengine/clb/certificate/resource_volcengine_certificate.go @@ -36,13 +36,13 @@ func ResourceVolcengineCertificate() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - Description: "The public key of the Certificate.", + Description: "The public key of the Certificate. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields.", }, "private_key": { Type: schema.TypeString, Required: true, ForceNew: true, - Description: "The private key of the Certificate.", + Description: "The private key of the Certificate. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields.", }, "description": { Type: schema.TypeString, diff --git a/common/common_volcengine_diff_suppress_func.go b/volcengine/ecs/ecs_instance/common_volcengine_ecs_instance.go similarity index 78% rename from common/common_volcengine_diff_suppress_func.go rename to volcengine/ecs/ecs_instance/common_volcengine_ecs_instance.go index ed949d1b..9ba90736 100644 --- a/common/common_volcengine_diff_suppress_func.go +++ b/volcengine/ecs/ecs_instance/common_volcengine_ecs_instance.go @@ -1,4 +1,4 @@ -package common +package ecs_instance import ( "encoding/base64" @@ -10,18 +10,18 @@ func EcsInstanceImportDiffSuppress(k, old, new string, d *schema.ResourceData) b if k == "force_restart" { return true } - //由于一些字段暂时无法支持从查询中返回 所以现在设立做特殊处理拦截变更 用来适配导入的场景 后续支持后在对导入场景做优化 - if d.Id() != "" { - if k == "security_enhancement_strategy" { - return true - } - if k == "auto_renew" { - return true - } - if k == "auto_renew_period" { - return true - } - } + //由于一些字段暂时无法支持从查询中返回 所以现在设立做特殊处理拦截变更 用来适配导入的场景 后续支持后在对导入场景做优化 此模式会导致不一致问题 去除 + //if d.Id() != "" { + // if k == "security_enhancement_strategy" { + // return true + // } + // if k == "auto_renew" { + // return true + // } + // if k == "auto_renew_period" { + // return true + // } + //} if d.Id() == "" { if k == "include_data_volumes" { diff --git a/volcengine/ecs/ecs_instance/resource_volcengine_ecs_instance.go b/volcengine/ecs/ecs_instance/resource_volcengine_ecs_instance.go index 8810ec33..65197f44 100644 --- a/volcengine/ecs/ecs_instance/resource_volcengine_ecs_instance.go +++ b/volcengine/ecs/ecs_instance/resource_volcengine_ecs_instance.go @@ -94,7 +94,7 @@ func ResourceVolcengineEcsInstance() *schema.Resource { Type: schema.TypeString, Optional: true, Computed: true, - DiffSuppressFunc: ve.UserDateImportDiffSuppress, + DiffSuppressFunc: UserDateImportDiffSuppress, Description: "The user data of ECS instance.", }, "security_enhancement_strategy": { @@ -105,9 +105,8 @@ func ResourceVolcengineEcsInstance() *schema.Resource { "Active", "InActive", }, false), - Default: "Active", - DiffSuppressFunc: ve.EcsInstanceImportDiffSuppress, - Description: "The security enhancement strategy of ECS instance. The value can be Active or InActive. Default is Active.", + Default: "Active", + Description: "The security enhancement strategy of ECS instance. The value can be Active or InActive. Default is Active.When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields.", }, "hpc_cluster_id": { Type: schema.TypeString, @@ -119,7 +118,7 @@ func ResourceVolcengineEcsInstance() *schema.Resource { Type: schema.TypeInt, Optional: true, Default: 12, - DiffSuppressFunc: ve.EcsInstanceImportDiffSuppress, + DiffSuppressFunc: EcsInstanceImportDiffSuppress, Description: "The period of ECS instance.Only effective when instance_charge_type is PrePaid. Default is 12. Unit is Month.", }, //"period_unit": { @@ -137,23 +136,23 @@ func ResourceVolcengineEcsInstance() *schema.Resource { Optional: true, ForceNew: true, Default: true, - DiffSuppressFunc: ve.EcsInstanceImportDiffSuppress, - Description: "The auto renew flag of ECS instance.Only effective when instance_charge_type is PrePaid. Default is true.", + DiffSuppressFunc: EcsInstanceImportDiffSuppress, + Description: "The auto renew flag of ECS instance.Only effective when instance_charge_type is PrePaid. Default is true.When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields.", }, "auto_renew_period": { Type: schema.TypeInt, Optional: true, ForceNew: true, Default: 1, - DiffSuppressFunc: ve.EcsInstanceImportDiffSuppress, - Description: "The auto renew period of ECS instance.Only effective when instance_charge_type is PrePaid. Default is 1.", + DiffSuppressFunc: EcsInstanceImportDiffSuppress, + Description: "The auto renew period of ECS instance.Only effective when instance_charge_type is PrePaid. Default is 1.When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields.", }, "include_data_volumes": { Type: schema.TypeBool, Optional: true, Default: false, - DiffSuppressFunc: ve.EcsInstanceImportDiffSuppress, + DiffSuppressFunc: EcsInstanceImportDiffSuppress, Description: "The include data volumes flag of ECS instance.Only effective when change instance charge type.include_data_volumes.", }, diff --git a/volcengine/ecs/ecs_key_pair/resource_volcengine_ecs_key_pair.go b/volcengine/ecs/ecs_key_pair/resource_volcengine_ecs_key_pair.go index 0cee8517..84178aa4 100644 --- a/volcengine/ecs/ecs_key_pair/resource_volcengine_ecs_key_pair.go +++ b/volcengine/ecs/ecs_key_pair/resource_volcengine_ecs_key_pair.go @@ -56,10 +56,12 @@ func ResourceVolcengineEcsKeyPair() *schema.Resource { Description: "The description of key pair.", }, "key_file": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: "Target file to save info.", + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: "Target file to save private key. It is recommended that the value not be empty. " + + "You only have one chance to download the private key, the volcengine will not save your private key, please keep it safe. " + + "In the TF import scenario, this field will not write the private key locally.", }, "finger_print": { Type: schema.TypeString, diff --git a/volcengine/escloud/instance/data_source_volcengine_escloud_instances.go b/volcengine/escloud/instance/data_source_volcengine_escloud_instances.go index 0cf60680..c3513653 100644 --- a/volcengine/escloud/instance/data_source_volcengine_escloud_instances.go +++ b/volcengine/escloud/instance/data_source_volcengine_escloud_instances.go @@ -187,10 +187,10 @@ func DataSourceVolcengineESCloudInstances() *schema.Resource { Computed: true, Description: "The kibana private domain of instance.", }, - "kibana_public_endpoint": { + "kibana_public_domain": { Type: schema.TypeString, Computed: true, - Description: "The kibana public endpoint of instance.", + Description: "The kibana public domain of instance.", }, "instance_configuration": { Type: schema.TypeList, diff --git a/volcengine/escloud/instance/resource_volcengine_escloud_instance.go b/volcengine/escloud/instance/resource_volcengine_escloud_instance.go index 7246e4be..4f9e9c0f 100644 --- a/volcengine/escloud/instance/resource_volcengine_escloud_instance.go +++ b/volcengine/escloud/instance/resource_volcengine_escloud_instance.go @@ -37,21 +37,28 @@ func ResourceVolcengineESCloudInstance() *schema.Resource { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "version": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: "The version of ESCloud instance, the value is V6_7 or V7_10.", + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{"V6_7", "V7_10"}, false), + Description: "The version of ESCloud instance, the value is V6_7 or V7_10.", }, "region_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, + Type: schema.TypeString, + Optional: true, + Computed: true, + DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { + return d.Id() != "" + }, Description: "The region ID of ESCloud instance.", }, "zone_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, + Type: schema.TypeString, + Optional: true, + Computed: true, + DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { + return d.Id() != "" + }, Description: "The available zone ID of ESCloud instance.", }, "zone_number": { @@ -67,10 +74,11 @@ func ResourceVolcengineESCloudInstance() *schema.Resource { Description: "Whether Https access is enabled.", }, "admin_user_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: "The name of administrator account(should be admin).", + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{"admin"}, false), + Description: "The name of administrator account(should be admin).", }, "admin_password": { Type: schema.TypeString, @@ -91,7 +99,6 @@ func ResourceVolcengineESCloudInstance() *schema.Resource { "configuration_code": { Type: schema.TypeString, Required: true, - ForceNew: true, Description: "Configuration code used for billing.", }, "enable_pure_master": { @@ -103,38 +110,33 @@ func ResourceVolcengineESCloudInstance() *schema.Resource { "node_specs_assigns": { Type: schema.TypeList, Required: true, - ForceNew: true, Description: "The number and configuration of various ESCloud instance node.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "type": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: "The type of node, the value is `Master` or `Hot` or `Kibana`.", + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{"Master", "Hot", "Kibana"}, false), + Description: "The type of node, the value is `Master` or `Hot` or `Kibana`.", }, "number": { Type: schema.TypeInt, Required: true, - ForceNew: true, Description: "The number of node.", }, "resource_spec_name": { Type: schema.TypeString, Required: true, - ForceNew: true, Description: "The name of compute resource spec, the value is `kibana.x2.small` or `es.x4.medium` or `es.x4.large` or `es.x4.xlarge` or `es.x2.2xlarge` or `es.x4.2xlarge` or `es.x2.3xlarge`.", }, "storage_spec_name": { Type: schema.TypeString, Required: true, - ForceNew: true, Description: "The name of storage spec.", }, "storage_size": { Type: schema.TypeInt, Required: true, - ForceNew: true, Description: "The size of storage.", }, }, @@ -179,6 +181,15 @@ func ResourceVolcengineESCloudInstance() *schema.Resource { Type: schema.TypeString, }, }, + "force_restart_after_scale": { + Type: schema.TypeBool, + Optional: true, + Default: false, + DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { + return d.Id() == "" + }, + Description: "Whether to force restart when changes are made. If true, it means that the cluster will be forced to restart without paying attention to instance availability.", + }, }, }, }, diff --git a/volcengine/escloud/instance/service_volcengine_escloud_instance.go b/volcengine/escloud/instance/service_volcengine_escloud_instance.go index ea4f02c4..135035c3 100644 --- a/volcengine/escloud/instance/service_volcengine_escloud_instance.go +++ b/volcengine/escloud/instance/service_volcengine_escloud_instance.go @@ -4,6 +4,9 @@ import ( "encoding/json" "errors" "fmt" + "github.com/google/uuid" + "strconv" + "strings" "time" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" @@ -160,6 +163,10 @@ func (s *VolcengineESCloudInstanceService) ReadResource(resourceData *schema.Res if assigns != nil && len(assigns.([]interface{})) > 0 { data["InstanceConfiguration"].(map[string]interface{})["NodeSpecsAssigns"] = resourceData.Get("instance_configuration.0.node_specs_assigns") } + if subnet, ok := data["InstanceConfiguration"].(map[string]interface{})["Subnet"]; ok { + data["InstanceConfiguration"].(map[string]interface{})["SubnetId"] = subnet.(map[string]interface{})["SubnetId"] + } + return data, err } @@ -220,6 +227,78 @@ func (s *VolcengineESCloudInstanceService) WithResourceResponseHandlers(instance return []ve.ResourceResponseHandler{handler} } +func preCheckNodeSpec(call ve.SdkCall) error { + // check node number + var enablePureMaster bool + if enablePureMasterValue, ok := (*call.SdkParam)["InstanceConfiguration.EnablePureMaster"]; ok { + enablePureMaster = enablePureMasterValue.(bool) + } else { + enablePureMaster = false + } + + /** + 打平拆分 + InstanceConfiguration.NodeSpecsAssigns.1.StorageSpecName:es.volume.essd.pl0 + InstanceConfiguration.NodeSpecsAssigns.1.Type:Master + */ + nodeConfigs := map[string]map[string]interface{}{} + for key, value := range *call.SdkParam { + if (strings.Contains(key, "InstanceConfiguration.NodeSpecsAssigns")) && (value == "Master" || value == "Hot" || value == "Kibana") { + if _, exist := nodeConfigs[value.(string)]; exist { + return fmt.Errorf("repeated node configs: %s", value) + } + slices := strings.Split(key, ".") + prefix := strings.TrimSuffix(key, slices[len(slices)-1]) + + var number int + if v, ok := (*call.SdkParam)[prefix+"Number"]; ok { + number = v.(int) + } + nodeConfigs[value.(string)] = map[string]interface{}{ + "StorageSpecName": (*call.SdkParam)[prefix+"StorageSpecName"], + "StorageSize": (*call.SdkParam)[prefix+"StorageSize"], + "ResourceSpecName": (*call.SdkParam)[prefix+"ResourceSpecName"], + "Number": number, + } + } + } + if len(nodeConfigs) != 3 { + return fmt.Errorf(" Master, Hot or Kibana NodeSpecsAssigns should be configured.") + } + + if enablePureMaster { + // MasterNodeNumber指定的为专属主节点个数,并且取值固定为3。 + // HotNodeNumber指定独立数据节点个数,取值为1-50。此时MasterNode和HotNode计算存储配置可以不一致。 + if nodeConfigs["Master"]["Number"] != 3 { + return fmt.Errorf(" Master node number muster be 3 if enable_pure_master is true.") + } + if nodeConfigs["Hot"]["Number"].(int) < 1 || nodeConfigs["Hot"]["Number"].(int) > 50 { + return fmt.Errorf(" Hot node number muster range in 1-50 if enable_pure_master is true.") + } + } else { + // MasterNodeNumber=1,HotNodeNumber必需为0,此时代表创建一个单节点的ES实例。 + // MasterNodeNumber=3,HotNodeNumber可选值为0-47,此时MasterNode和HotNode计算存储配置必须一致。 + if nodeConfigs["Master"]["Number"] == 1 { + if nodeConfigs["Hot"]["Number"] != 0 { + return fmt.Errorf(" Hot node number muster 0 if enable_pure_master is false and master node number is 1.") + } + } else if nodeConfigs["Master"]["Number"] == 3 { + if nodeConfigs["Hot"]["Number"].(int) < 0 || nodeConfigs["Hot"]["Number"].(int) > 47 { + return fmt.Errorf(" Hot node number muster range in 0-47 if enable_pure_master is false and master node number is 3.") + } + + if nodeConfigs["Master"]["ResourceSpecName"] != nodeConfigs["Hot"]["ResourceSpecName"] || + nodeConfigs["Master"]["StorageSpecName"] != nodeConfigs["Hot"]["StorageSpecName"] || + nodeConfigs["Master"]["StorageSize"] != nodeConfigs["Hot"]["StorageSize"] { + return fmt.Errorf(" Hot and Master node spec shoud be same if enable_pure_master is false and master node number is 3.") + } + } else { + return fmt.Errorf(" Master node number muster be 1 or 3 if enable_pure_master is false.") + } + } + return nil +} + func (s *VolcengineESCloudInstanceService) CreateResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { callback := ve.Callback{ Call: ve.SdkCall{ @@ -259,6 +338,10 @@ func (s *VolcengineESCloudInstanceService) CreateResource(resourceData *schema.R vpcs []interface{} ok bool ) + // check specs + if err := preCheckNodeSpec(call); err != nil { + return false, err + } // check region regionId := *(s.Client.ClbClient.Config.Region) @@ -305,7 +388,7 @@ func (s *VolcengineESCloudInstanceService) CreateResource(resourceData *schema.R // describe vpc req = map[string]interface{}{ - "Vpcs.1": vpcId, + "VpcIds.1": vpcId, } action = "DescribeVpcs" resp, err = s.Client.VpcClient.DescribeVpcsCommon(&req) @@ -448,6 +531,79 @@ func (s *VolcengineESCloudInstanceService) ModifyResource(resourceData *schema.R callbacks = append(callbacks, resetAdminPasswdCallback) } + if resourceData.HasChange("instance_configuration.0.node_specs_assigns") { + logger.DebugInfo("NodeSpecsAssigns:%v", resourceData.Get("instance_configuration.0.node_specs_assigns")) + scaleCallback := ve.Callback{ + Call: ve.SdkCall{ + Action: "ScaleInstance", + ContentType: ve.ContentTypeJson, + ConvertMode: ve.RequestConvertInConvert, + Convert: map[string]ve.RequestConvert{ + "instance_configuration": { + ConvertType: ve.ConvertJsonObject, + NextLevelConvert: map[string]ve.RequestConvert{ + "node_specs_assigns": { + ConvertType: ve.ConvertJsonObjectArray, + }, + }, + }, + }, + BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { + totalNodeNumber := 0 + var nodeSpecsAssigns []map[string]interface{} + nodeSpecs := d.Get("instance_configuration.0.node_specs_assigns").([]interface{}) + for i, node := range nodeSpecs { + if node.(map[string]interface{})["type"].(string) == "Master" { + if d.HasChange("instance_configuration.0.node_specs_assigns." + strconv.Itoa(i) + ".number") { + return false, fmt.Errorf("master node number is can not be modified") + } + } + if node.(map[string]interface{})["type"].(string) == "Master" || node.(map[string]interface{})["type"].(string) == "Hot" { + nodeNumber := d.Get("instance_configuration.0.node_specs_assigns." + strconv.Itoa(i) + ".number") + totalNodeNumber += nodeNumber.(int) + } + nodeSpecsAssigns = append(nodeSpecsAssigns, map[string]interface{}{ + "Type": node.(map[string]interface{})["type"], + "Number": node.(map[string]interface{})["number"], + "ResourceSpecName": node.(map[string]interface{})["resource_spec_name"], + "StorageSpecName": node.(map[string]interface{})["storage_spec_name"], + "StorageSize": node.(map[string]interface{})["storage_size"], + }) + } + if totalNodeNumber == 1 { + return false, fmt.Errorf("single-node cluster does not allow scale") + } + // check node specs + (*call.SdkParam)["InstanceConfiguration.EnablePureMaster"] = d.Get("instance_configuration.0.enable_pure_master") + err := preCheckNodeSpec(call) + if err != nil { + return false, err + } + + uid, err := uuid.NewUUID() + if err != nil { + return false, fmt.Errorf("generate ClientToken failed ") + } + (*call.SdkParam)["ClientToken"] = uid.String() + (*call.SdkParam)["InstanceId"] = d.Id() + (*call.SdkParam)["NodeSpecsAssigns"] = nodeSpecsAssigns + (*call.SdkParam)["ConfigurationCode"] = d.Get("instance_configuration.0.configuration_code") + (*call.SdkParam)["Force"] = false + return true, nil + }, + ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { + logger.Debug(logger.ReqFormat, call.Action, call.SdkParam) + return s.Client.UniversalClient.DoCall(getUniversalInfo(call.Action), call.SdkParam) + }, + Refresh: &ve.StateRefresh{ + Target: []string{"Running"}, + Timeout: resourceData.Timeout(schema.TimeoutCreate), + }, + }, + } + callbacks = append(callbacks, scaleCallback) + } + return callbacks } diff --git a/volcengine/rds/rds_account/resource_volcengine_rds_account.go b/volcengine/rds/rds_account/resource_volcengine_rds_account.go index 68f62646..bf80e868 100644 --- a/volcengine/rds/rds_account/resource_volcengine_rds_account.go +++ b/volcengine/rds/rds_account/resource_volcengine_rds_account.go @@ -42,10 +42,7 @@ func ResourceVolcengineRdsAccount() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - Description: "The password of the database account.\nillustrate\nCannot start with `!` or `@`.\nThe length is 8~32 characters.\nIt consists of any three of uppercase letters, lowercase letters, numbers, and special characters.\nThe special characters are `!@#$%^*()_+-=`.", - DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { - return d.Id() != "" - }, + Description: "The password of the database account.\nillustrate\nCannot start with `!` or `@`.\nThe length is 8~32 characters.\nIt consists of any three of uppercase letters, lowercase letters, numbers, and special characters.\nThe special characters are `!@#$%^*()_+-=`. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields.", }, "account_type": { Type: schema.TypeString, diff --git a/volcengine/rds/rds_instance/common_volcengine_rds_instance.go b/volcengine/rds/rds_instance/common_volcengine_rds_instance.go deleted file mode 100644 index bfd2c63b..00000000 --- a/volcengine/rds/rds_instance/common_volcengine_rds_instance.go +++ /dev/null @@ -1,22 +0,0 @@ -package rds_instance - -import "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - -func RdsInstanceImportDiffSuppress(k, old, new string, d *schema.ResourceData) bool { - if d.Id() != "" { - if k == "auto_renew" { - return true - } - if k == "prepaid_period" { - return true - } - if k == "used_time" { - return true - } - if k == "project_name" { - // project_name is not returned by the API - return true - } - } - return false -} diff --git a/volcengine/rds/rds_instance/resource_volcengine_rds_instance.go b/volcengine/rds/rds_instance/resource_volcengine_rds_instance.go index eba53726..1b02679d 100644 --- a/volcengine/rds/rds_instance/resource_volcengine_rds_instance.go +++ b/volcengine/rds/rds_instance/resource_volcengine_rds_instance.go @@ -120,31 +120,28 @@ func ResourceVolcengineRdsInstance() *schema.Resource { ValidateFunc: validation.StringInSlice([]string{"PostPaid", "Prepaid"}, false), }, "auto_renew": { - Type: schema.TypeBool, - Optional: true, - ForceNew: true, - Description: "Whether to automatically renew. Default: false. Value:\ntrue: yes.\nfalse: no.", - DiffSuppressFunc: RdsInstanceImportDiffSuppress, + Type: schema.TypeBool, + Optional: true, + ForceNew: true, + Description: "Whether to automatically renew. Default: false. Value:\ntrue: yes.\nfalse: no. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields.", }, "prepaid_period": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: "The purchase cycle in the prepaid scenario. Value:\nMonth: monthly subscription.\nYear: yearly subscription.", - DiffSuppressFunc: RdsInstanceImportDiffSuppress, + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: "The purchase cycle in the prepaid scenario. Value:\nMonth: monthly subscription.\nYear: yearly subscription. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields.", }, "used_time": { - Type: schema.TypeInt, - Optional: true, - ForceNew: true, - Description: "The purchase time of RDS instance.", - DiffSuppressFunc: RdsInstanceImportDiffSuppress, + Type: schema.TypeInt, + Optional: true, + ForceNew: true, + Description: "The purchase time of RDS instance. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields.", }, "project_name": { Type: schema.TypeString, Optional: true, ForceNew: true, - Description: "Select the project to which the instance belongs. If this parameter is left blank, the new instance will not be added to any project.", + Description: "Select the project to which the instance belongs. If this parameter is left blank, the new instance will not be added to any project. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields.", }, "subnet_id": { Type: schema.TypeString, diff --git a/volcengine/rds_v2/rds_instance_v2/common_volcengine_rds_instance_v2.go b/volcengine/rds_v2/rds_instance_v2/common_volcengine_rds_instance_v2.go deleted file mode 100644 index 64e50fdf..00000000 --- a/volcengine/rds_v2/rds_instance_v2/common_volcengine_rds_instance_v2.go +++ /dev/null @@ -1,17 +0,0 @@ -package rds_instance_v2 - -import "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - -func RdsInstanceImportDiffSuppress(k, old, new string, d *schema.ResourceData) bool { - if d.Id() != "" { - if k == "db_param_group_id" { - // db_param_group_id is not returned by the API - return true - } - if k == "db_time_zone" { - // db_time_zone is not returned by the API - return true - } - } - return false -} diff --git a/volcengine/rds_v2/rds_instance_v2/resource_volcengine_rds_instance_v2.go b/volcengine/rds_v2/rds_instance_v2/resource_volcengine_rds_instance_v2.go index 2278b7b9..ba54b9b9 100644 --- a/volcengine/rds_v2/rds_instance_v2/resource_volcengine_rds_instance_v2.go +++ b/volcengine/rds_v2/rds_instance_v2/resource_volcengine_rds_instance_v2.go @@ -77,18 +77,16 @@ func ResourceVolcengineRdsInstance() *schema.Resource { Description: "Whether the table name is case sensitive, the default value is 1.\nRanges:\n0: Table names are stored as fixed and table names are case-sensitive.\n1: Table names will be stored in lowercase and table names are not case sensitive.", }, "db_time_zone": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: "Time zone. Support UTC -12:00 ~ +13:00.", - DiffSuppressFunc: RdsInstanceImportDiffSuppress, + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: "Time zone. Support UTC -12:00 ~ +13:00. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields.", }, "db_param_group_id": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: "Parameter template ID. It only takes effect when the database type is MySQL/PostgreSQL/SQL_Server.", - DiffSuppressFunc: RdsInstanceImportDiffSuppress, + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: "Parameter template ID. It only takes effect when the database type is MySQL/PostgreSQL/SQL_Server. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields.", }, "project_name": { Type: schema.TypeString, diff --git a/volcengine/vpc/vpc/service_volcengine_vpc.go b/volcengine/vpc/vpc/service_volcengine_vpc.go index bd18f34e..d203ae52 100644 --- a/volcengine/vpc/vpc/service_volcengine_vpc.go +++ b/volcengine/vpc/vpc/service_volcengine_vpc.go @@ -59,6 +59,7 @@ func (s *VolcengineVpcService) ReadResources(m map[string]interface{}) (data []i if data, ok = results.([]interface{}); !ok { return data, errors.New("Result.Vpcs is not Slice") } + return data, err }) } @@ -86,6 +87,10 @@ func (s *VolcengineVpcService) ReadResource(resourceData *schema.ResourceData, v if len(data) == 0 { return data, fmt.Errorf("Vpc %s not exist ", vpcId) } + + if _, ok1 := data["AuxiliaryCidrBlocks"]; !ok1 { + data["AuxiliaryCidrBlocks"] = []string{} + } return data, err } diff --git a/website/docs/d/escloud_instances.html.markdown b/website/docs/d/escloud_instances.html.markdown index b2deb5d4..e71f2157 100644 --- a/website/docs/d/escloud_instances.html.markdown +++ b/website/docs/d/escloud_instances.html.markdown @@ -106,7 +106,7 @@ In addition to all arguments above, the following attributes are exported: * `zone_number` - The zone number of instance. * `instance_id` - The Id of instance. * `kibana_private_domain` - The kibana private domain of instance. - * `kibana_public_endpoint` - The kibana public endpoint of instance. + * `kibana_public_domain` - The kibana public domain of instance. * `maintenance_day` - The maintenance day of instance. * `maintenance_time` - The maintenance time of instance. * `namespace` - The namespace of instance. diff --git a/website/docs/r/certificate.html.markdown b/website/docs/r/certificate.html.markdown index 77054f60..55276eea 100644 --- a/website/docs/r/certificate.html.markdown +++ b/website/docs/r/certificate.html.markdown @@ -19,8 +19,8 @@ resource "volcengine_certificate" "foo" { ``` ## Argument Reference The following arguments are supported: -* `private_key` - (Required, ForceNew) The private key of the Certificate. -* `public_key` - (Required, ForceNew) The public key of the Certificate. +* `private_key` - (Required, ForceNew) The private key of the Certificate. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields. +* `public_key` - (Required, ForceNew) The public key of the Certificate. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields. * `certificate_name` - (Optional, ForceNew) The name of the Certificate. * `description` - (Optional, ForceNew) The description of the Certificate. diff --git a/website/docs/r/ecs_instance.html.markdown b/website/docs/r/ecs_instance.html.markdown index 2dbd8c21..fc742b32 100644 --- a/website/docs/r/ecs_instance.html.markdown +++ b/website/docs/r/ecs_instance.html.markdown @@ -58,8 +58,8 @@ The following arguments are supported: * `subnet_id` - (Required, ForceNew) The subnet ID of primary networkInterface. * `system_volume_size` - (Required) The size of system volume. * `system_volume_type` - (Required, ForceNew) The type of system volume, the value is `PTSSD` or `ESSD_PL0` or `ESSD_PL1` or `ESSD_PL2` or `ESSD_FlexPL`. -* `auto_renew_period` - (Optional, ForceNew) The auto renew period of ECS instance.Only effective when instance_charge_type is PrePaid. Default is 1. -* `auto_renew` - (Optional, ForceNew) The auto renew flag of ECS instance.Only effective when instance_charge_type is PrePaid. Default is true. +* `auto_renew_period` - (Optional, ForceNew) The auto renew period of ECS instance.Only effective when instance_charge_type is PrePaid. Default is 1.When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields. +* `auto_renew` - (Optional, ForceNew) The auto renew flag of ECS instance.Only effective when instance_charge_type is PrePaid. Default is true.When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields. * `data_volumes` - (Optional) The data volumes collection of ECS instance. * `deployment_set_id` - (Optional) The ID of Ecs Deployment Set. * `description` - (Optional) The description of ECS instance. @@ -72,7 +72,7 @@ The following arguments are supported: * `password` - (Optional) The password of ECS instance. * `period` - (Optional) The period of ECS instance.Only effective when instance_charge_type is PrePaid. Default is 12. Unit is Month. * `secondary_network_interfaces` - (Optional) The secondary networkInterface detail collection of ECS instance. -* `security_enhancement_strategy` - (Optional, ForceNew) The security enhancement strategy of ECS instance. The value can be Active or InActive. Default is Active. +* `security_enhancement_strategy` - (Optional, ForceNew) The security enhancement strategy of ECS instance. The value can be Active or InActive. Default is Active.When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields. * `user_data` - (Optional) The user data of ECS instance. * `zone_id` - (Optional, ForceNew) The available zone ID of ECS instance. diff --git a/website/docs/r/ecs_key_pair.html.markdown b/website/docs/r/ecs_key_pair.html.markdown index 5ee5d93c..9005c275 100644 --- a/website/docs/r/ecs_key_pair.html.markdown +++ b/website/docs/r/ecs_key_pair.html.markdown @@ -19,7 +19,7 @@ resource "volcengine_ecs_key_pair" "default" { The following arguments are supported: * `key_pair_name` - (Required, ForceNew) The name of key pair. * `description` - (Optional) The description of key pair. -* `key_file` - (Optional, ForceNew) Target file to save info. +* `key_file` - (Optional, ForceNew) Target file to save private key. It is recommended that the value not be empty. You only have one chance to download the private key, the volcengine will not save your private key, please keep it safe. In the TF import scenario, this field will not write the private key locally. * `public_key` - (Optional, ForceNew) Public key string. ## Attributes Reference diff --git a/website/docs/r/escloud_instance.html.markdown b/website/docs/r/escloud_instance.html.markdown index 66a41bac..9f2c681f 100644 --- a/website/docs/r/escloud_instance.html.markdown +++ b/website/docs/r/escloud_instance.html.markdown @@ -13,15 +13,13 @@ Provides a resource to manage escloud instance resource "volcengine_escloud_instance" "foo" { instance_configuration { version = "V7_10" - region_id = "cn-xxx" - zone_id = "cn-xxx" zone_number = 1 enable_https = true admin_user_name = "admin" - admin_password = "xxxxxx" + admin_password = "xxxx" charge_type = "PostPaid" configuration_code = "es.standard" - enable_pure_master = false + enable_pure_master = true instance_name = "from-tf4" node_specs_assigns { type = "Master" @@ -32,8 +30,8 @@ resource "volcengine_escloud_instance" "foo" { } node_specs_assigns { type = "Hot" - number = 0 - resource_spec_name = "es.x4.medium" + number = 2 + resource_spec_name = "es.x4.large" storage_spec_name = "es.volume.essd.pl0" storage_size = 100 } @@ -57,13 +55,14 @@ The `instance_configuration` object supports the following: * `admin_password` - (Required) The password of administrator account. * `admin_user_name` - (Required, ForceNew) The name of administrator account(should be admin). * `charge_type` - (Required, ForceNew) The charge type of ESCloud instance, the value can be PostPaid or PrePaid. -* `configuration_code` - (Required, ForceNew) Configuration code used for billing. +* `configuration_code` - (Required) Configuration code used for billing. * `enable_https` - (Required, ForceNew) Whether Https access is enabled. * `enable_pure_master` - (Required, ForceNew) Whether the Master node is independent. -* `node_specs_assigns` - (Required, ForceNew) The number and configuration of various ESCloud instance node. +* `node_specs_assigns` - (Required) The number and configuration of various ESCloud instance node. * `subnet_id` - (Required, ForceNew) The ID of subnet, the subnet must belong to the AZ selected. * `version` - (Required, ForceNew) The version of ESCloud instance, the value is V6_7 or V7_10. * `zone_number` - (Required, ForceNew) The zone count of the ESCloud instance used. +* `force_restart_after_scale` - (Optional) Whether to force restart when changes are made. If true, it means that the cluster will be forced to restart without paying attention to instance availability. * `instance_name` - (Optional) The name of ESCloud instance. * `maintenance_day` - (Optional) The maintainable date for the instance. * `maintenance_time` - (Optional) The maintainable time period for the instance. @@ -73,11 +72,11 @@ The `instance_configuration` object supports the following: The `node_specs_assigns` object supports the following: -* `number` - (Required, ForceNew) The number of node. -* `resource_spec_name` - (Required, ForceNew) The name of compute resource spec, the value is `kibana.x2.small` or `es.x4.medium` or `es.x4.large` or `es.x4.xlarge` or `es.x2.2xlarge` or `es.x4.2xlarge` or `es.x2.3xlarge`. -* `storage_size` - (Required, ForceNew) The size of storage. -* `storage_spec_name` - (Required, ForceNew) The name of storage spec. -* `type` - (Required, ForceNew) The type of node, the value is `Master` or `Hot` or `Kibana`. +* `number` - (Required) The number of node. +* `resource_spec_name` - (Required) The name of compute resource spec, the value is `kibana.x2.small` or `es.x4.medium` or `es.x4.large` or `es.x4.xlarge` or `es.x2.2xlarge` or `es.x4.2xlarge` or `es.x2.3xlarge`. +* `storage_size` - (Required) The size of storage. +* `storage_spec_name` - (Required) The name of storage spec. +* `type` - (Required) The type of node, the value is `Master` or `Hot` or `Kibana`. ## Attributes Reference In addition to all arguments above, the following attributes are exported: diff --git a/website/docs/r/rds_account.html.markdown b/website/docs/r/rds_account.html.markdown index 57f9798e..90d2aaf4 100644 --- a/website/docs/r/rds_account.html.markdown +++ b/website/docs/r/rds_account.html.markdown @@ -30,7 +30,7 @@ illustrate Cannot start with `!` or `@`. The length is 8~32 characters. It consists of any three of uppercase letters, lowercase letters, numbers, and special characters. -The special characters are `!@#$%^*()_+-=`. +The special characters are `!@#$%^*()_+-=`. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields. * `account_type` - (Required, ForceNew) Database account type, value: Super: A high-privilege account. Only one database account can be created for an instance. Normal: An account with ordinary privileges. diff --git a/website/docs/r/rds_instance.html.markdown b/website/docs/r/rds_instance.html.markdown index 6968982e..a1b0533f 100644 --- a/website/docs/r/rds_instance.html.markdown +++ b/website/docs/r/rds_instance.html.markdown @@ -53,7 +53,7 @@ LocalSSD: Local SSD disk. * `zone` - (Required, ForceNew) The available zone of the RDS instance. * `auto_renew` - (Optional, ForceNew) Whether to automatically renew. Default: false. Value: true: yes. -false: no. +false: no. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields. * `db_engine` - (Optional, ForceNew) Database type. Value: MySQL (default). * `instance_name` - (Optional, ForceNew) Set the name of the instance. The naming rules are as follows: @@ -63,8 +63,8 @@ It can only contain Chinese characters, letters, numbers, underscores (_) and un The length needs to be within 1~128 characters. * `prepaid_period` - (Optional, ForceNew) The purchase cycle in the prepaid scenario. Value: Month: monthly subscription. -Year: yearly subscription. -* `project_name` - (Optional, ForceNew) Select the project to which the instance belongs. If this parameter is left blank, the new instance will not be added to any project. +Year: yearly subscription. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields. +* `project_name` - (Optional, ForceNew) Select the project to which the instance belongs. If this parameter is left blank, the new instance will not be added to any project. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields. * `region` - (Optional, ForceNew) The region of the RDS instance. * `super_account_name` - (Optional, ForceNew) Fill in the high-privileged user account name. The naming rules are as follows: Unique name. @@ -72,11 +72,15 @@ Start with a letter and end with a letter or number. Consists of lowercase letters, numbers, or underscores (_). The length is 2~32 characters. [Keywords](https://www.volcengine.com/docs/6313/66162) are not allowed for account names. -* `supper_account_password` - (Optional, ForceNew) Set a high-privilege account password. The rules are as follows: +* `super_account_password` - (Optional, ForceNew) Set a high-privilege account password. The rules are as follows: Only uppercase and lowercase letters, numbers and the following special characters _#!@$%^*()+=-. The length needs to be within 8~32 characters. Contains at least 3 of uppercase letters, lowercase letters, numbers or special characters. -* `used_time` - (Optional, ForceNew) The purchase time of RDS instance. +* `supper_account_password` - (Optional, ForceNew, **Deprecated**) supper_account_password is deprecated, use super_account_password instead Set a high-privilege account password. The rules are as follows: +Only uppercase and lowercase letters, numbers and the following special characters _#!@$%^*()+=-. +The length needs to be within 8~32 characters. +Contains at least 3 of uppercase letters, lowercase letters, numbers or special characters. +* `used_time` - (Optional, ForceNew) The purchase time of RDS instance. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields. ## Attributes Reference In addition to all arguments above, the following attributes are exported: diff --git a/website/docs/r/rds_instance_v2.html.markdown b/website/docs/r/rds_instance_v2.html.markdown index 5ea97c0f..8db4438b 100644 --- a/website/docs/r/rds_instance_v2.html.markdown +++ b/website/docs/r/rds_instance_v2.html.markdown @@ -54,8 +54,8 @@ When the database type is veDB_MySQL/veDB_PostgreSQL, the value is: DistributedStorage - Distributed Storage. * `subnet_id` - (Required, ForceNew) Subnet ID. * `vpc_id` - (Required, ForceNew) Private network (VPC) ID. You can call the DescribeVpcs query and use this parameter to specify the VPC where the instance is to be created. -* `db_param_group_id` - (Optional, ForceNew) Parameter template ID. It only takes effect when the database type is MySQL/PostgreSQL/SQL_Server. -* `db_time_zone` - (Optional, ForceNew) Time zone. Support UTC -12:00 ~ +13:00. +* `db_param_group_id` - (Optional, ForceNew) Parameter template ID. It only takes effect when the database type is MySQL/PostgreSQL/SQL_Server. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields. +* `db_time_zone` - (Optional, ForceNew) Time zone. Support UTC -12:00 ~ +13:00. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields. * `instance_name` - (Optional, ForceNew) Instance name. Cannot start with a number or a dash Can only contain Chinese characters, letters, numbers, underscores and dashes The length is limited between 1 ~ 128. diff --git a/website/docs/r/vke_default_node_pool.html.markdown b/website/docs/r/vke_default_node_pool.html.markdown new file mode 100644 index 00000000..ad41e9da --- /dev/null +++ b/website/docs/r/vke_default_node_pool.html.markdown @@ -0,0 +1,118 @@ +--- +subcategory: "VKE" +layout: "volcengine" +page_title: "Volcengine: volcengine_vke_default_node_pool" +sidebar_current: "docs-volcengine-resource-vke_default_node_pool" +description: |- + Provides a resource to manage vke default node pool +--- +# volcengine_vke_default_node_pool +Provides a resource to manage vke default node pool +## Example Usage +```hcl +resource "volcengine_vke_default_node_pool" "default" { + cluster_id = "ccc2umdnqtoflv91lqtq0" + node_config { + security { + login { + password = "amw4WTdVcTRJVVFsUXpVTw==" + } + security_group_ids = ["sg-2d6t6djr2wge858ozfczv41xq", "sg-3re6v4lz76yv45zsk2hjvvwcj"] + security_strategies = ["Hids"] + } + initialize_script = "ISMvYmluL2Jhc2gKZWNobyAx" + } + kubernetes_config { + labels { + key = "aa" + value = "bb" + } + labels { + key = "cccc" + value = "dddd" + } + taints { + key = "cccc" + value = "dddd" + effect = "NoSchedule" + } + taints { + key = "aa11" + value = "111" + effect = "NoSchedule" + } + cordon = true + } + instances { + instance_id = "i-ybvza90ohwexzk8emaa3" + keep_instance_name = false + additional_container_storage_enabled = false + } + instances { + instance_id = "i-ybvza90ohxexzkm4zihf" + keep_instance_name = false + additional_container_storage_enabled = true + container_storage_path = "/" + } +} +``` +## Argument Reference +The following arguments are supported: +* `cluster_id` - (Required, ForceNew) The ClusterId of NodePool. +* `node_config` - (Required) The Config of NodePool. +* `instances` - (Optional) The ECS InstanceIds add to NodePool. +* `kubernetes_config` - (Optional) The KubernetesConfig of NodeConfig. + +The `instances` object supports the following: + +* `instance_id` - (Required) The instance id. +* `additional_container_storage_enabled` - (Optional) The flag of additional container storage enable, the value is `true` or `false`..Default is `false`. +* `container_storage_path` - (Optional) The container storage path.When additional_container_storage_enabled is `false` will ignore. +* `image_id` - (Optional) The Image Id to the ECS Instance. +* `keep_instance_name` - (Optional) The flag of keep instance name, the value is `true` or `false`.Default is `false`. + +The `kubernetes_config` object supports the following: + +* `cordon` - (Optional) The Cordon of KubernetesConfig. +* `labels` - (Optional) The Labels of KubernetesConfig. +* `taints` - (Optional) The Taints of KubernetesConfig. + +The `labels` object supports the following: + +* `key` - (Optional) The Key of Labels. +* `value` - (Optional) The Value of Labels. + +The `login` object supports the following: + +* `password` - (Optional) The Password of Security. +* `ssh_key_pair_name` - (Optional) The SshKeyPairName of Security. + +The `node_config` object supports the following: + +* `security` - (Required) The Security of NodeConfig. +* `initialize_script` - (Optional) The initializeScript of NodeConfig. + +The `security` object supports the following: + +* `login` - (Required) The Login of Security. +* `security_group_ids` - (Optional) The SecurityGroupIds of Security. +* `security_strategies` - (Optional) The SecurityStrategies of Security. + +The `taints` object supports the following: + +* `effect` - (Optional) The Effect of Taints. +* `key` - (Optional) The Key of Taints. +* `value` - (Optional) The Value of Taints. + +## Attributes Reference +In addition to all arguments above, the following attributes are exported: +* `id` - ID of the resource. +* `is_import` - Is import of the DefaultNodePool. It only works when imported, set to true. + + +## Import +VKE default node can be imported using the node id, e.g. +``` +$ terraform import volcengine_vke_default_node.default nc5t5epmrsf**** +``` +