@@ -104,7 +104,7 @@ func resourceConfigurationV2() *schema.Resource {
104104 Schema : map [string ]* schema.Schema {
105105 "telemetry_type" : {
106106 Type : schema .TypeString ,
107- Required : true ,
107+ Optional : true ,
108108 ForceNew : false ,
109109 Description : "The telemetry type to route. Valid route types include 'logs', 'metrics', or 'traces' 'logs+metrics', 'logs+traces', 'metrics+traces', 'logs+metrics+traces'." ,
110110 ValidateFunc : func (val any , _ string ) (warns []string , errs []error ) {
@@ -114,25 +114,14 @@ func resourceConfigurationV2() *schema.Resource {
114114 }
115115 return
116116 },
117+ Default : component .RouteTypeLogsMetricsTraces ,
117118 },
118119 "components" : {
119120 Type : schema .TypeList ,
120121 Required : true ,
121122 ForceNew : false ,
122123 Elem : & schema.Schema {Type : schema .TypeString },
123124 Description : "List of component names to route." ,
124- ValidateFunc : func (val any , _ string ) (warns []string , errs []error ) {
125- rawComponents := val .([]any )
126- components := []string {}
127- for _ , c := range rawComponents {
128- components = append (components , c .(string ))
129- }
130- validationErrors := component .ValidateRouteComponents (components )
131- if len (validationErrors ) > 0 {
132- errs = append (errs , validationErrors ... )
133- }
134- return
135- },
136125 },
137126 },
138127 },
@@ -310,13 +299,16 @@ func resourceConfigurationV2Create(d *schema.ResourceData, meta any) error {
310299 routes := & model.Routes {}
311300 if rawRoutes := sourcesRaw ["route" ].([]any ); v != nil {
312301 for _ , r := range rawRoutes {
313- telemetryType := r .(map [string ]any )["telemetry_type" ].(string )
314302 rawComponents := r .(map [string ]any )["components" ].([]any )
315303 components := []model.ComponentPath {}
316304 for _ , c := range rawComponents {
317305 components = append (components , model .ComponentPath (c .(string )))
318306 }
307+ if err := component .ValidateRouteComponents (components ); err != nil {
308+ return fmt .Errorf ("validate route components: %v" , err )
309+ }
319310
311+ telemetryType := r .(map [string ]any )["telemetry_type" ].(string )
320312 switch telemetryType {
321313 case "logs" :
322314 routes .Logs = append (routes .Logs , model.Route {
0 commit comments