@@ -3,7 +3,7 @@ Provides a resource to create a NAT gateway.
33
44Example Usage
55
6- Create a NAT gateway.
6+ Create a traditional NAT gateway.
77
88```hcl
99resource "tencentcloud_vpc" "vpc" {
@@ -34,6 +34,43 @@ resource "tencentcloud_nat_gateway" "example" {
3434}
3535```
3636
37+ Create a standard NAT gateway.
38+
39+ ```hcl
40+ resource "tencentcloud_vpc" "vpc" {
41+ cidr_block = "10.0.0.0/16"
42+ name = "tf_nat_gateway_vpc"
43+ }
44+
45+ resource "tencentcloud_eip" "eip_example1" {
46+ name = "tf_nat_gateway_eip1"
47+ }
48+
49+ resource "tencentcloud_eip" "eip_example2" {
50+ name = "tf_nat_gateway_eip2"
51+ }
52+
53+ resource "tencentcloud_nat_gateway" "example" {
54+ name = "tf_example_nat_gateway"
55+ vpc_id = tencentcloud_vpc.vpc.id
56+ assigned_eip_set = [
57+ tencentcloud_eip.eip_example1.public_ip,
58+ tencentcloud_eip.eip_example2.public_ip,
59+ ]
60+ nat_product_version = 2
61+ tags = {
62+ tf_tag_key = "tf_tag_value"
63+ }
64+ lifecycle {
65+ ignore_changes = [
66+ // standard nat will set default values for bandwidth and max_concurrent
67+ bandwidth,
68+ max_concurrent,
69+ ]
70+ }
71+ }
72+ ```
73+
3774Import
3875
3976NAT gateway can be imported using the id, e.g.
@@ -109,6 +146,20 @@ func resourceTencentCloudNatGateway() *schema.Resource {
109146 Computed : true ,
110147 Description : "The availability zone, such as `ap-guangzhou-3`." ,
111148 },
149+ "subnet_id" : {
150+ Type : schema .TypeString ,
151+ Optional : true ,
152+ Computed : true ,
153+ ForceNew : true ,
154+ Description : "Subnet of NAT." ,
155+ },
156+ "nat_product_version" : {
157+ Type : schema .TypeInt ,
158+ Optional : true ,
159+ Computed : true ,
160+ ForceNew : true ,
161+ Description : "1: traditional NAT, 2: standard NAT, default value is 1." ,
162+ },
112163 "tags" : {
113164 Type : schema .TypeMap ,
114165 Optional : true ,
@@ -151,6 +202,14 @@ func resourceTencentCloudNatGatewayCreate(d *schema.ResourceData, meta interface
151202 request .Zone = helper .String (v .(string ))
152203 }
153204
205+ if v , ok := d .GetOk ("subnet_id" ); ok {
206+ request .SubnetId = helper .String (v .(string ))
207+ }
208+
209+ if v , ok := d .GetOkExists ("nat_product_version" ); ok {
210+ request .NatProductVersion = helper .IntUint64 (v .(int ))
211+ }
212+
154213 if v := helper .GetTags (d , "tags" ); len (v ) > 0 {
155214 for tagKey , tagValue := range v {
156215 tag := vpc.Tag {
@@ -200,7 +259,7 @@ func resourceTencentCloudNatGatewayCreate(d *schema.ResourceData, meta interface
200259 result , e := meta .(* TencentCloudClient ).apiV3Conn .UseVpcClient ().DescribeNatGateways (statRequest )
201260 if e != nil {
202261 log .Printf ("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n " ,
203- logId , request .GetAction (), request .ToJsonString (), e .Error ())
262+ logId , statRequest .GetAction (), statRequest .ToJsonString (), e .Error ())
204263 return retryError (e )
205264 } else {
206265 //if not, quit
@@ -263,6 +322,12 @@ func resourceTencentCloudNatGatewayRead(d *schema.ResourceData, meta interface{}
263322 _ = d .Set ("created_time" , * nat .CreatedTime )
264323 _ = d .Set ("assigned_eip_set" , flattenAddressList ((* nat ).PublicIpAddressSet ))
265324 _ = d .Set ("zone" , * nat .Zone )
325+ if nat .SubnetId != nil {
326+ _ = d .Set ("subnet_id" , * nat .SubnetId )
327+ }
328+ if nat .NatProductVersion != nil {
329+ _ = d .Set ("nat_product_version" , * nat .NatProductVersion )
330+ }
266331
267332 tcClient := meta .(* TencentCloudClient ).apiV3Conn
268333 tagService := & TagService {client : tcClient }
0 commit comments