@@ -383,16 +383,28 @@ func agentResource() *schema.Resource {
383
383
}
384
384
385
385
if rd .HasChange ("resources_monitoring" ) {
386
- monitors ,ok := rd .Get ("resources_monitoring" ).(* schema.Set )
386
+ rmResource ,ok := rd .Get ("resources_monitoring" ).(* schema.Set )
387
387
if ! ok {
388
- return xerrors .Errorf ("unexpected type %T for resources_monitoring.0.volume , expected []any" ,rd .Get ("resources_monitoring.0.volume " ))
388
+ return xerrors .Errorf ("unexpected type %T for resources_monitoring, expected []any" ,rd .Get ("resources_monitoring" ))
389
389
}
390
390
391
- monitor := monitors .List ()[0 ].(map [string ]any )
391
+ rmResourceAsList := rmResource .List ()
392
+ if len (rmResourceAsList )== 0 {
393
+ return xerrors .Errorf ("developer error: resources_monitoring cannot be empty" )
394
+ }
395
+ rawMonitors := rmResourceAsList [0 ]
396
+ if rawMonitors == nil {
397
+ return xerrors .Errorf ("resources_monitoring must define at least one monitor" )
398
+ }
399
+
400
+ monitors ,ok := rawMonitors .(map [string ]any )
401
+ if ! ok {
402
+ return xerrors .Errorf ("unexpected type %T for resources_monitoring.0.volume, expected []any" ,rawMonitors )
403
+ }
392
404
393
- volumes ,ok := monitor ["volume" ].(* schema.Set )
405
+ volumes ,ok := monitors ["volume" ].(* schema.Set )
394
406
if ! ok {
395
- return xerrors .Errorf ("unexpected type %T for resources_monitoring.0.volume, expected []any" ,monitor ["volume" ])
407
+ return xerrors .Errorf ("unexpected type %T for resources_monitoring.0.volume, expected []any" ,monitors ["volume" ])
396
408
}
397
409
398
410
paths := map [string ]bool {}
@@ -403,7 +415,6 @@ func agentResource() *schema.Resource {
403
415
}
404
416
405
417
// print path for debug purpose
406
-
407
418
path ,ok := obj ["path" ].(string )
408
419
if ! ok {
409
420
return xerrors .Errorf ("unexpected type %T for volume path, expected string" ,obj ["path" ])