@@ -108,6 +108,63 @@ import (
108108 "github.com/terraform-providers/terraform-provider-tencentcloud/tencentcloud/ratelimit"
109109)
110110
111+ func TkeInstanceAdvancedSetting () map [string ]* schema.Schema {
112+ return map [string ]* schema.Schema {
113+ "mount_target" : {
114+ Type : schema .TypeString ,
115+ Optional : true ,
116+ ForceNew : true ,
117+ Description : "Mount target. Default is not mounting." ,
118+ },
119+ "docker_graph_path" : {
120+ Type : schema .TypeString ,
121+ Optional : true ,
122+ ForceNew : true ,
123+ Default : "/var/lib/docker" ,
124+ Description : "Docker graph path. Default is `/var/lib/docker`." ,
125+ },
126+ "data_disk" : {
127+ Type : schema .TypeList ,
128+ ForceNew : true ,
129+ Optional : true ,
130+ MaxItems : 11 ,
131+ Description : "Configurations of data disk." ,
132+ Elem : & schema.Resource {
133+ Schema : map [string ]* schema.Schema {
134+ "disk_type" : {
135+ Type : schema .TypeString ,
136+ ForceNew : true ,
137+ Optional : true ,
138+ Default : SYSTEM_DISK_TYPE_CLOUD_PREMIUM ,
139+ ValidateFunc : validateAllowedStringValue (SYSTEM_DISK_ALLOW_TYPE ),
140+ Description : "Types of disk, available values: CLOUD_PREMIUM and CLOUD_SSD." ,
141+ },
142+ "disk_size" : {
143+ Type : schema .TypeInt ,
144+ ForceNew : true ,
145+ Optional : true ,
146+ Default : 0 ,
147+ Description : "Volume of disk in GB. Default is 0." ,
148+ },
149+ },
150+ },
151+ },
152+ "user_data" : {
153+ Type : schema .TypeString ,
154+ ForceNew : true ,
155+ Optional : true ,
156+ Description : "Base64-encoded User Data text, the length limit is 16KB." ,
157+ },
158+ "is_schedule" : {
159+ Type : schema .TypeBool ,
160+ ForceNew : true ,
161+ Optional : true ,
162+ Default : true ,
163+ Description : "Indicate to schedule the adding node or not. Default is true." ,
164+ },
165+ }
166+ }
167+
111168func resourceTencentCloudTkeClusterAttachment () * schema.Resource {
112169 schemaBody := map [string ]* schema.Schema {
113170 "cluster_id" : {
@@ -138,7 +195,16 @@ func resourceTencentCloudTkeClusterAttachment() *schema.Resource {
138195 Elem : & schema.Schema {Type : schema .TypeString },
139196 Description : "The key pair to use for the instance, it looks like skey-16jig7tx, it should be set if `password` not set." ,
140197 },
141-
198+ "worker_config" : {
199+ Type : schema .TypeList ,
200+ ForceNew : true ,
201+ MaxItems : 1 ,
202+ Optional : true ,
203+ Elem : & schema.Resource {
204+ Schema : TkeInstanceAdvancedSetting (),
205+ },
206+ Description : "Deploy the machine configuration information of the 'WORKER', commonly used to attach existing instances." ,
207+ },
142208 //compute
143209 "security_groups" : {
144210 Type : schema .TypeSet ,
@@ -162,6 +228,43 @@ func resourceTencentCloudTkeClusterAttachment() *schema.Resource {
162228 }
163229}
164230
231+ func tkeGetInstanceAdvancedPara (dMap map [string ]interface {}, meta interface {}) (setting tke.InstanceAdvancedSettings ) {
232+ setting = tke.InstanceAdvancedSettings {}
233+ if v , ok := dMap ["mount_target" ]; ok {
234+ setting .MountTarget = helper .String (v .(string ))
235+ }
236+
237+ if v , ok := dMap ["data_disk" ]; ok {
238+
239+ dataDisks := v .([]interface {})
240+ setting .DataDisks = make ([]* tke.DataDisk , 0 , len (dataDisks ))
241+
242+ for _ , d := range dataDisks {
243+ var (
244+ value = d .(map [string ]interface {})
245+ diskType = value ["disk_type" ].(string )
246+ diskSize = int64 (value ["disk_size" ].(int ))
247+ dataDisk = tke.DataDisk {
248+ DiskType : & diskType ,
249+ DiskSize : & diskSize ,
250+ }
251+ )
252+ setting .DataDisks = append (setting .DataDisks , & dataDisk )
253+ }
254+ }
255+
256+ setting .Unschedulable = helper .BoolToInt64Ptr (! dMap ["is_schedule" ].(bool ))
257+
258+ if v , ok := dMap ["user_data" ]; ok {
259+ setting .UserScript = helper .String (v .(string ))
260+ }
261+
262+ if v , ok := dMap ["docker_graph_path" ]; ok {
263+ setting .DockerGraphPath = helper .String (v .(string ))
264+ }
265+
266+ return setting
267+ }
165268func resourceTencentCloudTkeClusterAttachmentRead (d * schema.ResourceData , meta interface {}) error {
166269 defer logElapsed ("resource.tencentcloud_kubernetes_cluster_attachment.read" )()
167270 defer inconsistentCheck (d , meta )()
@@ -282,6 +385,14 @@ func resourceTencentCloudTkeClusterAttachmentCreate(d *schema.ResourceData, meta
282385 }
283386
284387 request .InstanceAdvancedSettings = & tke.InstanceAdvancedSettings {}
388+ if workConfig , ok := d .GetOk ("worker_config" ); ok {
389+ workConfigList := workConfig .([]interface {})
390+ if len (workConfigList ) == 1 {
391+ workConfigPara := workConfigList [0 ].(map [string ]interface {})
392+ setting := tkeGetInstanceAdvancedPara (workConfigPara , meta )
393+ request .InstanceAdvancedSettings = & setting
394+ }
395+ }
285396
286397 request .InstanceAdvancedSettings .Labels = GetTkeLabels (d , "labels" )
287398
0 commit comments