Skip to content

fix(cbs): [124497595] tencentcloud_cbs_storage support encrypt_type #3395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/3395.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_cbs_storage: support `encrypt_type`
```
15 changes: 15 additions & 0 deletions tencentcloud/services/cbs/resource_tc_cbs_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ func ResourceTencentCloudCbsStorage() *schema.Resource {
Computed: true,
Description: "Whether to enable performance burst when creating a cloud disk.",
},
"encrypt_type": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Computed: true,
Description: "Specifies the cloud disk encryption type. The values are `ENCRYPT_V1` and `ENCRYPT_V2`, which represent the first-generation and second-generation encryption technologies respectively. The two encryption technologies are incompatible with each other. It is recommended to use the second-generation encryption technology `ENCRYPT_V2` first. The first-generation encryption technology is only supported on some older models. This parameter is only valid when creating an encrypted cloud disk.",
},
// computed
"storage_status": {
Type: schema.TypeString,
Expand Down Expand Up @@ -227,6 +234,10 @@ func resourceTencentCloudCbsStorageCreate(d *schema.ResourceData, meta interface
request.BurstPerformance = helper.Bool(v.(bool))
}

if v, ok := d.GetOkExists("encrypt_type"); ok {
request.EncryptType = helper.String(v.(string))
}

storageId := ""
err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
response, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseCbsClient().CreateDisks(request)
Expand Down Expand Up @@ -336,6 +347,10 @@ func resourceTencentCloudCbsStorageRead(d *schema.ResourceData, meta interface{}
_ = d.Set("throughput_performance", storage.ThroughputPerformance)
_ = d.Set("burst_performance", storage.BurstPerformance)

if storage.EncryptType != nil {
_ = d.Set("encrypt_type", storage.EncryptType)
}

if storage.KmsKeyId != nil {
_ = d.Set("kms_key_id", storage.KmsKeyId)
}
Expand Down
18 changes: 18 additions & 0 deletions tencentcloud/services/cbs/resource_tc_cbs_storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,24 @@ resource "tencentcloud_cbs_storage" "example" {
}
```

Create an encrypted CBS storage with encrypt_type

```hcl
resource "tencentcloud_cbs_storage" "example" {
storage_name = "tf-example"
storage_type = "CLOUD_SSD"
storage_size = 100
availability_zone = "ap-guangzhou-3"
project_id = 0
encrypt = true
encrypt_type = "ENCRYPT_V2"

tags = {
createBy = "Terraform"
}
}
```

Create a dedicated cluster CBS storage

```hcl
Expand Down
19 changes: 19 additions & 0 deletions website/docs/r/cbs_storage.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,24 @@ resource "tencentcloud_cbs_storage" "example" {
}
```

### Create an encrypted CBS storage with encrypt_type

```hcl
resource "tencentcloud_cbs_storage" "example" {
storage_name = "tf-example"
storage_type = "CLOUD_SSD"
storage_size = 100
availability_zone = "ap-guangzhou-3"
project_id = 0
encrypt = true
encrypt_type = "ENCRYPT_V2"

tags = {
createBy = "Terraform"
}
}
```

### Create a dedicated cluster CBS storage

```hcl
Expand Down Expand Up @@ -100,6 +118,7 @@ The following arguments are supported:
* `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`.
* `dedicated_cluster_id` - (Optional, String, ForceNew) Exclusive cluster id.
* `disk_backup_quota` - (Optional, Int) The quota of backup points of cloud disk.
* `encrypt_type` - (Optional, String, ForceNew) Specifies the cloud disk encryption type. The values are `ENCRYPT_V1` and `ENCRYPT_V2`, which represent the first-generation and second-generation encryption technologies respectively. The two encryption technologies are incompatible with each other. It is recommended to use the second-generation encryption technology `ENCRYPT_V2` first. The first-generation encryption technology is only supported on some older models. This parameter is only valid when creating an encrypted cloud disk.
* `encrypt` - (Optional, Bool, ForceNew) Pass in this parameter to create an encrypted cloud disk.
* `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.
* `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.
Expand Down
Loading