Skip to content

Commit 7540508

Browse files
author
“guojunchu”
committed
update tcr open_public_operation
1 parent 841cc9d commit 7540508

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

tencentcloud/resource_tc_tcr_instance.go

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ func resourceTencentCloudTcrInstance() *schema.Resource {
6565
"open_public_operation": {
6666
Type: schema.TypeBool,
6767
Optional: true,
68-
ForceNew: true,
6968
Default: false,
7069
Description: "Control public network access.",
7170
},
@@ -240,6 +239,36 @@ func resourceTencentCloudTcrInstanceRead(d *schema.ResourceData, meta interface{
240239
func resourceTencentCloudTcrInstanceUpdate(d *schema.ResourceData, meta interface{}) error {
241240
defer logElapsed("resource.tencentcloud_tcr_instance.update")()
242241
//delete_bucket
242+
var (
243+
outErr, inErr error
244+
instanceId string
245+
operation bool
246+
)
247+
248+
logId := getLogId(contextNil)
249+
ctx := context.WithValue(context.TODO(), logIdKey, logId)
250+
tcrService := TCRService{client: meta.(*TencentCloudClient).apiV3Conn}
251+
instanceId = d.Id()
252+
if d.HasChange("open_public_operation") {
253+
operation = d.Get("open_public_operation").(bool)
254+
outErr = resource.Retry(writeRetryTimeout, func() *resource.RetryError {
255+
if v, ok := d.GetOk("open_public_operation"); ok {
256+
operation = v.(bool)
257+
if operation {
258+
inErr = tcrService.ManageTCRExternalEndpoint(ctx, instanceId, "Create")
259+
} else {
260+
inErr = tcrService.ManageTCRExternalEndpoint(ctx, instanceId, "Delete")
261+
}
262+
if inErr != nil {
263+
return retryError(inErr)
264+
}
265+
}
266+
return nil
267+
})
268+
if outErr != nil {
269+
return outErr
270+
}
271+
}
243272
return resourceTencentCloudTcrInstanceRead(d, meta)
244273
}
245274

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-
* `open_public_operation` - (Optional, ForceNew) Control public network access.
34+
* `open_public_operation` - (Optional) Control public network access.
3535
* `tags` - (Optional, ForceNew) The available tags within this TCR instance.
3636

3737
## Attributes Reference

0 commit comments

Comments
 (0)