@@ -383,16 +383,28 @@ func agentResource() *schema.Resource {
383383}
384384
385385if rd .HasChange ("resources_monitoring" ) {
386- monitors ,ok := rd .Get ("resources_monitoring" ).(* schema.Set )
386+ rmResource ,ok := rd .Get ("resources_monitoring" ).(* schema.Set )
387387if ! 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" ))
389389}
390390
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+ }
392404
393- volumes ,ok := monitor ["volume" ].(* schema.Set )
405+ volumes ,ok := monitors ["volume" ].(* schema.Set )
394406if ! 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" ])
396408}
397409
398410paths := map [string ]bool {}
@@ -403,7 +415,6 @@ func agentResource() *schema.Resource {
403415}
404416
405417// print path for debug purpose
406-
407418path ,ok := obj ["path" ].(string )
408419if ! ok {
409420return xerrors .Errorf ("unexpected type %T for volume path, expected string" ,obj ["path" ])