Skip to content

Commit

Permalink
Add a post create
Browse files Browse the repository at this point in the history
  • Loading branch information
bcreddy-gcp committed Jan 11, 2025
1 parent 464e47b commit 8053cbd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mmv1/products/colab/RuntimeTemplate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ iam_policy:
- 'projects/{{project}}/locations/{{location}}/notebookRuntimeTemplates/{{runtime_template}}'
- '{{runtime_template}}'
custom_code:
post_create: 'templates/terraform/post_create/accesspolicy.tmpl'
post_create: 'templates/terraform/post_create/colab_runtime_template.tmpl'
examples:
- name: 'colab_runtime_template_basic'
primary_resource_id: 'runtime-template'
Expand Down
2 changes: 1 addition & 1 deletion mmv1/templates/terraform/post_create/accesspolicy.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

resp := res["response"].(map[string]interface{})
name := tpgresource.GetResourceNameFromSelfLink(resp["name"].(string))
log.Printf("[DEBUG] Setting resource name, id to %s", name)
log.Printf("[DEBUG] Setting AccessPolicy name, id to %s", name)
if err := d.Set("name", name); err != nil {
return fmt.Errorf("Error setting name: %s", err)
}
Expand Down
10 changes: 10 additions & 0 deletions mmv1/templates/terraform/post_create/colab_runtime_template.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// The operation for this resource contains the generated name that we need
// in order to perform a READ. We need to access the object inside of it as
// a map[string]interface, so let's do that.

resp := res["response"].(map[string]interface{})
name := tpgresource.GetResourceNameFromSelfLink(resp["name"].(string))
log.Printf("[DEBUG] Setting resource name, id to %s", name)
if err := d.Set("name", name); err != nil {
return fmt.Errorf("Error setting name: %s", err)
}

0 comments on commit 8053cbd

Please sign in to comment.