Skip to content

Commit

Permalink
Merge pull request #23 from volcengine/feat/es
Browse files Browse the repository at this point in the history
Feat/es
  • Loading branch information
xuyaming0800 authored Sep 13, 2022
2 parents 58087d5 + 095614a commit f7be110
Show file tree
Hide file tree
Showing 24 changed files with 405 additions and 160 deletions.
2 changes: 1 addition & 1 deletion common/common_volcengine_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package common

const (
TerraformProviderName = "terraform-provider-volcengine"
TerraformProviderVersion = "0.0.20"
TerraformProviderVersion = "0.0.21"
)
10 changes: 4 additions & 6 deletions example/esCloudInstance/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions volcengine/clb/certificate/resource_volcengine_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package common
package ecs_instance

import (
"encoding/base64"
Expand All @@ -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" {
Expand Down
19 changes: 9 additions & 10 deletions volcengine/ecs/ecs_instance/resource_volcengine_ecs_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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,
Expand All @@ -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": {
Expand All @@ -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.",
},

Expand Down
10 changes: 6 additions & 4 deletions volcengine/ecs/ecs_key_pair/resource_volcengine_ecs_key_pair.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
59 changes: 35 additions & 24 deletions volcengine/escloud/instance/resource_volcengine_escloud_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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,
Expand All @@ -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": {
Expand All @@ -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.",
},
},
Expand Down Expand Up @@ -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.",
},
},
},
},
Expand Down
Loading

0 comments on commit f7be110

Please sign in to comment.