@@ -482,26 +482,32 @@ func resourceColabRuntimeTemplateCreate(d *schema.ResourceData, meta interface{}
482
482
}
483
483
d .SetId (id )
484
484
485
- err = ColabOperationWaitTime (
486
- config , res , project , "Creating RuntimeTemplate" , userAgent ,
485
+ // Use the resource in the operation response to populate
486
+ // identity fields and d.Id() before read
487
+ var opRes map [string ]interface {}
488
+ err = ColabOperationWaitTimeWithResponse (
489
+ config , res , & opRes , project , "Creating RuntimeTemplate" , userAgent ,
487
490
d .Timeout (schema .TimeoutCreate ))
488
-
489
491
if err != nil {
490
492
// The resource didn't actually create
491
493
d .SetId ("" )
494
+
492
495
return fmt .Errorf ("Error waiting to create RuntimeTemplate: %s" , err )
493
496
}
494
497
495
- // The operation for this resource contains the generated name that we need
496
- // in order to perform a READ. We need to access the object inside of it as
497
- // a map[string]interface, so let's do that.
498
+ // name is set by API when unset
499
+ if tpgresource .IsEmptyValue (reflect .ValueOf (d .Get ("name" ))) {
500
+ if err := d .Set ("name" , flattenColabRuntimeTemplateName (opRes ["name" ], d , config )); err != nil {
501
+ return fmt .Errorf (`Error setting computed identity field "name": %s` , err )
502
+ }
503
+ }
498
504
499
- resp := res ["response" ].(map [string ]interface {})
500
- name := tpgresource .GetResourceNameFromSelfLink (resp ["name" ].(string ))
501
- log .Printf ("[DEBUG] Setting resource name to %s" , name )
502
- if err := d .Set ("name" , name ); err != nil {
503
- return fmt .Errorf ("Error setting name: %s" , err )
505
+ // This may have caused the ID to update - update it if so.
506
+ id , err = tpgresource .ReplaceVars (d , config , "projects/{{project}}/locations/{{location}}/notebookRuntimeTemplates/{{name}}" )
507
+ if err != nil {
508
+ return fmt .Errorf ("Error constructing id: %s" , err )
504
509
}
510
+ d .SetId (id )
505
511
506
512
log .Printf ("[DEBUG] Finished creating RuntimeTemplate %q: %#v" , d .Id (), res )
507
513
0 commit comments