Skip to content

Commit fc2b236

Browse files
authored
dcx support owner (#1988)
* dcx support owner * dcx support owner
1 parent f6b8a20 commit fc2b236

File tree

4 files changed

+31
-5
lines changed

4 files changed

+31
-5
lines changed

.changelog/1988.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_dcx: support set `dc_owner_account`
3+
```

tencentcloud/resource_tc_dcx.go

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ resource "tencentcloud_dcx" "static_main" {
3434
dc_id = var.dc_id
3535
dcg_id = var.dcg_id
3636
name = "static_main"
37+
dc_owner_account = "xxxxxxxx"
3738
network_type = "VPC"
3839
route_type = "STATIC"
3940
vlan = 301
@@ -80,6 +81,13 @@ func resourceTencentCloudDcxInstance() *schema.Resource {
8081
ValidateFunc: validateStringLengthInRange(1, 60),
8182
Description: "Name of the dedicated tunnel.",
8283
},
84+
"dc_owner_account": {
85+
Type: schema.TypeString,
86+
Optional: true,
87+
ForceNew: true,
88+
Computed: true,
89+
Description: "Connection owner, who is the current customer by default. The developer account ID should be entered for shared connections.",
90+
},
8391
"network_type": {
8492
Type: schema.TypeString,
8593
Optional: true,
@@ -90,7 +98,7 @@ func resourceTencentCloudDcxInstance() *schema.Resource {
9098
},
9199
"vpc_id": {
92100
Type: schema.TypeString,
93-
Required: true,
101+
Optional: true,
94102
ForceNew: true,
95103
Description: "ID of the VPC or BMVPC.",
96104
},
@@ -185,9 +193,10 @@ func resourceTencentCloudDcxInstanceCreate(d *schema.ResourceData, meta interfac
185193
var (
186194
dcId = d.Get("dc_id").(string)
187195
name = d.Get("name").(string)
196+
dcOwnerAccount = ""
188197
networkType = d.Get("network_type").(string)
189198
networkRegion = service.client.Region
190-
vpcId = d.Get("vpc_id").(string)
199+
vpcId = ""
191200
routeType = strings.ToUpper(d.Get("route_type").(string))
192201
bgpAsn int64 = -1
193202
bgpAuthKey = ""
@@ -215,6 +224,14 @@ func resourceTencentCloudDcxInstanceCreate(d *schema.ResourceData, meta interfac
215224
bgpAuthKey = bgpKeyTemp.(string)
216225
}
217226

227+
if temp, ok := d.GetOk("dc_owner_account"); ok {
228+
dcOwnerAccount = temp.(string)
229+
}
230+
231+
if temp, ok := d.GetOk("vpc_id"); ok {
232+
vpcId = temp.(string)
233+
}
234+
218235
if temp, ok := d.GetOk("tencent_address"); ok {
219236
tencentAddress = temp.(string)
220237
}
@@ -242,7 +259,7 @@ func resourceTencentCloudDcxInstanceCreate(d *schema.ResourceData, meta interfac
242259
dcxId, err := service.CreateDirectConnectTunnel(ctx, dcId, name, networkType,
243260
networkRegion, vpcId, routeType,
244261
bgpAuthKey, tencentAddress,
245-
customerAddress, dcgId,
262+
customerAddress, dcgId, dcOwnerAccount,
246263
bgpAsn, vlan,
247264
bandwidth, routeFilterPrefixes)
248265
if err != nil {
@@ -311,6 +328,7 @@ func resourceTencentCloudDcxInstanceRead(d *schema.ResourceData, meta interface{
311328

312329
_ = d.Set("state", strings.ToUpper(service.strPt2str(item.State)))
313330
_ = d.Set("create_time", service.strPt2str(item.CreatedTime))
331+
_ = d.Set("dc_owner_account", service.strPt2str(item.DirectConnectOwnerAccount))
314332
return nil
315333
})
316334
if err != nil {

tencentcloud/service_tencentcloud_dc.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ getMoreData:
195195

196196
func (me *DcService) CreateDirectConnectTunnel(ctx context.Context, dcId, dcxName, networkType,
197197
networkRegion, vpcId, routeType, bgpAuthKey,
198-
tencentAddress, customerAddress, dcgId string,
198+
tencentAddress, customerAddress, dcgId, dcOwnerAccount string,
199199
bgpAsn, vlan, bandwidth int64,
200200
routeFilterPrefixes []string) (dcxId string, errRet error) {
201201

@@ -211,6 +211,9 @@ func (me *DcService) CreateDirectConnectTunnel(ctx context.Context, dcId, dcxNam
211211
request.DirectConnectTunnelName = &dcxName
212212
request.NetworkType = &networkType
213213
request.NetworkRegion = &networkRegion
214+
if dcOwnerAccount != "" {
215+
request.DirectConnectOwnerAccount = &dcOwnerAccount
216+
}
214217
if vpcId != "" {
215218
request.VpcId = &vpcId
216219
}

website/docs/r/dcx.html.markdown

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ resource "tencentcloud_dcx" "static_main" {
4444
dc_id = var.dc_id
4545
dcg_id = var.dcg_id
4646
name = "static_main"
47+
dc_owner_account = "xxxxxxxx"
4748
network_type = "VPC"
4849
route_type = "STATIC"
4950
vlan = 301
@@ -61,16 +62,17 @@ The following arguments are supported:
6162
* `dc_id` - (Required, String, ForceNew) ID of the DC to be queried, application deployment offline.
6263
* `dcg_id` - (Required, String, ForceNew) ID of the DC Gateway. Currently only new in the console.
6364
* `name` - (Required, String) Name of the dedicated tunnel.
64-
* `vpc_id` - (Required, String, ForceNew) ID of the VPC or BMVPC.
6565
* `bandwidth` - (Optional, Int, ForceNew) Bandwidth of the DC.
6666
* `bgp_asn` - (Optional, Int, ForceNew) BGP ASN of the user. A required field within BGP.
6767
* `bgp_auth_key` - (Optional, String, ForceNew) BGP key of the user.
6868
* `customer_address` - (Optional, String, ForceNew) Interconnect IP of the DC within client.
69+
* `dc_owner_account` - (Optional, String, ForceNew) Connection owner, who is the current customer by default. The developer account ID should be entered for shared connections.
6970
* `network_type` - (Optional, String, ForceNew) Type of the network. Valid value: `VPC`, `BMVPC` and `CCN`. The default value is `VPC`.
7071
* `route_filter_prefixes` - (Optional, Set: [`String`], ForceNew) Static route, the network address of the user IDC. It can be modified after setting but cannot be deleted. AN unable field within BGP.
7172
* `route_type` - (Optional, String, ForceNew) Type of the route, and available values include BGP and STATIC. The default value is `BGP`.
7273
* `tencent_address` - (Optional, String, ForceNew) Interconnect IP of the DC within Tencent.
7374
* `vlan` - (Optional, Int, ForceNew) Vlan of the dedicated tunnels. Valid value ranges: (0~3000). `0` means that only one tunnel can be created for the physical connect.
75+
* `vpc_id` - (Optional, String, ForceNew) ID of the VPC or BMVPC.
7476

7577
## Attributes Reference
7678

0 commit comments

Comments
 (0)