@@ -45,6 +45,11 @@ func resourceScalewayLb() *schema.Resource {
4545 Computed : true ,
4646 Description : "Name of the lb" ,
4747 },
48+ "description" : {
49+ Type : schema .TypeString ,
50+ Optional : true ,
51+ Description : "The description of the lb" ,
52+ },
4853 "type" : {
4954 Type : schema .TypeString ,
5055 Required : true ,
@@ -115,6 +120,18 @@ func resourceScalewayLb() *schema.Resource {
115120 },
116121 },
117122 },
123+ "ssl_compatibility_level" : {
124+ Type : schema .TypeString ,
125+ Optional : true ,
126+ Description : "Enforces minimal SSL version (in SSL/TLS offloading context)" ,
127+ Default : lbSDK .SSLCompatibilityLevelSslCompatibilityLevelIntermediate .String (),
128+ ValidateFunc : validation .StringInSlice ([]string {
129+ lbSDK .SSLCompatibilityLevelSslCompatibilityLevelUnknown .String (),
130+ lbSDK .SSLCompatibilityLevelSslCompatibilityLevelIntermediate .String (),
131+ lbSDK .SSLCompatibilityLevelSslCompatibilityLevelModern .String (),
132+ lbSDK .SSLCompatibilityLevelSslCompatibilityLevelOld .String (),
133+ }, false ),
134+ },
118135 "region" : regionComputedSchema (),
119136 "zone" : zoneSchema (),
120137 "organization_id" : organizationIDSchema (),
@@ -130,11 +147,13 @@ func resourceScalewayLbCreate(ctx context.Context, d *schema.ResourceData, meta
130147 }
131148
132149 createReq := & lbSDK.ZonedAPICreateLBRequest {
133- Zone : zone ,
134- IPID : expandStringPtr (expandID (d .Get ("ip_id" ))),
135- ProjectID : expandStringPtr (d .Get ("project_id" )),
136- Name : expandOrGenerateString (d .Get ("name" ), "lb" ),
137- Type : d .Get ("type" ).(string ),
150+ Zone : zone ,
151+ IPID : expandStringPtr (expandID (d .Get ("ip_id" ))),
152+ ProjectID : expandStringPtr (d .Get ("project_id" )),
153+ Name : expandOrGenerateString (d .Get ("name" ), "lb" ),
154+ Description : d .Get ("description" ).(string ),
155+ Type : d .Get ("type" ).(string ),
156+ SslCompatibilityLevel : lbSDK .SSLCompatibilityLevel (* expandStringPtr (d .Get ("ssl_compatibility_level" ))),
138157 }
139158
140159 if raw , ok := d .GetOk ("tags" ); ok {
@@ -199,6 +218,7 @@ func resourceScalewayLbRead(ctx context.Context, d *schema.ResourceData, meta in
199218
200219 _ = d .Set ("release_ip" , false )
201220 _ = d .Set ("name" , lb .Name )
221+ _ = d .Set ("description" , lb .Description )
202222 _ = d .Set ("zone" , lb .Zone .String ())
203223 _ = d .Set ("region" , region .String ())
204224 _ = d .Set ("organization_id" , lb .OrganizationID )
@@ -208,6 +228,7 @@ func resourceScalewayLbRead(ctx context.Context, d *schema.ResourceData, meta in
208228 _ = d .Set ("type" , strings .ToUpper (lb .Type ))
209229 _ = d .Set ("ip_id" , newZonedIDString (zone , lb .IP [0 ].ID ))
210230 _ = d .Set ("ip_address" , lb .IP [0 ].IPAddress )
231+ _ = d .Set ("ssl_compatibility_level" , lb .SslCompatibilityLevel .String ())
211232
212233 // retrieve attached private networks
213234 privateNetworks , err := waitForLBPN (ctx , lbAPI , zone , ID , d .Timeout (schema .TimeoutRead ))
@@ -229,6 +250,41 @@ func resourceScalewayLbUpdate(ctx context.Context, d *schema.ResourceData, meta
229250 return diag .FromErr (err )
230251 }
231252
253+ req := & lbSDK.ZonedAPIUpdateLBRequest {
254+ Zone : zone ,
255+ LBID : ID ,
256+ }
257+
258+ hasChanged := false
259+
260+ if d .HasChanges ("name" , "tags" ) {
261+ req .Name = d .Get ("name" ).(string )
262+ req .Tags = expandStrings (d .Get ("tags" ))
263+ hasChanged = true
264+ }
265+
266+ if d .HasChange ("description" ) {
267+ req .Description = d .Get ("description" ).(string )
268+ hasChanged = true
269+ }
270+
271+ if d .HasChange ("ssl_compatibility_level" ) {
272+ req .SslCompatibilityLevel = lbSDK .SSLCompatibilityLevel (* expandStringPtr (d .Get ("ssl_compatibility_level" )))
273+ hasChanged = true
274+ }
275+
276+ if hasChanged {
277+ _ , err = lbAPI .UpdateLB (req , scw .WithContext (ctx ))
278+ if err != nil && ! is404Error (err ) {
279+ return diag .FromErr (err )
280+ }
281+
282+ _ , err = waitForLB (ctx , lbAPI , zone , ID , d .Timeout (schema .TimeoutUpdate ))
283+ if err != nil && ! is404Error (err ) {
284+ return diag .FromErr (err )
285+ }
286+ }
287+
232288 if d .HasChange ("type" ) {
233289 lbType := d .Get ("type" ).(string )
234290 migrateReq := & lbSDK.ZonedAPIMigrateLBRequest {
@@ -248,28 +304,16 @@ func resourceScalewayLbUpdate(ctx context.Context, d *schema.ResourceData, meta
248304 }
249305 }
250306
251- if d .HasChanges ("name" , "tags" ) {
252- req := & lbSDK.ZonedAPIUpdateLBRequest {
253- Zone : zone ,
254- LBID : ID ,
255- Name : d .Get ("name" ).(string ),
256- Tags : expandStrings (d .Get ("tags" )),
257- }
258-
259- _ , err = waitForLB (ctx , lbAPI , zone , ID , d .Timeout (schema .TimeoutUpdate ))
260- if err != nil && ! is404Error (err ) {
261- return diag .FromErr (err )
262- }
263-
264- _ , err = lbAPI .UpdateLB (req , scw .WithContext (ctx ))
265- if err != nil && ! is404Error (err ) {
266- return diag .FromErr (err )
267- }
268- }
269307 ////
270308 // Attach / Detach Private Networks
271309 ////
272310 if d .HasChange ("private_network" ) {
311+ // check current lb stability state
312+ _ , err = waitForLB (ctx , lbAPI , zone , ID , d .Timeout (schema .TimeoutUpdate ))
313+ if err != nil {
314+ return diag .FromErr (err )
315+ }
316+
273317 // check that pns are in a stable state
274318 pns , err := waitForLBPN (ctx , lbAPI , zone , ID , d .Timeout (schema .TimeoutUpdate ))
275319 if err != nil && ! is404Error (err ) {
0 commit comments