@@ -4,15 +4,30 @@ Provides a resource to create a NAT gateway.
44Example Usage
55
66```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+ }
1317
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+ ]
1429 tags = {
15- test = "tf "
30+ tf = "test "
1631 }
1732}
1833```
@@ -86,6 +101,12 @@ func resourceTencentCloudNatGateway() *schema.Resource {
86101 MaxItems : 10 ,
87102 Description : "EIP IP address set bound to the gateway. The value of at least 1 and at most 10." ,
88103 },
104+ "zone" : {
105+ Type : schema .TypeString ,
106+ Optional : true ,
107+ Computed : true ,
108+ Description : "The availability zone, such as `ap-guangzhou-3`." ,
109+ },
89110 "tags" : {
90111 Type : schema .TypeMap ,
91112 Optional : true ,
@@ -124,6 +145,10 @@ func resourceTencentCloudNatGatewayCreate(d *schema.ResourceData, meta interface
124145 }
125146 }
126147
148+ if v , ok := d .GetOk ("zone" ); ok {
149+ request .Zone = helper .String (v .(string ))
150+ }
151+
127152 if v := helper .GetTags (d , "tags" ); len (v ) > 0 {
128153 for tagKey , tagValue := range v {
129154 tag := vpc.Tag {
@@ -235,6 +260,7 @@ func resourceTencentCloudNatGatewayRead(d *schema.ResourceData, meta interface{}
235260 _ = d .Set ("bandwidth" , * nat .InternetMaxBandwidthOut )
236261 _ = d .Set ("created_time" , * nat .CreatedTime )
237262 _ = d .Set ("assigned_eip_set" , flattenAddressList ((* nat ).PublicIpAddressSet ))
263+ _ = d .Set ("zone" , * nat .Zone )
238264
239265 tcClient := meta .(* TencentCloudClient ).apiV3Conn
240266 tagService := & TagService {client : tcClient }
@@ -254,6 +280,14 @@ func resourceTencentCloudNatGatewayUpdate(d *schema.ResourceData, meta interface
254280 ctx := context .WithValue (context .TODO (), logIdKey , logId )
255281 vpcService := VpcService {client : meta .(* TencentCloudClient ).apiV3Conn }
256282
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+
257291 d .Partial (true )
258292 natGatewayId := d .Id ()
259293 request := vpc .NewModifyNatGatewayAttributeRequest ()
0 commit comments