Skip to content

Commit 61a9bd4

Browse files
authored
Merge branch 'master' into feat/cls_pltv2
2 parents 4895751 + 8f150d3 commit 61a9bd4

25 files changed

+2156
-1084
lines changed

.changelog/3334.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_cbs_storage: support `kms_key_id`
3+
```
4+
5+
```release-note:enhancement
6+
resource/tencentcloud_cbs_storage_set: support `kms_key_id`
7+
```
8+
9+
```release-note:enhancement
10+
datasource/tencentcloud_cbs_storages: add return value `kms_key_id`
11+
```
12+
13+
```release-note:enhancement
14+
datasource/tencentcloud_cbs_storages_set: add return value `kms_key_id`
15+
```

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ require (
3434
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/bi v1.0.824
3535
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cam v1.0.1071
3636
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cat v1.0.825
37-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cbs v1.0.591
37+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cbs v1.0.1153
3838
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cdb v1.0.944
3939
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cdn v1.0.1010
4040
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cdwch v1.0.1129
@@ -45,8 +45,8 @@ require (
4545
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ckafka v1.0.1073
4646
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.1107
4747
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit v1.0.1033
48-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1149
4948
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.1148
49+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1153
5050
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.1128
5151
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cwp v1.0.762
5252
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cynosdb v1.0.1111

go.sum

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,10 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cat v1.0.825 h1:TgO9L1y
837837
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cat v1.0.825/go.mod h1:1yCKeIioX4D0bcIDHs3JCS5lbyzndXh1E8wHyHaCjxY=
838838
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cbs v1.0.591 h1:TPGLjH6wqkA5Iirl6xCxFkWwrtCZ8ZmeF7ASzqUbsZA=
839839
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cbs v1.0.591/go.mod h1:nCAGfVTXZkVnurkbjF3b0FM6RwGztE9t8D9Ms1unaKo=
840+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cbs v1.0.1148 h1:AUppERhfYCUu5ZAN8gbGYfHwPy1uaT7nPmhYGY5JvSY=
841+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cbs v1.0.1148/go.mod h1:cfP+nV0uB7FF86XyKF31edBoSJO36WFUsTc0KC80B4I=
842+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cbs v1.0.1153 h1:jRsdk2F5QZusPAV5+C/cwmgXoxxomOXH3o9ofeb4dFo=
843+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cbs v1.0.1153/go.mod h1:M83IuCDKXMqmpeOMkVtu9cloiJZsylESDjCvF0hzWQg=
840844
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cdb v1.0.944 h1:+PGoNHlZE/WY6KWWNOByL0sYVv1ZJtSx7yXMUJNYV1Y=
841845
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cdb v1.0.944/go.mod h1:+VHcZ4Cnzpt6vtCvNROz8xWfNWUkoAZ9UPSonbA3NWM=
842846
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cdc v1.0.970 h1:0A6PwOaUeLtm4U5TR1uD91ETBgDcnfqFnsG9mwCNvlY=
@@ -947,14 +951,14 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1136/go.mod
947951
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1142/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
948952
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1145 h1:DETyir/MtG+GLOD0OatzjrQTTXRguFSJo1ZtPXtbIQw=
949953
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1145/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
950-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1148 h1:+2jHvXzO0ljzTtqdnZ6ug0wMLYSaMwyr1zJa0z/DqyE=
951-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1148/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
952954
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1147 h1:6v559jM1v6A4KJinNZ28RqVZs+ipKMzCWtYWcWy+zZ4=
953955
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1147/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
954956
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1148 h1:+2jHvXzO0ljzTtqdnZ6ug0wMLYSaMwyr1zJa0z/DqyE=
955957
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1148/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
956958
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1149 h1:a2N8e9YHftVvJmI6PIVJBLfPuy2dn+jZ92atTsmtJuc=
957959
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1149/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
960+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1153 h1:g/aw2nrrMfO/+sdBPCFsiq+sgSFNiUK/sAci6PT4O4E=
961+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1153/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
958962
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/controlcenter v1.0.993 h1:WlPgXldQCxt7qi5Xrc6j6zTrsXWzN5BcOGs7Irq7fwQ=
959963
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/controlcenter v1.0.993/go.mod h1:Z9U8zNtyuyKhjS0698wqsrG/kLx1TQ5CEixXBwVe7xY=
960964
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/csip v1.0.860 h1:F3esKBIT3HW9+7Gt8cVgf8X06VdGIczpgLBUECzSEzU=

tencentcloud/services/cbs/data_source_tc_cbs_storages.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,11 @@ func DataSourceTencentCloudCbsStorages() *schema.Resource {
156156
Computed: true,
157157
Description: "ID of the CVM instance that be mounted by this CBS.",
158158
},
159+
"kms_key_id": {
160+
Type: schema.TypeString,
161+
Computed: true,
162+
Description: "Kms key ID.",
163+
},
159164
"encrypt": {
160165
Type: schema.TypeBool,
161166
Computed: true,
@@ -288,6 +293,7 @@ func dataSourceTencentCloudCbsStoragesRead(d *schema.ResourceData, meta interfac
288293
"storage_size": storage.DiskSize,
289294
"attached": storage.Attached,
290295
"instance_id": storage.InstanceId,
296+
"kms_key_id": storage.KmsKeyId,
291297
"encrypt": storage.Encrypt,
292298
"create_time": storage.CreateTime,
293299
"status": storage.DiskState,

tencentcloud/services/cbs/data_source_tc_cbs_storages.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Use this data source to query detailed information of CBS storages.
33
Example Usage
44

55
Query all CBS storages
6+
67
```hcl
78
data "tencentcloud_cbs_storages" "example" {}
89
```
@@ -17,6 +18,7 @@ data "tencentcloud_cbs_storages" "example" {
1718
```
1819

