Skip to content

Commit d355e87

Browse files
author
“guojunchu”
committed
add cfs and tcr attribute
1 parent 19bcd68 commit d355e87

File tree

4 files changed

+37
-43
lines changed

4 files changed

+37
-43
lines changed

tencentcloud/resource_tc_cfs_file_system.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,11 @@ func resourceTencentCloudCfsFileSystem() *schema.Resource {
7373
Description: "File service protocol. Valid values are `NFS` and `CIFS`. and the default is `NFS`.",
7474
},
7575
"storage_type": {
76-
Type: schema.TypeString,
77-
Optional: true,
78-
Default: CFS_STORAGETYPE_SD,
79-
ValidateFunc: validateAllowedStringValue(CFS_STORAGETYPE),
80-
ForceNew: true,
81-
Description: "File service StorageType. Valid values are `SD` and `HP`. and the default is `SD`.",
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`.",
8281
},
8382

8483
"vpc_id": {

tencentcloud/resource_tc_tcr_instance.go

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,11 @@ func resourceTencentCloudTcrInstance() *schema.Resource {
6363
Description: "The available tags within this TCR instance.",
6464
},
6565
"public_operation": {
66-
Type: schema.TypeString,
66+
Type: schema.TypeBool,
6767
Optional: true,
6868
ForceNew: true,
69-
Description: "Control public network access. Valid values are:`Create`, `Delete`.",
69+
Default: false,
70+
Description: "Control public network access.",
7071
},
7172
//Computed values
7273
"status": {
@@ -108,11 +109,13 @@ func resourceTencentCloudTcrInstanceCreate(d *schema.ResourceData, meta interfac
108109
tcrService := TCRService{client: meta.(*TencentCloudClient).apiV3Conn}
109110

110111
var (
111-
name = d.Get("name").(string)
112-
insType = d.Get("instance_type").(string)
113-
tags = helper.GetTags(d, "tags")
114-
outErr, inErr error
115-
instanceId, operation string
112+
name = d.Get("name").(string)
113+
insType = d.Get("instance_type").(string)
114+
tags = helper.GetTags(d, "tags")
115+
outErr, inErr error
116+
instanceId string
117+
instanceStatus string
118+
operation bool
116119
)
117120

118121
outErr = resource.Retry(writeRetryTimeout, func() *resource.RetryError {
@@ -134,6 +137,7 @@ func resourceTencentCloudTcrInstanceCreate(d *schema.ResourceData, meta interfac
134137
if err != nil {
135138
return retryError(err)
136139
} else if has && *instance.Status == "Running" {
140+
instanceStatus = "Running"
137141
return nil
138142
} else if !has {
139143
return resource.NonRetryableError(fmt.Errorf("create tcr instance fail"))
@@ -145,33 +149,24 @@ func resourceTencentCloudTcrInstanceCreate(d *schema.ResourceData, meta interfac
145149
if err != nil {
146150
return err
147151
}
148-
149-
outErr = resource.Retry(writeRetryTimeout, func() *resource.RetryError {
150-
if v, ok := d.GetOk("public_operation"); ok {
151-
operation = v.(string)
152-
inErr = tcrService.ManageTCRExternalEndpoint(ctx, instanceId, operation)
153-
if inErr != nil {
154-
return retryError(inErr)
155-
}
156-
}
157-
return nil
158-
})
159-
if outErr != nil {
160-
return outErr
161-
}
162-
163-
outErr = resource.Retry(writeRetryTimeout, func() *resource.RetryError {
164-
if v, ok := d.GetOk("public_operation"); ok {
165-
operation = v.(string)
166-
inErr = tcrService.ManageTCRExternalEndpoint(ctx, instanceId, operation)
167-
if inErr != nil {
168-
return retryError(inErr)
152+
if instanceStatus == "Running" {
153+
outErr = resource.Retry(writeRetryTimeout, func() *resource.RetryError {
154+
if v, ok := d.GetOk("public_operation"); ok {
155+
operation = v.(bool)
156+
if operation {
157+
inErr = tcrService.ManageTCRExternalEndpoint(ctx, instanceId, "Create")
158+
} else {
159+
inErr = tcrService.ManageTCRExternalEndpoint(ctx, instanceId, "Delete")
160+
}
161+
if inErr != nil {
162+
return retryError(inErr)
163+
}
169164
}
165+
return nil
166+
})
167+
if outErr != nil {
168+
return outErr
170169
}
171-
return nil
172-
})
173-
if outErr != nil {
174-
return outErr
175170
}
176171

177172
return resourceTencentCloudTcrInstanceRead(d, meta)
@@ -221,9 +216,9 @@ func resourceTencentCloudTcrInstanceRead(d *schema.ResourceData, meta interface{
221216
return nil
222217
}
223218
if publicStatus == "Opening" || publicStatus == "Opened" {
224-
_ = d.Set("public_operation", "Create")
219+
_ = d.Set("public_operation", true)
225220
} else if publicStatus == "Closed" {
226-
_ = d.Set("public_operation", "Delete")
221+
_ = d.Set("public_operation", false)
227222
}
228223

229224
_ = d.Set("name", instance.RegistryName)

tencentcloud/resource_tc_tcr_instance_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ resource "tencentcloud_tcr_instance" "mytcr_instance" {
9696
name = "testacctcrinstance1"
9797
instance_type = "basic"
9898
delete_bucket = true
99-
public_operation = "Create"
99+
public_operation = false
100100
101101
tags ={
102102
test = "test"
@@ -108,7 +108,7 @@ resource "tencentcloud_tcr_instance" "mytcr_instance" {
108108
name = "testacctcrinstance2"
109109
instance_type = "basic"
110110
delete_bucket = true
111-
public_operation = "Create"
111+
public_operation = true
112112
tags ={
113113
tf = "tf"
114114
}

website/docs/r/tcr_instance.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ The following arguments are supported:
3131
* `instance_type` - (Required, ForceNew) TCR types. Valid values are: `standard`, `basic`, `premium`.
3232
* `name` - (Required, ForceNew) Name of the TCR instance.
3333
* `delete_bucket` - (Optional) Indicate to delete the COS bucket which is auto-created with the instance or not.
34-
* `public_operation` - (Optional, ForceNew) Control public network access. Valid values are:`Create`, `Delete`.
34+
* `public_operation` - (Optional, ForceNew) Control public network access.
3535
* `tags` - (Optional, ForceNew) The available tags within this TCR instance.
3636

3737
## Attributes Reference

0 commit comments

Comments
 (0)