Skip to content

add resrouce vpn gateway, customer gateway and vpn connection #183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from Nov 13, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
## 1.22.1 (Unreleased)

FEATURES:

* **New Data Source**: `tencentcloud_vpn_gateways`
* **New Data Source**: `tencentcloud_customer_gateways`
* **New Data Source**: `tencentcloud_vpn_connections`
* **New Resource**: `tencentcloud_vpn_gateway`
* **New Resource**: `tencentcloud_customer_gateway`
* **New Resource**: `tencentcloud_vpn_connection`

BUG FIXES:
* Fixed docs of CAM

Expand All @@ -11,13 +21,17 @@ FEATURES:
* **New Data Source**: `tencentcloud_cfs_access_rules`
* **New Data Source**: `tencentcloud_scf_functions`
* **New Data Source**: `tencentcloud_scf_namespaces`
* **New Data Source**: `tencentcloud_vpn_gateways`
* **New Data Source**: `tencentcloud_customer_gateways`
* **New Data Source**: `tencentcloud_vpn_connections`
* **New Data Source**: `tencentcloud_scf_logs`
* **New Resource**: `tencentcloud_cfs_file_system`
* **New Resource**: `tencentcloud_cfs_access_group`
* **New Resource**: `tencentcloud_cfs_access_rule`
* **New Resource**: `tencentcloud_scf_function`
* **New Resource**: `tencentcloud_scf_namespace`


## 1.21.2 (October 29, 2019)

BUG FIXES:
Expand Down
65 changes: 65 additions & 0 deletions examples/tencentcloud-vpn/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

resource "tencentcloud_vpn_customer_gateway" "example" {
name = "example"
public_ip_address = "3.3.3.3"

tags = {
test = "example"
}
}

data "tencentcloud_vpc_instances" "example" {
name = "Default-VPC"
}

resource "tencentcloud_vpn_gateway" "example" {
name = "example"
vpc_id = "${data.tencentcloud_vpc_instances.example.instance_list.0.vpc_id}"
bandwidth = 5
zone = "${var.availability_zone}"

tags = {
test = "test"
}
}

resource "tencentcloud_vpn_connection" "example" {
name = "example"
vpc_id = "${data.tencentcloud_vpc_instances.example.instance_list.0.vpc_id}"
vpn_gateway_id = "${tencentcloud_vpn_gateway.example.id}"
customer_gateway_id = "${tencentcloud_vpn_customer_gateway.example.id}"
pre_share_key = "test"
ike_proto_encry_algorithm = "3DES-CBC"
ike_proto_authen_algorithm = "MD5"
ike_local_identity = "ADDRESS"
ike_local_address = "${tencentcloud_vpn_gateway.example.public_ip_address}"
ike_remote_identity = "ADDRESS"
ike_remote_address = "${tencentcloud_vpn_customer_gateway.example.public_ip_address}"
ike_dh_group_name = "GROUP1"
ike_sa_lifetime_seconds = 86400
ipsec_encrypt_algorithm = "3DES-CBC"
ipsec_integrity_algorithm = "MD5"
ipsec_sa_lifetime_seconds = 3600
ipsec_pfs_dh_group = "DH-GROUP1"
ipsec_sa_lifetime_traffic = 2560

security_group_policy {
local_cidr_block = "172.16.0.0/16"
remote_cidr_block = ["3.3.3.0/32", ]
}
tags = {
test = "test"
}
}

data "tencentcloud_vpn_customer_gateways" "example" {
id = "${tencentcloud_vpn_customer_gateway.example.id}"
}

data "tencentcloud_vpn_gateways" "example" {
id = "${tencentcloud_vpn_gateway.example.id}"
}

