@@ -68,6 +68,14 @@ func resourceScalewayInstanceVolume() *schema.Resource {
68
68
Computed : true ,
69
69
Description : "The server associated with this volume" ,
70
70
},
71
+ "tags" : {
72
+ Type : schema .TypeList ,
73
+ Elem : & schema.Schema {
74
+ Type : schema .TypeString ,
75
+ },
76
+ Optional : true ,
77
+ Description : "The tags associated with the volume" ,
78
+ },
71
79
"organization_id" : organizationIDSchema (),
72
80
"project_id" : projectIDSchema (),
73
81
"zone" : zoneSchema (),
@@ -86,6 +94,7 @@ func resourceScalewayInstanceVolumeCreate(ctx context.Context, d *schema.Resourc
86
94
Name : expandOrGenerateString (d .Get ("name" ), "vol" ),
87
95
VolumeType : instance .VolumeVolumeType (d .Get ("type" ).(string )),
88
96
Project : expandStringPtr (d .Get ("project_id" )),
97
+ Tags : expandStrings (d .Get ("tags" )),
89
98
}
90
99
91
100
if size , ok := d .GetOk ("size_in_gb" ); ok {
@@ -134,6 +143,7 @@ func resourceScalewayInstanceVolumeRead(ctx context.Context, d *schema.ResourceD
134
143
_ = d .Set ("project_id" , res .Volume .Project )
135
144
_ = d .Set ("zone" , string (zone ))
136
145
_ = d .Set ("type" , res .Volume .VolumeType .String ())
146
+ _ = d .Set ("tags" , res .Volume .Tags )
137
147
138
148
_ , fromVolume := d .GetOk ("from_volume_id" )
139
149
_ , fromSnapshot := d .GetOk ("from_snapshot_id" )
@@ -156,17 +166,18 @@ func resourceScalewayInstanceVolumeUpdate(ctx context.Context, d *schema.Resourc
156
166
return diag .FromErr (err )
157
167
}
158
168
169
+ req := & instance.UpdateVolumeRequest {
170
+ VolumeID : id ,
171
+ Zone : zone ,
172
+ }
173
+
159
174
if d .HasChange ("name" ) {
160
175
newName := d .Get ("name" ).(string )
176
+ req .Name = & newName
177
+ }
161
178
162
- _ , err = instanceAPI .UpdateVolume (& instance.UpdateVolumeRequest {
163
- VolumeID : id ,
164
- Zone : zone ,
165
- Name : & newName ,
166
- }, scw .WithContext (ctx ))
167
- if err != nil {
168
- return diag .FromErr (fmt .Errorf ("couldn't update volume: %s" , err ))
169
- }
179
+ if d .HasChange ("tags" ) {
180
+ req .Tags = scw .StringsPtr (expandStrings (d .Get ("tags" )))
170
181
}
171
182
172
183
if d .HasChange ("size_in_gb" ) {
@@ -204,6 +215,11 @@ func resourceScalewayInstanceVolumeUpdate(ctx context.Context, d *schema.Resourc
204
215
}
205
216
}
206
217
218
+ _ , err = instanceAPI .UpdateVolume (req , scw .WithContext (ctx ))
219
+ if err != nil {
220
+ return diag .FromErr (fmt .Errorf ("couldn't update volume: %s" , err ))
221
+ }
222
+
207
223
return resourceScalewayInstanceVolumeRead (ctx , d , meta )
208
224
}
209
225
0 commit comments