Skip to content

Commit 1399ed6

Browse files
authored
Merge pull request #679 from tencentcloudstack/fix/vpc-attach-delete-params
fix: tcr_vpc_attach - pass region_id for delete if provided
2 parents 71bc6d8 + 5c1d4dd commit 1399ed6

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

tencentcloud/resource_tc_tcr_vpc_attachment.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func resourceTencentCloudTcrVpcAttachment() *schema.Resource {
6363
"region_id": {
6464
Type: schema.TypeInt,
6565
Optional: true,
66-
Description: "Whether to enable public domain dns. Default value is `false`.",
66+
Description: "ID of region.",
6767
},
6868
"enable_public_domain_dns": {
6969
Type: schema.TypeBool,
@@ -271,6 +271,7 @@ func resourceTencentCLoudTcrVpcAttachmentDelete(d *schema.ResourceData, meta int
271271
ctx := context.WithValue(context.TODO(), logIdKey, logId)
272272

273273
resourceId := d.Id()
274+
regionId := d.Get("region_id").(int)
274275
items := strings.Split(resourceId, FILED_SP)
275276
if len(items) != 3 {
276277
return fmt.Errorf("invalid ID %s", resourceId)
@@ -285,10 +286,10 @@ func resourceTencentCLoudTcrVpcAttachmentDelete(d *schema.ResourceData, meta int
285286
var inErr, outErr error
286287
var has bool
287288

288-
outErr = tcrService.DeleteTCRVPCAttachment(ctx, instanceId, vpcId, subnetId)
289+
outErr = tcrService.DeleteTCRVPCAttachment(ctx, instanceId, vpcId, subnetId, regionId)
289290
if outErr != nil {
290291
outErr = resource.Retry(writeRetryTimeout, func() *resource.RetryError {
291-
inErr = tcrService.DeleteTCRVPCAttachment(ctx, instanceId, vpcId, subnetId)
292+
inErr = tcrService.DeleteTCRVPCAttachment(ctx, instanceId, vpcId, subnetId, regionId)
292293
if inErr != nil {
293294
return retryError(inErr)
294295
}

tencentcloud/resource_tc_tcr_vpc_attachment_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,5 @@ resource "tencentcloud_tcr_vpc_attachment" "mytcr_vpc_attachment" {
129129
instance_id = tencentcloud_tcr_instance.mytcr_instance.id
130130
vpc_id = tencentcloud_vpc.foo.id
131131
subnet_id = tencentcloud_subnet.subnet.id
132+
region_id = 1
132133
}`

tencentcloud/service_tencentcloud_tcr.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ func (me *TCRService) CreateTCRVPCAttachment(ctx context.Context, instanceId str
606606
return
607607
}
608608

609-
func (me *TCRService) DeleteTCRVPCAttachment(ctx context.Context, instanceId string, vpcId string, subnetId string) (errRet error) {
609+
func (me *TCRService) DeleteTCRVPCAttachment(ctx context.Context, instanceId string, vpcId string, subnetId string, regionId int) (errRet error) {
610610
logId := getLogId(ctx)
611611
request := tcr.NewManageInternalEndpointRequest()
612612
defer func() {
@@ -618,6 +618,7 @@ func (me *TCRService) DeleteTCRVPCAttachment(ctx context.Context, instanceId str
618618
request.VpcId = &vpcId
619619
request.SubnetId = &subnetId
620620
request.Operation = helper.String("Delete")
621+
request.RegionId = helper.IntUint64(regionId)
621622

622623
ratelimit.Check(request.GetAction())
623624
response, err := me.client.UseTCRClient().ManageInternalEndpoint(request)

website/docs/r/tcr_vpc_attachment.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ The following arguments are supported:
3030
* `vpc_id` - (Required, ForceNew) ID of VPC.
3131
* `enable_public_domain_dns` - (Optional) Whether to enable public domain dns. Default value is `false`.
3232
* `enable_vpc_domain_dns` - (Optional) Whether to enable vpc domain dns. Default value is `false`.
33+
* `region_id` - (Optional) ID of region.
3334

3435
## Attributes Reference
3536

0 commit comments

Comments
 (0)