@@ -56,6 +56,17 @@ func resourceScalewayVPCPublicGateway() *schema.Resource {
56
56
Type : schema .TypeString ,
57
57
},
58
58
},
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
+ },
59
70
"project_id" : projectIDSchema (),
60
71
"zone" : zoneSchema (),
61
72
// Computed elements
@@ -86,9 +97,14 @@ func resourceScalewayVPCPublicGatewayCreate(ctx context.Context, d *schema.Resou
86
97
Tags : expandStrings (d .Get ("tags" )),
87
98
UpstreamDNSServers : expandStrings (d .Get ("upstream_dns_servers" )),
88
99
ProjectID : d .Get ("project_id" ).(string ),
100
+ EnableBastion : d .Get ("bastion_enabled" ).(bool ),
89
101
Zone : zone ,
90
102
}
91
103
104
+ if bastionPort , ok := d .GetOk ("bastion_port" ); ok {
105
+ req .BastionPort = expandUint32Ptr (bastionPort .(int ))
106
+ }
107
+
92
108
if ipID , ok := d .GetOk ("ip_id" ); ok {
93
109
req .IPID = expandStringPtr (expandZonedID (ipID ).ID )
94
110
}
@@ -133,6 +149,8 @@ func resourceScalewayVPCPublicGatewayRead(ctx context.Context, d *schema.Resourc
133
149
_ = d .Set ("tags" , gateway .Tags )
134
150
_ = d .Set ("upstream_dns_servers" , gateway .UpstreamDNSServers )
135
151
_ = 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 ))
136
154
137
155
return nil
138
156
}
@@ -148,19 +166,34 @@ func resourceScalewayVPCPublicGatewayUpdate(ctx context.Context, d *schema.Resou
148
166
return diag .FromErr (err )
149
167
}
150
168
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
+ }
159
173
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 )
164
197
}
165
198
166
199
_ , err = waitForVPCPublicGateway (ctx , vpcgwAPI , zone , id , d .Timeout (schema .TimeoutUpdate ))
0 commit comments