Skip to content

Commit 338c9f0

Browse files
committed
add
1 parent 34f5fd8 commit 338c9f0

10 files changed

+149
-5
lines changed

.changelog/3334.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
```release-note:enhancement
22
resource/tencentcloud_cbs_storage: support `kms_key_id`
33
```
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+
```

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_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: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
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+
35
Example Usage
46

57
Create 3 standard CBS storages
@@ -16,6 +18,35 @@ resource "tencentcloud_cbs_storage_set" "example" {
1618
}
1719
```
1820

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

2152
```hcl

website/docs/d/cbs_storages.html.markdown

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ data "tencentcloud_cbs_storages" "example" {
3939
### The following snippet shows the new supported query params
4040

4141
```hcl
42-
data "tencentcloud_cbs_storages" "whats_new" {
42+
data "tencentcloud_cbs_storages" "example" {
4343
charge_type = ["POSTPAID_BY_HOUR", "PREPAID", "CDCPAID", "DEDICATED_CLUSTER_PAID"]
4444
storage_state = ["ATTACHED"]
4545
instance_ips = ["10.0.0.2"]
@@ -82,6 +82,7 @@ In addition to all arguments above, the following attributes are exported:
8282
* `dedicated_cluster_id` - Exclusive cluster id.
8383
* `encrypt` - Indicates whether CBS is encrypted.
8484
* `instance_id` - ID of the CVM instance that be mounted by this CBS.
85+
* `kms_key_id` - Kms key ID.
8586
* `prepaid_renew_flag` - The way that CBS instance will be renew automatically or not when it reach the end of the prepaid tenancy.
8687
* `project_id` - ID of the project.
8788
* `status` - Status of CBS.

website/docs/d/cbs_storages_set.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ In addition to all arguments above, the following attributes are exported:
5353
* `dedicated_cluster_id` - Exclusive cluster id.
5454
* `encrypt` - Indicates whether CBS is encrypted.
5555
* `instance_id` - ID of the CVM instance that be mounted by this CBS.
56+
* `kms_key_id` - Kms key ID.
5657
* `prepaid_renew_flag` - The way that CBS instance will be renew automatically or not when it reach the end of the prepaid tenancy.
5758
* `project_id` - ID of the project.
5859
* `status` - Status of CBS.

website/docs/r/cbs_storage.html.markdown

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ description: |-
1111

1212
Provides a resource to create a CBS storage.
1313

14+
-> **NOTE:** When creating an encrypted disk, if `kms_key_id` is not entered, the product side will generate a key by default.
15+
1416
## Example Usage
1517

1618
### Create a standard CBS storage
@@ -25,7 +27,42 @@ resource "tencentcloud_cbs_storage" "example" {
2527
encrypt = false
2628
2729
tags = {
28-
createBy = "terraform"
30+
createBy = "Terraform"
31+
}
32+
}
33+
```
34+
35+
### Create an encrypted CBS storage with customize kms_key_id
36+
37+
```hcl
38+
resource "tencentcloud_cbs_storage" "example" {
39+
storage_name = "tf-example"
40+
storage_type = "CLOUD_SSD"
41+
storage_size = 100
42+
availability_zone = "ap-guangzhou-3"
43+
project_id = 0
44+
kms_key_id = "2e860789-7ef0-11ef-8d1c-5254001955d1"
45+
encrypt = true
46+
47+
tags = {
48+
createBy = "Terraform"
49+
}
50+
}
51+
```
52+
53+
### Create an encrypted CBS storage with default generated kms_key_id
54+
55+
```hcl
56+
resource "tencentcloud_cbs_storage" "example" {
57+
storage_name = "tf-example"
58+
storage_type = "CLOUD_SSD"
59+
storage_size = 100
60+
availability_zone = "ap-guangzhou-3"
61+
project_id = 0
62+
encrypt = true
63+
64+
tags = {
65+
createBy = "Terraform"
2966
}
3067
}
3168
```
@@ -44,7 +81,7 @@ resource "tencentcloud_cbs_storage" "example" {
4481
encrypt = false
4582
4683
tags = {
47-
createBy = "terraform"
84+
createBy = "Terraform"
4885
}
4986
}
5087
```
@@ -60,8 +97,9 @@ The following arguments are supported:
6097
* `charge_type` - (Optional, String) The charge type of CBS instance. Valid values are `PREPAID`, `POSTPAID_BY_HOUR`, `CDCPAID` and `DEDICATED_CLUSTER_PAID`. The default is `POSTPAID_BY_HOUR`.
6198
* `dedicated_cluster_id` - (Optional, String, ForceNew) Exclusive cluster id.
6299
* `disk_backup_quota` - (Optional, Int) The quota of backup points of cloud disk.
63-
* `encrypt` - (Optional, Bool, ForceNew) Indicates whether CBS is encrypted.
100+
* `encrypt` - (Optional, Bool, ForceNew) Pass in this parameter to create an encrypted cloud disk.
64101
* `force_delete` - (Optional, Bool) Indicate whether to delete CBS instance directly or not. Default is false. If set true, the instance will be deleted instead of staying recycle bin.
102+
* `kms_key_id` - (Optional, String, ForceNew) Optional parameters. When purchasing an encryption disk, customize the key. When this parameter is passed in, the `encrypt` parameter need be set.
65103
* `period` - (Optional, Int, **Deprecated**) It has been deprecated from version 1.33.0. Set `prepaid_period` instead. The purchased usage period of CBS. Valid values: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 24, 36].
66104
* `prepaid_period` - (Optional, Int) The tenancy (time unit is month) of the prepaid instance, NOTE: it only works when charge_type is set to `PREPAID`. Valid values are 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 24, 36.
67105
* `prepaid_renew_flag` - (Optional, String) Auto Renewal flag. Value range: `NOTIFY_AND_AUTO_RENEW`: Notify expiry and renew automatically, `NOTIFY_AND_MANUAL_RENEW`: Notify expiry but do not renew automatically, `DISABLE_NOTIFY_AND_MANUAL_RENEW`: Neither notify expiry nor renew automatically. Default value range: `NOTIFY_AND_MANUAL_RENEW`: Notify expiry but do not renew automatically. NOTE: it only works when charge_type is set to `PREPAID`.

website/docs/r/cbs_storage_set.html.markdown

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ description: |-
1111

1212
Provides a resource to create CBS set.
1313

14+
-> **NOTE:** When creating encrypted disks, if `kms_key_id` is not entered, the product side will generate a key by default.
15+
1416
## Example Usage
1517

1618
### Create 3 standard CBS storages
@@ -27,6 +29,35 @@ resource "tencentcloud_cbs_storage_set" "example" {
2729
}
2830
```
2931

32+
### Create 3 standard CBS storages with customize kms_key_id
33+
34+
```hcl
35+
resource "tencentcloud_cbs_storage_set" "example" {
36+
disk_count = 3
37+
storage_name = "tf-example"
38+
storage_type = "CLOUD_SSD"
39+
storage_size = 100
40+
availability_zone = "ap-guangzhou-3"
41+
project_id = 0
42+
kms_key_id = "b60b328d-7ed5-11ef-8836-5254009ad364"
43+
encrypt = true
44+
}
45+
```
46+
47+
### Create 3 encrypted CBS storage with default generated kms_key_id
48+
49+
```hcl
50+
resource "tencentcloud_cbs_storage_set" "example" {
51+
disk_count = 3
52+
storage_name = "tf-example"
53+
storage_type = "CLOUD_SSD"
54+
storage_size = 100
55+
availability_zone = "ap-guangzhou-3"
56+
project_id = 0
57+
encrypt = true
58+
}
59+
```
60+
3061
### Create 3 dedicated cluster CBS storages
3162

3263
```hcl
@@ -55,6 +86,7 @@ The following arguments are supported:
5586
* `dedicated_cluster_id` - (Optional, String, ForceNew) Exclusive cluster id.
5687
* `disk_count` - (Optional, Int, ForceNew) The number of disks to be purchased. Default 1.
5788
* `encrypt` - (Optional, Bool, ForceNew) Indicates whether CBS is encrypted.
89+
* `kms_key_id` - (Optional, String, ForceNew) Optional parameters. When purchasing an encryption disk, customize the key. When this parameter is passed in, the `encrypt` parameter need be set.
5890
* `project_id` - (Optional, Int) ID of the project to which the instance belongs.
5991
* `snapshot_id` - (Optional, String) ID of the snapshot. If specified, created the CBS by this snapshot.
6092
* `throughput_performance` - (Optional, Int) Add extra performance to the data disk. Only works when disk type is `CLOUD_TSSD` or `CLOUD_HSSD`.

0 commit comments

Comments
 (0)