Skip to content

Commit e201149

Browse files
authored
support create turbo cfs (#1934)
* support create turbo cfs * add changelog
1 parent db36b21 commit e201149

File tree

4 files changed

+187
-20
lines changed

4 files changed

+187
-20
lines changed

.changelog/1934.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_cfs_file_system: support create turbo file system
3+
```

tencentcloud/extension_cfs.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
package tencentcloud
22

33
const (
4-
CFS_PROTOCOL_NFS = "NFS"
5-
CFS_PROTOCOL_CIFS = "CIFS"
4+
CFS_PROTOCOL_NFS = "NFS"
5+
CFS_PROTOCOL_CIFS = "CIFS"
6+
CFS_PROTOCOL_TURBO = "TURBO"
67

78
CFS_STORAGETYPE_SD = "SD"
89
CFS_STORAGETYPE_HP = "HP"
10+
CFS_STORAGETYPE_TB = "TB"
11+
CFS_STORAGETYPE_TP = "TP"
12+
13+
CFS_NET_VPC = "VPC"
14+
CFS_NET_CCN = "CCN"
915

1016
CFS_FILE_SYSTEM_STATUS_CREATING = "creating"
1117
CFS_FILE_SYSTEM_STATUS_SUCCESS = "available"
@@ -23,11 +29,19 @@ const (
2329
var CFS_STORAGETYPE = []string{
2430
CFS_STORAGETYPE_SD,
2531
CFS_STORAGETYPE_HP,
32+
CFS_STORAGETYPE_TB,
33+
CFS_STORAGETYPE_TP,
2634
}
2735

2836
var CFS_PROTOCOL = []string{
2937
CFS_PROTOCOL_NFS,
3038
CFS_PROTOCOL_CIFS,
39+
CFS_PROTOCOL_TURBO,
40+
}
41+
42+
var CFS_NET = []string{
43+
CFS_NET_VPC,
44+
CFS_NET_CCN,
3145
}
3246

3347
var CFS_RW_PERMISSION = []string{

tencentcloud/resource_tc_cfs_file_system.go

Lines changed: 110 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ Provides a resource to create a cloud file system(CFS).
33
44
Example Usage
55
6+
Standard Nfs CFS
7+
68
```hcl
79
resource "tencentcloud_cfs_file_system" "foo" {
810
name = "test_file_system"
@@ -14,6 +16,54 @@ resource "tencentcloud_cfs_file_system" "foo" {
1416
}
1517
```
1618
19+
High-Performance Nfs CFS
20+
21+
```hcl
22+
resource "tencentcloud_cfs_file_system" "foo" {
23+
name = "test_file_system"
24+
net_interface = "CCN"
25+
availability_zone = "ap-guangzhou-6"
26+
access_group_id = "pgroup-drwt29od"
27+
protocol = "TURBO"
28+
storage_type = "TP"
29+
capacity = 10240
30+
ccn_id = "ccn-39lqkygf"
31+
cidr_block = "11.0.0.0/24"
32+
}
33+
```
34+
35+
Standard Turbo CFS
36+
37+
```hcl
38+
resource "tencentcloud_cfs_file_system" "foo" {
39+
name = "test_file_system"
40+
net_interface = "CCN"
41+
availability_zone = "ap-guangzhou-6"
42+
access_group_id = "pgroup-drwt29od"
43+
protocol = "TURBO"
44+
storage_type = "TB"
45+
capacity = 20480
46+
ccn_id = "ccn-39lqkygf"
47+
cidr_block = "11.0.0.0/24"
48+
}
49+
```
50+
51+
High-Performance Turbo CFS
52+
53+
```hcl
54+
resource "tencentcloud_cfs_file_system" "foo" {
55+
name = "test_file_system"
56+
net_interface = "CCN"
57+
availability_zone = "ap-guangzhou-6"
58+
access_group_id = "pgroup-drwt29od"
59+
protocol = "TURBO"
60+
storage_type = "TP"
61+
capacity = 10240
62+
ccn_id = "ccn-39lqkygf"
63+
cidr_block = "11.0.0.0/24"
64+
}
65+
```
66+
1767
Import
1868
1969
Cloud file system can be imported using the id, e.g.
@@ -64,31 +114,40 @@ func resourceTencentCloudCfsFileSystem() *schema.Resource {
64114
Required: true,
65115
Description: "ID of a access group.",
66116
},
117+
"net_interface": {
118+
Type: schema.TypeString,
119+
Optional: true,
120+
Default: CFS_NET_VPC,
121+
ValidateFunc: validateAllowedStringValue(CFS_NET),
122+
Description: "Network type, Default `VPC`. Valid values: `VPC` and `CCN`. Select `VPC` for a Standard or High-Performance file system, and `CCN` for a Standard Turbo or High-Performance Turbo one.",
123+
},
67124
"protocol": {
68125
Type: schema.TypeString,
69126
Optional: true,
70127
Default: CFS_PROTOCOL_NFS,
71128
ValidateFunc: validateAllowedStringValue(CFS_PROTOCOL),
72129
ForceNew: true,
73-
Description: "File service protocol. Valid values are `NFS` and `CIFS`. and the default is `NFS`.",
130+
Description: "File system protocol. Valid values: `NFS`, `CIFS`, `TURBO`. If this parameter is left empty, `NFS` is used by default. For the Turbo series, you must set this parameter to `TURBO`.",
74131
},
75132
"storage_type": {
76-
Type: schema.TypeString,
77-
Optional: true,
78-
Default: CFS_STORAGETYPE_SD,
79-
ForceNew: true,
80-
Description: "File service StorageType. Valid values are `SD` and `HP`. and the default is `SD`.",
133+
Type: schema.TypeString,
134+
Optional: true,
135+
Default: CFS_STORAGETYPE_SD,
136+
ValidateFunc: validateAllowedStringValue(CFS_STORAGETYPE),
137+
ForceNew: true,
138+
Description: "Storage type of the file system. Valid values: `SD` (Standard), `HP` (High-Performance), `TB` (Standard Turbo), and `TP` (High-Performance Turbo). Default value: `SD`.",
81139
},
82-
83140
"vpc_id": {
84141
Type: schema.TypeString,
85-
Required: true,
142+
Optional: true,
143+
Computed: true,
86144
ForceNew: true,
87145
Description: "ID of a VPC network.",
88146
},
89147
"subnet_id": {
90148
Type: schema.TypeString,
91-
Required: true,
149+
Optional: true,
150+
Computed: true,
92151
ForceNew: true,
93152
Description: "ID of a subnet.",
94153
},
@@ -99,7 +158,24 @@ func resourceTencentCloudCfsFileSystem() *schema.Resource {
99158
Computed: true,
100159
Description: "IP of mount point.",
101160
},
102-
161+
"ccn_id": {
162+
Type: schema.TypeString,
163+
Optional: true,
164+
Computed: true,
165+
Description: "CCN instance ID (required if the network type is CCN).",
166+
},
167+
"cidr_block": {
168+
Type: schema.TypeString,
169+
Optional: true,
170+
Computed: true,
171+
Description: "CCN IP range used by the CFS (required if the network type is CCN), which cannot conflict with other IP ranges bound in CCN.",
172+
},
173+
"capacity": {
174+
Type: schema.TypeInt,
175+
Optional: true,
176+
Computed: true,
177+
Description: "File system capacity, in GiB (required for the Turbo series). For Standard Turbo, the minimum purchase required is 40,960 GiB (40 TiB) and the expansion increment is 20,480 GiB (20 TiB). For High-Performance Turbo, the minimum purchase required is 20,480 GiB (20 TiB) and the expansion increment is 10,240 GiB (10 TiB).",
178+
},
103179
// computed
104180
"create_time": {
105181
Type: schema.TypeString,
@@ -130,6 +206,7 @@ func resourceTencentCloudCfsFileSystemCreate(d *schema.ResourceData, meta interf
130206

131207
request := cfs.NewCreateCfsFileSystemRequest()
132208
request.Zone = helper.String(d.Get("availability_zone").(string))
209+
request.NetInterface = helper.String(d.Get("net_interface").(string))
133210
request.PGroupId = helper.String(d.Get("access_group_id").(string))
134211
request.Protocol = helper.String(d.Get("protocol").(string))
135212
request.VpcId = helper.String(d.Get("vpc_id").(string))
@@ -141,7 +218,15 @@ func resourceTencentCloudCfsFileSystemCreate(d *schema.ResourceData, meta interf
141218
if v, ok := d.GetOk("mount_ip"); ok {
142219
request.MountIP = helper.String(v.(string))
143220
}
144-
request.NetInterface = helper.String("VPC")
221+
if v, ok := d.GetOk("ccn_id"); ok {
222+
request.CcnId = helper.String(v.(string))
223+
}
224+
if v, ok := d.GetOk("cidr_block"); ok {
225+
request.CidrBlock = helper.String(v.(string))
226+
}
227+
if v, ok := d.GetOkExists("capacity"); ok {
228+
request.Capacity = helper.IntUint64(v.(int))
229+
}
145230

146231
if v := helper.GetTags(d, "tags"); len(v) > 0 {
147232
for tagKey, tagValue := range v {
@@ -154,7 +239,7 @@ func resourceTencentCloudCfsFileSystemCreate(d *schema.ResourceData, meta interf
154239
}
155240

156241
fsId := ""
157-
err := resource.Retry(writeRetryTimeout, func() *resource.RetryError {
242+
err := resource.Retry(3*writeRetryTimeout, func() *resource.RetryError {
158243
ratelimit.Check(request.GetAction())
159244
response, err := meta.(*TencentCloudClient).apiV3Conn.UseCfsClient().CreateCfsFileSystem(request)
160245
if err != nil {
@@ -178,7 +263,7 @@ func resourceTencentCloudCfsFileSystemCreate(d *schema.ResourceData, meta interf
178263
d.SetId(fsId)
179264

180265
// wait for success status
181-
err = resource.Retry(2*readRetryTimeout, func() *resource.RetryError {
266+
err = resource.Retry(3*readRetryTimeout, func() *resource.RetryError {
182267
fileSystems, errRet := cfsService.DescribeFileSystem(ctx, fsId, "", "")
183268
if errRet != nil {
184269
return retryError(errRet, InternalError)
@@ -242,6 +327,7 @@ func resourceTencentCloudCfsFileSystemRead(d *schema.ResourceData, meta interfac
242327
_ = d.Set("protocol", fileSystem.Protocol)
243328
_ = d.Set("create_time", fileSystem.CreationTime)
244329
_ = d.Set("storage_type", fileSystem.StorageType)
330+
_ = d.Set("capacity", fileSystem.SizeLimit)
245331

246332
var mountTarget *cfs.MountInfo
247333
err = resource.Retry(readRetryTimeout, func() *resource.RetryError {
@@ -270,7 +356,9 @@ func resourceTencentCloudCfsFileSystemRead(d *schema.ResourceData, meta interfac
270356
_ = d.Set("vpc_id", mountTarget.VpcId)
271357
_ = d.Set("subnet_id", mountTarget.SubnetId)
272358
_ = d.Set("mount_ip", mountTarget.IpAddress)
273-
_ = d.Set("fs_id", mountTarget.FSID)
359+
_ = d.Set("ccn_id", mountTarget.CcnID)
360+
_ = d.Set("cidr_block", mountTarget.CidrBlock)
361+
_ = d.Set("net_interface", mountTarget.NetworkInterface)
274362
}
275363

276364
return nil
@@ -285,6 +373,14 @@ func resourceTencentCloudCfsFileSystemUpdate(d *schema.ResourceData, meta interf
285373
client: meta.(*TencentCloudClient).apiV3Conn,
286374
}
287375

376+
immutableArgs := []string{"ccn_id", "cidr_block", "net_interface", "capacity"}
377+
378+
for _, v := range immutableArgs {
379+
if d.HasChange(v) {
380+
return fmt.Errorf("argument `%s` cannot be changed", v)
381+
}
382+
}
383+
288384
d.Partial(true)
289385

290386
if d.HasChange("name") {

website/docs/r/cfs_file_system.html.markdown

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Provides a resource to create a cloud file system(CFS).
1313

1414
## Example Usage
1515

16+
Standard Nfs CFS
17+
1618
```hcl
1719
resource "tencentcloud_cfs_file_system" "foo" {
1820
name = "test_file_system"
@@ -24,19 +26,71 @@ resource "tencentcloud_cfs_file_system" "foo" {
2426
}
2527
```
2628

29+
High-Performance Nfs CFS
30+
31+
```hcl
32+
resource "tencentcloud_cfs_file_system" "foo" {
33+
name = "test_file_system"
34+
net_interface = "CCN"
35+
availability_zone = "ap-guangzhou-6"
36+
access_group_id = "pgroup-drwt29od"
37+
protocol = "TURBO"
38+
storage_type = "TP"
39+
capacity = 10240
40+
ccn_id = "ccn-39lqkygf"
41+
cidr_block = "11.0.0.0/24"
42+
}
43+
```
44+
45+
Standard Turbo CFS
46+
47+
```hcl
48+
resource "tencentcloud_cfs_file_system" "foo" {
49+
name = "test_file_system"
50+
net_interface = "CCN"
51+
availability_zone = "ap-guangzhou-6"
52+
access_group_id = "pgroup-drwt29od"
53+
protocol = "TURBO"
54+
storage_type = "TB"
55+
capacity = 20480
56+
ccn_id = "ccn-39lqkygf"
57+
cidr_block = "11.0.0.0/24"
58+
}
59+
```
60+
61+
High-Performance Turbo CFS
62+
63+
```hcl
64+
resource "tencentcloud_cfs_file_system" "foo" {
65+
name = "test_file_system"
66+
net_interface = "CCN"
67+
availability_zone = "ap-guangzhou-6"
68+
access_group_id = "pgroup-drwt29od"
69+
protocol = "TURBO"
70+
storage_type = "TP"
71+
capacity = 10240
72+
ccn_id = "ccn-39lqkygf"
73+
cidr_block = "11.0.0.0/24"
74+
}
75+
```
76+
2777
## Argument Reference
2878

2979
The following arguments are supported:
3080

3181
* `access_group_id` - (Required, String) ID of a access group.
3282
* `availability_zone` - (Required, String, ForceNew) The available zone that the file system locates at.
33-
* `subnet_id` - (Required, String, ForceNew) ID of a subnet.
34-
* `vpc_id` - (Required, String, ForceNew) ID of a VPC network.
83+
* `capacity` - (Optional, Int) File system capacity, in GiB (required for the Turbo series). For Standard Turbo, the minimum purchase required is 40,960 GiB (40 TiB) and the expansion increment is 20,480 GiB (20 TiB). For High-Performance Turbo, the minimum purchase required is 20,480 GiB (20 TiB) and the expansion increment is 10,240 GiB (10 TiB).
84+
* `ccn_id` - (Optional, String) CCN instance ID (required if the network type is CCN).
85+
* `cidr_block` - (Optional, String) CCN IP range used by the CFS (required if the network type is CCN), which cannot conflict with other IP ranges bound in CCN.
3586
* `mount_ip` - (Optional, String, ForceNew) IP of mount point.
3687
* `name` - (Optional, String) Name of a file system.
37-
* `protocol` - (Optional, String, ForceNew) File service protocol. Valid values are `NFS` and `CIFS`. and the default is `NFS`.
38-
* `storage_type` - (Optional, String, ForceNew) File service StorageType. Valid values are `SD` and `HP`. and the default is `SD`.
88+
* `net_interface` - (Optional, String) Network type, Default `VPC`. Valid values: `VPC` and `CCN`. Select `VPC` for a Standard or High-Performance file system, and `CCN` for a Standard Turbo or High-Performance Turbo one.
89+
* `protocol` - (Optional, String, ForceNew) File system protocol. Valid values: `NFS`, `CIFS`, `TURBO`. If this parameter is left empty, `NFS` is used by default. For the Turbo series, you must set this parameter to `TURBO`.
90+
* `storage_type` - (Optional, String, ForceNew) Storage type of the file system. Valid values: `SD` (Standard), `HP` (High-Performance), `TB` (Standard Turbo), and `TP` (High-Performance Turbo). Default value: `SD`.
91+
* `subnet_id` - (Optional, String, ForceNew) ID of a subnet.
3992
* `tags` - (Optional, Map) Instance tags.
93+
* `vpc_id` - (Optional, String, ForceNew) ID of a VPC network.
4094

4195
## Attributes Reference
4296

0 commit comments

Comments
 (0)