Skip to content

Commit 601cbd2

Browse files
committed
support security group
1 parent c21e638 commit 601cbd2

File tree

4 files changed

+41
-23
lines changed

4 files changed

+41
-23
lines changed

.changelog/2866.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_kubernetes_cluster_attachment: support param `taints` of worker_config
3+
```
4+
5+
```release-note:enhancement
6+
resource/tencentcloud_kubernetes_cluster_attachment: support param `security_groups`
7+
```

tencentcloud/services/tke/resource_tc_kubernetes_cluster_attachment.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,10 @@ func ResourceTencentCloudKubernetesClusterAttachment() *schema.Resource {
425425
},
426426

427427
"security_groups": {
428-
Type: schema.TypeSet,
428+
Type: schema.TypeList,
429429
Computed: true,
430+
Optional: true,
431+
ForceNew: true,
430432
Description: "A list of security group IDs after attach to cluster.",
431433
Elem: &schema.Schema{
432434
Type: schema.TypeString,
@@ -554,6 +556,14 @@ func resourceTencentCloudKubernetesClusterAttachmentCreate(d *schema.ResourceDat
554556
request.HostName = helper.String(v.(string))
555557
}
556558

559+
if v, ok := d.GetOk("security_groups"); ok {
560+
securityGroupIdsSet := v.([]interface{})
561+
for i := range securityGroupIdsSet {
562+
securityGroupIds := securityGroupIdsSet[i].(string)
563+
request.SecurityGroupIds = append(request.SecurityGroupIds, helper.String(securityGroupIds))
564+
}
565+
}
566+
557567
if v, ok := d.GetOk("worker_config_overrides"); ok {
558568
for _, item := range v.([]interface{}) {
559569
instanceAdvancedSettingsOverridesMap := item.(map[string]interface{})

tencentcloud/services/tke/resource_tc_kubernetes_cluster_attachment_extension.go

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func resourceTencentCloudKubernetesClusterAttachmentReadRequestOnError2(ctx cont
170170
}
171171

172172
func resourceTencentCloudKubernetesClusterAttachmentReadRequestOnSuccess2(ctx context.Context, resp *tke.Instance) *resource.RetryError {
173-
d := tccommon.ResourceDataFromContext(ctx)
173+
// d := tccommon.ResourceDataFromContext(ctx)
174174
if resp == nil {
175175
return nil
176176
}
@@ -197,31 +197,32 @@ func resourceTencentCloudKubernetesClusterAttachmentReadRequestOnSuccess2(ctx co
197197
))
198198
}
199199

200-
if resp.InstanceAdvancedSettings.Taints != nil {
201-
iAdvanced := resp.InstanceAdvancedSettings
202-
taintsList := make([]map[string]interface{}, 0, len(iAdvanced.Taints))
203-
if iAdvanced.Taints != nil {
204-
for _, taints := range iAdvanced.Taints {
205-
taintsMap := map[string]interface{}{}
200+
// api cannot return Taints
201+
// if resp.InstanceAdvancedSettings.Taints != nil {
202+
// iAdvanced := resp.InstanceAdvancedSettings
203+
// taintsList := make([]map[string]interface{}, 0, len(iAdvanced.Taints))
204+
// if iAdvanced.Taints != nil {
205+
// for _, taints := range iAdvanced.Taints {
206+
// taintsMap := map[string]interface{}{}
206207

207-
if taints.Key != nil {
208-
taintsMap["key"] = taints.Key
209-
}
208+
// if taints.Key != nil {
209+
// taintsMap["key"] = taints.Key
210+
// }
210211

211-
if taints.Value != nil {
212-
taintsMap["value"] = taints.Value
213-
}
212+
// if taints.Value != nil {
213+
// taintsMap["value"] = taints.Value
214+
// }
214215

215-
if taints.Effect != nil {
216-
taintsMap["effect"] = taints.Effect
217-
}
216+
// if taints.Effect != nil {
217+
// taintsMap["effect"] = taints.Effect
218+
// }
218219

219-
taintsList = append(taintsList, taintsMap)
220-
}
220+
// taintsList = append(taintsList, taintsMap)
221+
// }
221222

222-
_ = d.Set("taints", taintsList)
223-
}
224-
}
223+
// _ = d.Set("taints", taintsList)
224+
// }
225+
// }
225226

226227
return nil
227228
}

website/docs/r/kubernetes_cluster_attachment.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ The following arguments are supported:
117117
* `key_ids` - (Optional, List: [`String`], ForceNew) The key pair to use for the instance, it looks like skey-16jig7tx, it should be set if `password` not set.
118118
* `labels` - (Optional, Map, ForceNew) Labels of tke attachment exits CVM.
119119
* `password` - (Optional, String, ForceNew) Password to access, should be set if `key_ids` not set.
120+
* `security_groups` - (Optional, List: [`String`], ForceNew) A list of security group IDs after attach to cluster.
120121
* `unschedulable` - (Optional, Int, ForceNew) Sets whether the joining node participates in the schedule. Default is `0`, which means it participates in scheduling. Non-zero(eg: `1`) number means it does not participate in scheduling.
121122
* `worker_config_overrides` - (Optional, List, ForceNew) Override variable worker_config, commonly used to attach existing instances.
122123
* `worker_config` - (Optional, List, ForceNew) Deploy the machine configuration information of the 'WORKER', commonly used to attach existing instances.
@@ -191,7 +192,6 @@ The `worker_config` object supports the following:
191192
In addition to all arguments above, the following attributes are exported:
192193

193194
* `id` - ID of the resource.
194-
* `security_groups` - A list of security group IDs after attach to cluster.
195195
* `state` - State of the node.
196196

197197

0 commit comments

Comments
 (0)