@@ -4,15 +4,30 @@ Provides a resource to create a NAT gateway.
4
4
Example Usage
5
5
6
6
```hcl
7
- resource "tencentcloud_nat_gateway" "foo" {
8
- name = "test_nat_gateway"
9
- vpc_id = "vpc-4xxr2cy7"
10
- bandwidth = 100
11
- max_concurrent = 1000000
12
- assigned_eip_set = ["1.1.1.1"]
7
+ data "tencentcloud_vpc_instances" "foo" {
8
+ name = "Default-VPC"
9
+ }
10
+ # Create EIP
11
+ resource "tencentcloud_eip" "eip_dev_dnat" {
12
+ name = "terraform_nat_test"
13
+ }
14
+ resource "tencentcloud_eip" "new_eip" {
15
+ name = "terraform_nat_test"
16
+ }
13
17
18
+ resource "tencentcloud_nat_gateway" "my_nat" {
19
+ vpc_id = data.tencentcloud_vpc_instances.foo.instance_list.0.vpc_id
20
+ name = "new_name"
21
+ max_concurrent = 10000000
22
+ bandwidth = 1000
23
+ zone = "ap-guangzhou-3"
24
+
25
+ assigned_eip_set = [
26
+ tencentcloud_eip.eip_dev_dnat.public_ip,
27
+ tencentcloud_eip.new_eip.public_ip,
28
+ ]
14
29
tags = {
15
- test = "tf "
30
+ tf = "test "
16
31
}
17
32
}
18
33
```
@@ -86,6 +101,12 @@ func resourceTencentCloudNatGateway() *schema.Resource {
86
101
MaxItems : 10 ,
87
102
Description : "EIP IP address set bound to the gateway. The value of at least 1 and at most 10." ,
88
103
},
104
+ "zone" : {
105
+ Type : schema .TypeString ,
106
+ Optional : true ,
107
+ Computed : true ,
108
+ Description : "The availability zone, such as `ap-guangzhou-3`." ,
109
+ },
89
110
"tags" : {
90
111
Type : schema .TypeMap ,
91
112
Optional : true ,
@@ -124,6 +145,10 @@ func resourceTencentCloudNatGatewayCreate(d *schema.ResourceData, meta interface
124
145
}
125
146
}
126
147
148
+ if v , ok := d .GetOk ("zone" ); ok {
149
+ request .Zone = helper .String (v .(string ))
150
+ }
151
+
127
152
if v := helper .GetTags (d , "tags" ); len (v ) > 0 {
128
153
for tagKey , tagValue := range v {
129
154
tag := vpc.Tag {
@@ -235,6 +260,7 @@ func resourceTencentCloudNatGatewayRead(d *schema.ResourceData, meta interface{}
235
260
_ = d .Set ("bandwidth" , * nat .InternetMaxBandwidthOut )
236
261
_ = d .Set ("created_time" , * nat .CreatedTime )
237
262
_ = d .Set ("assigned_eip_set" , flattenAddressList ((* nat ).PublicIpAddressSet ))
263
+ _ = d .Set ("zone" , * nat .Zone )
238
264
239
265
tcClient := meta .(* TencentCloudClient ).apiV3Conn
240
266
tagService := & TagService {client : tcClient }
@@ -254,6 +280,14 @@ func resourceTencentCloudNatGatewayUpdate(d *schema.ResourceData, meta interface
254
280
ctx := context .WithValue (context .TODO (), logIdKey , logId )
255
281
vpcService := VpcService {client : meta .(* TencentCloudClient ).apiV3Conn }
256
282
283
+ immutableArgs := []string {"zone" }
284
+
285
+ for _ , v := range immutableArgs {
286
+ if d .HasChange (v ) {
287
+ return fmt .Errorf ("argument `%s` cannot be changed" , v )
288
+ }
289
+ }
290
+
257
291
d .Partial (true )
258
292
natGatewayId := d .Id ()
259
293
request := vpc .NewModifyNatGatewayAttributeRequest ()
0 commit comments