1920
Query CBS by dedicated cluster id
21+
2022
```hcl
2123
data "tencentcloud_cbs_storages" "example" {
2224
dedicated_cluster_id = "cluster-262n63e8"
@@ -26,7 +28,7 @@ data "tencentcloud_cbs_storages" "example" {
2628
The following snippet shows the new supported query params
2729

2830
```hcl
29-
data "tencentcloud_cbs_storages" "whats_new" {
31+
data "tencentcloud_cbs_storages" "example" {
3032
charge_type = ["POSTPAID_BY_HOUR", "PREPAID", "CDCPAID", "DEDICATED_CLUSTER_PAID"]
3133
storage_state = ["ATTACHED"]
3234
instance_ips = ["10.0.0.2"]

tencentcloud/services/cbs/data_source_tc_cbs_storages_set.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,11 @@ func DataSourceTencentCloudCbsStoragesSet() *schema.Resource {
155155
Computed: true,
156156
Description: "ID of the CVM instance that be mounted by this CBS.",
157157
},
158+
"kms_key_id": {
159+
Type: schema.TypeString,
160+
Computed: true,
161+
Description: "Kms key ID.",
162+
},
158163
"encrypt": {
159164
Type: schema.TypeBool,
160165
Computed: true,
@@ -286,6 +291,7 @@ func dataSourceTencentCloudCbsStoragesSetRead(d *schema.ResourceData, meta inter
286291
"storage_size": storage.DiskSize,
287292
"attached": storage.Attached,
288293
"instance_id": storage.InstanceId,
294+
"kms_key_id": storage.KmsKeyId,
289295
"encrypt": storage.Encrypt,
290296
"create_time": storage.CreateTime,
291297
"status": storage.DiskState,

tencentcloud/services/cbs/resource_tc_cbs_storage.go

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,18 @@ func ResourceTencentCloudCbsStorage() *schema.Resource {
9595
Default: 0,
9696
Description: "ID of the project to which the instance belongs.",
9797
},
98+
"kms_key_id": {
99+
Type: schema.TypeString,
100+
Optional: true,
101+
ForceNew: true,
102+
Computed: true,
103+
Description: "Optional parameters. When purchasing an encryption disk, customize the key. When this parameter is passed in, the `encrypt` parameter need be set.",
104+
},
98105
"encrypt": {
99106
Type: schema.TypeBool,
100107
Optional: true,
101108
ForceNew: true,
102-
Description: "Indicates whether CBS is encrypted.",
109+
Description: "Pass in this parameter to create an encrypted cloud disk.",
103110
},
104111
"tags": {
105112
Type: schema.TypeMap,
@@ -156,7 +163,7 @@ func resourceTencentCloudCbsStorageCreate(d *schema.ResourceData, meta interface
156163
Zone: helper.String(d.Get("availability_zone").(string)),
157164
}
158165

159-
if v, ok := d.GetOk("project_id"); ok {
166+
if v, ok := d.GetOkExists("project_id"); ok {
160167
request.Placement.ProjectId = helper.IntUint64(v.(int))
161168
}
162169

@@ -168,11 +175,15 @@ func resourceTencentCloudCbsStorageCreate(d *schema.ResourceData, meta interface
168175
request.SnapshotId = helper.String(v.(string))
169176
}
170177

178+
if v, ok := d.GetOk("kms_key_id"); ok {
179+
request.KmsKeyId = helper.String(v.(string))
180+
}
181+
171182
if _, ok := d.GetOk("encrypt"); ok {
172183
request.Encrypt = helper.String("ENCRYPT")
173184
}
174185

175-
if v, ok := d.GetOk("throughput_performance"); ok {
186+
if v, ok := d.GetOkExists("throughput_performance"); ok {
176187
request.ThroughputPerformance = helper.IntUint64(v.(int))
177188
}
178189

@@ -182,7 +193,7 @@ func resourceTencentCloudCbsStorageCreate(d *schema.ResourceData, meta interface
182193

183194
if chargeType == CBS_CHARGE_TYPE_PREPAID {
184195
request.DiskChargePrepaid = &cbs.DiskChargePrepaid{}
185-
if period, ok := d.GetOk("prepaid_period"); ok {
196+
if period, ok := d.GetOkExists("prepaid_period"); ok {
186197
periodInt64 := uint64(period.(int))
187198
request.DiskChargePrepaid.Period = &periodInt64
188199
} else {
@@ -215,6 +226,10 @@ func resourceTencentCloudCbsStorageCreate(d *schema.ResourceData, meta interface
215226
return tccommon.RetryError(e, tccommon.InternalError)
216227
}
217228

229+
if response == nil || response.Response == nil {
230+
return resource.NonRetryableError(fmt.Errorf("Create cbs failed, Response is nil."))
231+
}
232+
218233
if len(response.Response.DiskIdSet) < 1 {
219234
return resource.NonRetryableError(fmt.Errorf("storage id is nil"))
220235
}
@@ -310,6 +325,10 @@ func resourceTencentCloudCbsStorageRead(d *schema.ResourceData, meta interface{}
310325
_ = d.Set("prepaid_renew_flag", storage.RenewFlag)
311326
_ = d.Set("throughput_performance", storage.ThroughputPerformance)
312327

328+
if storage.KmsKeyId != nil {
329+
_ = d.Set("kms_key_id", storage.KmsKeyId)
330+
}
331+
313332
if *storage.DiskChargeType == CBS_CHARGE_TYPE_PREPAID {
314333
_ = d.Set("prepaid_renew_flag", storage.RenewFlag)
315334
}

tencentcloud/services/cbs/resource_tc_cbs_storage.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
Provides a resource to create a CBS storage.
22

3+
-> **NOTE:** When creating an encrypted disk, if `kms_key_id` is not entered, the product side will generate a key by default.
4+
5+
-> **NOTE:** When using CBS encrypted disk, it is necessary to add `CVM_QcsRole` role and `QcloudKMSAccessForCVMRole` strategy to the account.
6+
37
Example Usage
48

59
Create a standard CBS storage
@@ -14,7 +18,42 @@ resource "tencentcloud_cbs_storage" "example" {
1418
encrypt = false
1519
1620
tags = {
17-
createBy = "terraform"
21+
createBy = "Terraform"
22+
}
23+
}
24+
```
25+
26+
Create an encrypted CBS storage with customize kms_key_id
27+
28+
```hcl
29+
resource "tencentcloud_cbs_storage" "example" {
30+
storage_name = "tf-example"
31+
storage_type = "CLOUD_SSD"
32+
storage_size = 100
33+
availability_zone = "ap-guangzhou-3"
34+
project_id = 0
35+
kms_key_id = "2e860789-7ef0-11ef-8d1c-5254001955d1"
36+
encrypt = true
37+
38+
tags = {
39+
createBy = "Terraform"
40+
}
41+
}
42+
```
43+
44+
Create an encrypted CBS storage with default generated kms_key_id
45+
46+
```hcl
47+
resource "tencentcloud_cbs_storage" "example" {
48+
storage_name = "tf-example"
49+
storage_type = "CLOUD_SSD"
50+
storage_size = 100
51+
availability_zone = "ap-guangzhou-3"
52+
project_id = 0
53+
encrypt = true
54+
55+
tags = {
56+
createBy = "Terraform"
1857
}
1958
}
2059
```
@@ -33,7 +72,7 @@ resource "tencentcloud_cbs_storage" "example" {
3372
encrypt = false
3473
3574
tags = {
36-
createBy = "terraform"
75+
createBy = "Terraform"
3776
}
3877
}
3978
```

tencentcloud/services/cbs/resource_tc_cbs_storage_set.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ func ResourceTencentCloudCbsStorageSet() *schema.Resource {
8080
Default: 0,
8181
Description: "ID of the project to which the instance belongs.",
8282
},
83+
"kms_key_id": {
84+
Type: schema.TypeString,
85+
Optional: true,
86+
ForceNew: true,
87+
Computed: true,
88+
Description: "Optional parameters. When purchasing an encryption disk, customize the key. When this parameter is passed in, the `encrypt` parameter need be set.",
89+
},
8390
"encrypt": {
8491
Type: schema.TypeBool,
8592
Optional: true,
@@ -148,6 +155,10 @@ func resourceTencentCloudCbsStorageSetCreate(d *schema.ResourceData, meta interf
148155
request.SnapshotId = helper.String(v.(string))
149156
}
150157

158+
if v, ok := d.GetOk("kms_key_id"); ok {
159+
request.KmsKeyId = helper.String(v.(string))
160+
}
161+
151162
if _, ok := d.GetOk("encrypt"); ok {
152163
request.Encrypt = helper.String("ENCRYPT")
153164
}
@@ -234,6 +245,10 @@ func resourceTencentCloudCbsStorageSetRead(d *schema.ResourceData, meta interfac
234245
_ = d.Set("charge_type", storage.DiskChargeType)
235246
_ = d.Set("throughput_performance", storage.ThroughputPerformance)
236247

248+
if storage.KmsKeyId != nil {
249+
_ = d.Set("kms_key_id", storage.KmsKeyId)
250+
}
251+
237252
return nil
238253
}
239254

tencentcloud/services/cbs/resource_tc_cbs_storage_set.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
Provides a resource to create CBS set.
22

3+
-> **NOTE:** When creating encrypted disks, if `kms_key_id` is not entered, the product side will generate a key by default.
4+
5+
-> **NOTE:** When using CBS encrypted disk, it is necessary to add `CVM_QcsRole` role and `QcloudKMSAccessForCVMRole` strategy to the account.
6+
37
Example Usage
48

59
Create 3 standard CBS storages
@@ -16,6 +20,35 @@ resource "tencentcloud_cbs_storage_set" "example" {
1620
}
1721
```
1822

23+
Create 3 standard CBS storages with customize kms_key_id
24+
25+
```hcl
26+
resource "tencentcloud_cbs_storage_set" "example" {
27+
disk_count = 3
28+
storage_name = "tf-example"
29+
storage_type = "CLOUD_SSD"
30+
storage_size = 100
31+
availability_zone = "ap-guangzhou-3"
32+
project_id = 0
33+
kms_key_id = "b60b328d-7ed5-11ef-8836-5254009ad364"
34+
encrypt = true
35+
}
36+
```
37+
38+
Create 3 encrypted CBS storage with default generated kms_key_id
39+
40+
```hcl
41+
resource "tencentcloud_cbs_storage_set" "example" {
42+
disk_count = 3
43+
storage_name = "tf-example"
44+
storage_type = "CLOUD_SSD"
45+
storage_size = 100
46+
availability_zone = "ap-guangzhou-3"
47+
project_id = 0
48+
encrypt = true
49+
}
50+
```
51+
1952
Create 3 dedicated cluster CBS storages
2053

2154
```hcl

0 commit comments

Comments
 (0)