@@ -143,6 +143,11 @@ func resourceCloudstackSnapshotPolicyCreate(d *schema.ResourceData, meta interfa
143143
144144 log .Printf ("[DEBUG] Snapshot policy created with ID: %s" , d .Id ())
145145
146+ // Set tags if provided
147+ if err := setTags (cs , d , "SnapshotPolicy" ); err != nil {
148+ return fmt .Errorf ("Error setting tags on snapshot policy %s: %s" , d .Id (), err )
149+ }
150+
146151 return resourceCloudstackSnapshotPolicyRead (d , meta )
147152}
148153
@@ -190,6 +195,13 @@ func resourceCloudstackSnapshotPolicyRead(d *schema.ResourceData, meta interface
190195 d .Set ("zone_ids" , nil )
191196 }
192197
198+ // Handle tags
199+ tags := make (map [string ]interface {})
200+ for _ , tag := range snapshotPolicy .Tags {
201+ tags [tag .Key ] = tag .Value
202+ }
203+ d .Set ("tags" , tags )
204+
193205 return nil
194206}
195207
@@ -203,7 +215,18 @@ func resourceCloudstackSnapshotPolicyUpdate(d *schema.ResourceData, meta interfa
203215 }
204216
205217 _ , err := cs .Snapshot .UpdateSnapshotPolicy (p )
206- return err
218+ if err != nil {
219+ return err
220+ }
221+
222+ // Handle tags
223+ if d .HasChange ("tags" ) {
224+ if err := updateTags (cs , d , "SnapshotPolicy" ); err != nil {
225+ return fmt .Errorf ("Error updating tags on snapshot policy %s: %s" , d .Id (), err )
226+ }
227+ }
228+
229+ return resourceCloudstackSnapshotPolicyRead (d , meta )
207230}
208231
209232func resourceCloudstackSnapshotPolicyDelete (d * schema.ResourceData , meta interface {}) error {
0 commit comments