@@ -56,6 +56,17 @@ func resourceScalewayVPCPublicGateway() *schema.Resource {
5656 Type : schema .TypeString ,
5757 },
5858 },
59+ "bastion_enabled" : {
60+ Type : schema .TypeBool ,
61+ Description : "Enable SSH bastion on the gateway" ,
62+ Optional : true ,
63+ },
64+ "bastion_port" : {
65+ Type : schema .TypeInt ,
66+ Description : "Port of the SSH bastion" ,
67+ Optional : true ,
68+ Computed : true ,
69+ },
5970 "project_id" : projectIDSchema (),
6071 "zone" : zoneSchema (),
6172 // Computed elements
@@ -86,9 +97,14 @@ func resourceScalewayVPCPublicGatewayCreate(ctx context.Context, d *schema.Resou
8697 Tags : expandStrings (d .Get ("tags" )),
8798 UpstreamDNSServers : expandStrings (d .Get ("upstream_dns_servers" )),
8899 ProjectID : d .Get ("project_id" ).(string ),
100+ EnableBastion : d .Get ("bastion_enabled" ).(bool ),
89101 Zone : zone ,
90102 }
91103
104+ if bastionPort , ok := d .GetOk ("bastion_port" ); ok {
105+ req .BastionPort = expandUint32Ptr (bastionPort .(int ))
106+ }
107+
92108 if ipID , ok := d .GetOk ("ip_id" ); ok {
93109 req .IPID = expandStringPtr (expandZonedID (ipID ).ID )
94110 }
@@ -133,6 +149,8 @@ func resourceScalewayVPCPublicGatewayRead(ctx context.Context, d *schema.Resourc
133149 _ = d .Set ("tags" , gateway .Tags )
134150 _ = d .Set ("upstream_dns_servers" , gateway .UpstreamDNSServers )
135151 _ = d .Set ("ip_id" , newZonedID (gateway .Zone , gateway .IP .ID ).String ())
152+ _ = d .Set ("bastion_enabled" , gateway .BastionEnabled )
153+ _ = d .Set ("bastion_port" , int (gateway .BastionPort ))
136154
137155 return nil
138156}
@@ -148,19 +166,34 @@ func resourceScalewayVPCPublicGatewayUpdate(ctx context.Context, d *schema.Resou
148166 return diag .FromErr (err )
149167 }
150168
151- if d .HasChanges ("name" , "tags" , "upstream_dns_servers" ) {
152- updateRequest := & vpcgw.UpdateGatewayRequest {
153- GatewayID : gateway .ID ,
154- Zone : gateway .Zone ,
155- Name : scw .StringPtr (d .Get ("name" ).(string )),
156- Tags : scw .StringsPtr (expandStrings (d .Get ("tags" ))),
157- UpstreamDNSServers : scw .StringsPtr (expandStrings (d .Get ("upstream_dns_servers" ))),
158- }
169+ updateRequest := & vpcgw.UpdateGatewayRequest {
170+ GatewayID : gateway .ID ,
171+ Zone : gateway .Zone ,
172+ }
159173
160- _ , err = vpcgwAPI .UpdateGateway (updateRequest , scw .WithContext (ctx ))
161- if err != nil {
162- return diag .FromErr (err )
163- }
174+ if d .HasChanges ("name" ) {
175+ updateRequest .Name = scw .StringPtr (d .Get ("name" ).(string ))
176+ }
177+
178+ if d .HasChange ("tags" ) {
179+ updateRequest .Tags = scw .StringsPtr (expandStrings (d .Get ("tags" )))
180+ }
181+
182+ if d .HasChange ("bastion_port" ) {
183+ updateRequest .BastionPort = scw .Uint32Ptr (uint32 (d .Get ("bastion_port" ).(int )))
184+ }
185+
186+ if d .HasChange ("enable_bastion" ) {
187+ updateRequest .EnableBastion = scw .BoolPtr (d .Get ("enable_bastion" ).(bool ))
188+ }
189+
190+ if d .HasChange ("upstream_dns_servers" ) {
191+ updateRequest .UpstreamDNSServers = scw .StringsPtr (expandStrings (d .Get ("upstream_dns_servers" )))
192+ }
193+
194+ _ , err = vpcgwAPI .UpdateGateway (updateRequest , scw .WithContext (ctx ))
195+ if err != nil {
196+ return diag .FromErr (err )
164197 }
165198
166199 _ , err = waitForVPCPublicGateway (ctx , vpcgwAPI , zone , id , d .Timeout (schema .TimeoutUpdate ))
0 commit comments