Skip to content

Commit b643757

Browse files
author
yuanhaojin
committed
Merge remote-tracking branch 'upstream/master' into yuanhaojin
update local-repo
2 parents ea4c829 + 9c70316 commit b643757

File tree

6 files changed

+193
-3
lines changed

6 files changed

+193
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
## 1.39.0 (Unreleased)
2+
3+
ENHANCEMENTS:
4+
* Resource: `tencentcloud_kubernetes_cluster_attachment` add new argument `worker_config` to support config with existing instances.
5+
26
## 1.38.2 (July 03, 2020)
37

48
BUG FIXES:

tencentcloud/internal/helper/transform.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,12 @@ func BoolToInt64Pointer(s bool) (i *uint64) {
100100
i = &result
101101
return
102102
}
103+
104+
func BoolToInt64Ptr(s bool) (i *int64) {
105+
result := int64(0)
106+
if s {
107+
result = int64(1)
108+
}
109+
i = &result
110+
return
111+
}

tencentcloud/resource_tc_cam_role.go

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ Provides a resource to create a CAM role.
33
44
Example Usage
55
6+
Create normally
7+
68
```hcl
79
resource "tencentcloud_cam_role" "foo" {
810
name = "cam-role-test"
@@ -14,7 +16,31 @@ resource "tencentcloud_cam_role" "foo" {
1416
"action": ["name/sts:AssumeRole"],
1517
"effect": "allow",
1618
"principal": {
17-
"qcs": ["qcs::cam::uin/3374997817:uin/3374997817"]
19+
"qcs": ["qcs::cam::uin/<your-account-id>:uin/<your-account-id>"]
20+
}
21+
}
22+
]
23+
}
24+
EOF
25+
description = "test"
26+
console_login = true
27+
}
28+
```
29+
30+
Create with SAML provider
31+
32+
```hcl
33+
resource "tencentcloud_cam_role" "boo" {
34+
name = "cam-role-test"
35+
document = <<EOF
36+
{
37+
"version": "2.0",
38+
"statement": [
39+
{
40+
"action": ["name/sts:AssumeRole", "name/sts:AssumeRoleWithWebIdentity"],
41+
"effect": "allow",
42+
"principal": {
43+
"federated": ["qcs::cam::uin/<your-account-id>:saml-provider/<your-name>"]
1844
}
1945
}
2046
]

tencentcloud/resource_tc_kubernetes_cluster_attachment.go

Lines changed: 112 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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+
111168
func 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+
}
165268
func 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

website/docs/r/cam_role.html.markdown

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Provides a resource to create a CAM role.
1212

1313
## Example Usage
1414

15+
Create normally
16+
1517
```hcl
1618
resource "tencentcloud_cam_role" "foo" {
1719
name = "cam-role-test"
@@ -23,7 +25,31 @@ resource "tencentcloud_cam_role" "foo" {
2325
"action": ["name/sts:AssumeRole"],
2426
"effect": "allow",
2527
"principal": {
26-
"qcs": ["qcs::cam::uin/3374997817:uin/3374997817"]
28+
"qcs": ["qcs::cam::uin/<your-account-id>:uin/<your-account-id>"]
29+
}
30+
}
31+
]
32+
}
33+
EOF
34+
description = "test"
35+
console_login = true
36+
}
37+
```
38+
39+
Create with SAML provider
40+
41+
```hcl
42+
resource "tencentcloud_cam_role" "boo" {
43+
name = "cam-role-test"
44+
document = <<EOF
45+
{
46+
"version": "2.0",
47+
"statement": [
48+
{
49+
"action": ["name/sts:AssumeRole", "name/sts:AssumeRoleWithWebIdentity"],
50+
"effect": "allow",
51+
"principal": {
52+
"federated": ["qcs::cam::uin/<your-account-id>:saml-provider/<your-name>"]
2753
}
2854
}
2955
]

website/docs/r/kubernetes_cluster_attachment.html.markdown

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,20 @@ The following arguments are supported:
108108
* `key_ids` - (Optional, ForceNew) The key pair to use for the instance, it looks like skey-16jig7tx, it should be set if `password` not set.
109109
* `labels` - (Optional, ForceNew) Labels of tke attachment exits cvm.
110110
* `password` - (Optional, ForceNew) Password to access, should be set if `key_ids` not set.
111+
* `worker_config` - (Optional, ForceNew) Deploy the machine configuration information of the 'WORKER', commonly used to attach existing instances.
112+
113+
The `data_disk` object supports the following:
114+
115+
* `disk_size` - (Optional, ForceNew) Volume of disk in GB. Default is 0.
116+
* `disk_type` - (Optional, ForceNew) Types of disk, available values: CLOUD_PREMIUM and CLOUD_SSD.
117+
118+
The `worker_config` object supports the following:
119+
120+
* `data_disk` - (Optional, ForceNew) Configurations of data disk.
121+
* `docker_graph_path` - (Optional, ForceNew) Docker graph path. Default is `/var/lib/docker`.
122+
* `is_schedule` - (Optional, ForceNew) Indicate to schedule the adding node or not. Default is true.
123+
* `mount_target` - (Optional, ForceNew) Mount target. Default is not mounting.
124+
* `user_data` - (Optional, ForceNew) Base64-encoded User Data text, the length limit is 16KB.
111125

112126
## Attributes Reference
113127

0 commit comments

Comments
 (0)