@@ -148,9 +148,11 @@ func ResourceDeployment() *schema.Resource {
148148}
149149
150150func resourceDeploymentCreate (ctx context.Context , d * schema.ResourceData , meta any ) diag.Diagnostics {
151- api := NewAPI (meta )
151+ api , region , err := datawarehouseAPIWithRegion (d , meta )
152+ if err != nil {
153+ return diag .FromErr (err )
154+ }
152155
153- region := scw .Region (d .Get ("region" ).(string ))
154156 req := & datawarehouseapi.CreateDeploymentRequest {
155157 Region : region ,
156158 ProjectID : d .Get ("project_id" ).(string ),
@@ -183,18 +185,18 @@ func resourceDeploymentCreate(ctx context.Context, d *schema.ResourceData, meta
183185 return diag .FromErr (err )
184186 }
185187
186- d .SetId (deployment .ID )
188+ d .SetId (regional . NewIDString ( region , deployment .ID ) )
187189
188190 return resourceDeploymentRead (ctx , d , meta )
189191}
190192
191193func resourceDeploymentRead (ctx context.Context , d * schema.ResourceData , meta any ) diag.Diagnostics {
192- api := NewAPI (meta )
193-
194- region := scw . Region ( d . Get ( "region" ).( string ) )
195- id := d . Id ()
194+ api , region , id , err := NewAPIWithRegionAndID (meta , d . Id () )
195+ if err != nil {
196+ return diag . FromErr ( err )
197+ }
196198
197- _ , err : = waitForDatawarehouseDeployment (ctx , api , region , id , d .Timeout (schema .TimeoutRead ))
199+ _ , err = waitForDatawarehouseDeployment (ctx , api , region , id , d .Timeout (schema .TimeoutRead ))
198200 if err != nil {
199201 return diag .FromErr (err )
200202 }
@@ -213,7 +215,7 @@ func resourceDeploymentRead(ctx context.Context, d *schema.ResourceData, meta an
213215 return diag .FromErr (err )
214216 }
215217
216- _ = d .Set ("region" , string (region ))
218+ _ = d .Set ("region" , string (deployment . Region ))
217219 _ = d .Set ("project_id" , deployment .ProjectID )
218220 _ = d .Set ("name" , deployment .Name )
219221 _ = d .Set ("tags" , types .FlattenSliceString (deployment .Tags ))
@@ -237,14 +239,14 @@ func resourceDeploymentRead(ctx context.Context, d *schema.ResourceData, meta an
237239}
238240
239241func resourceDeploymentUpdate (ctx context.Context , d * schema.ResourceData , meta any ) diag.Diagnostics {
240- api := NewAPI (meta )
242+ api , region , id , err := NewAPIWithRegionAndID (meta , d .Id ())
243+ if err != nil {
244+ return diag .FromErr (err )
245+ }
241246
242247 var diags diag.Diagnostics
243248
244- region := scw .Region (d .Get ("region" ).(string ))
245- id := d .Id ()
246-
247- _ , err := waitForDatawarehouseDeployment (ctx , api , region , id , d .Timeout (schema .TimeoutUpdate ))
249+ _ , err = waitForDatawarehouseDeployment (ctx , api , region , id , d .Timeout (schema .TimeoutUpdate ))
248250 if err != nil {
249251 return diag .FromErr (err )
250252 }
@@ -315,12 +317,12 @@ func resourceDeploymentUpdate(ctx context.Context, d *schema.ResourceData, meta
315317}
316318
317319func resourceDeploymentDelete (ctx context.Context , d * schema.ResourceData , meta any ) diag.Diagnostics {
318- api := NewAPI (meta )
319-
320- region := scw . Region ( d . Get ( "region" ).( string ) )
321- id := d . Id ()
320+ api , region , id , err := NewAPIWithRegionAndID (meta , d . Id () )
321+ if err != nil {
322+ return diag . FromErr ( err )
323+ }
322324
323- _ , err : = waitForDatawarehouseDeployment (ctx , api , region , id , d .Timeout (schema .TimeoutDelete ))
325+ _ , err = waitForDatawarehouseDeployment (ctx , api , region , id , d .Timeout (schema .TimeoutDelete ))
324326 if err != nil {
325327 return diag .FromErr (err )
326328 }
0 commit comments