data "tencentcloud_vpn_connections" "example" {
id = "${tencentcloud_vpn_connection.example.id}"
}
3 changes: 3 additions & 0 deletions examples/tencentcloud-vpn/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
variable "availability_zone" {
default = "ap-guangzhou-3"
}
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVY
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8=
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8=
github.com/keegancsmith/rpc v1.1.0 h1:bXVRk3EzbtrEegTGKxNTc+St1lR7t/Z1PAO8misBnCc=
github.com/keegancsmith/rpc v1.1.0/go.mod h1:Xow74TKX34OPPiPCdz6x1o9c0SCxRqGxDuKGk7ZOo8s=
github.com/keybase/go-crypto v0.0.0-20161004153544-93f5b35093ba/go.mod h1:ghbZscTyKdM07+Fw3KSi0hcJm+AlEUWj8QLlPtijN/M=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/gotool v1.0.0 h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg=
Expand Down Expand Up @@ -570,6 +572,7 @@ golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392 h1:ACG4HJsFiNMf47Y4PeRoeb
golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3 h1:x/bBzNauLQAlE3fLku/xy92Y8QwKX5HZymrMz2IiKFc=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
Expand Down
66 changes: 40 additions & 26 deletions tencentcloud/data_source_tc_nat_gateways.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ func dataSourceTencentCloudNatGateways() *schema.Resource {
"name": {
Type: schema.TypeString,
Optional: true,
Description: "Name of the nat gateway.",
Description: "Name of the NAT gateway.",
},
"id": {
Type: schema.TypeString,
Optional: true,
Description: "ID of the nat gateway.",
Description: "ID of the NAT gateway.",
},
"result_output_file": {
Type: schema.TypeString,
Expand All @@ -51,13 +51,13 @@ func dataSourceTencentCloudNatGateways() *schema.Resource {
"nats": {
Type: schema.TypeList,
Computed: true,
Description: "Information list of the dedicated tunnels.",
Description: "Information list of the dedicated nats.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
Computed: true,
Description: "ID of the nat gateway.",
Description: "ID of the NAT gateway.",
},
"vpc_id": {
Type: schema.TypeString,
Expand All @@ -67,22 +67,22 @@ func dataSourceTencentCloudNatGateways() *schema.Resource {
"name": {
Type: schema.TypeString,
Computed: true,
Description: "Name of the nat gateway.",
Description: "Name of the NAT gateway.",
},
"state": {
Type: schema.TypeInt,
Computed: true,
Description: "State of the nat gateway.",
Description: "State of the NAT gateway.",
},
"max_concurrent": {
Type: schema.TypeInt,
Computed: true,
Description: "The upper limit of concurrent connection of nat gateway, the available values include: 1000000,3000000,10000000. Default is 1000000.",
Description: "The upper limit of concurrent connection of NAT gateway, the available values include: 1000000,3000000,10000000. Default is 1000000.",
},
"bandwidth": {
Type: schema.TypeInt,
Computed: true,
Description: "The maximum public network output bandwidth of nat gateway (unit: Mbps), the available values include: 20,50,100,200,500,1000,2000,5000. Default is 100.",
Description: "The maximum public network output bandwidth of NAT gateway (unit: Mbps), the available values include: 20,50,100,200,500,1000,2000,5000. Default is 100.",
},
"assigned_eip_set": {
Type: schema.TypeList,
Expand All @@ -93,7 +93,7 @@ func dataSourceTencentCloudNatGateways() *schema.Resource {
"create_time": {
Type: schema.TypeString,
Computed: true,
Description: "Create time of the nat gateway.",
Description: "Create time of the NAT gateway.",
},
},
},
Expand Down Expand Up @@ -126,24 +126,38 @@ func dataSourceTencentCloudNatGatewaysRead(d *schema.ResourceData, meta interfac
}
request.Filters = append(request.Filters, filter)
}
var response *vpc.DescribeNatGatewaysResponse
err := resource.Retry(readRetryTimeout, func() *resource.RetryError {
result, e := meta.(*TencentCloudClient).apiV3Conn.UseVpcClient().DescribeNatGateways(request)
if e != nil {
log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n",
logId, request.GetAction(), request.ToJsonString(), e.Error())
return retryError(e)
offset := uint64(0)
request.Offset = &offset
result := make([]*vpc.NatGateway, 0)
limit := uint64(NAT_DESCRIBE_LIMIT)
for {
var response *vpc.DescribeNatGatewaysResponse
err := resource.Retry(readRetryTimeout, func() *resource.RetryError {
result, e := meta.(*TencentCloudClient).apiV3Conn.UseVpcClient().DescribeNatGateways(request)
if e != nil {
log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n",
logId, request.GetAction(), request.ToJsonString(), e.Error())
return retryError(e)
}
response = result
return nil
})
if err != nil {
log.Printf("[CRITAL]%s read NAT gateway failed, reason:%s\n ", logId, err.Error())
return err
} else {
result = append(result, response.Response.NatGatewaySet...)
if len(response.Response.NatGatewaySet) < NAT_DESCRIBE_LIMIT {
break
} else {
offset = offset + limit
request.Offset = &offset
}
}
response = result
return nil
})
if err != nil {
log.Printf("[CRITAL]%s read nat gateway failed, reason:%s\n ", logId, err.Error())
return err
}
ids := make([]string, 0, len(response.Response.NatGatewaySet))
natList := make([]map[string]interface{}, 0, len(response.Response.NatGatewaySet))
for _, nat := range response.Response.NatGatewaySet {
ids := make([]string, 0, len(result))
natList := make([]map[string]interface{}, 0, len(result))
for _, nat := range result {
mapping := map[string]interface{}{
"id": *nat.NatGatewayId,
"vpc_id": *nat.VpcId,
Expand All @@ -159,7 +173,7 @@ func dataSourceTencentCloudNatGatewaysRead(d *schema.ResourceData, meta interfac
}
d.SetId(dataResourceIdsHash(ids))
if e := d.Set("nats", natList); e != nil {
log.Printf("[CRITAL]%s provider set clb list fail, reason:%s\n ", logId, e.Error())
log.Printf("[CRITAL]%s provider set NAT list fail, reason:%s\n ", logId, e.Error())
return e
}

Expand Down
Loading