Skip to content

Commit

Permalink
Add post_create
Browse files Browse the repository at this point in the history
  • Loading branch information
bcreddy-gcp committed Jan 10, 2025
1 parent 7b919db commit d582945
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mmv1/products/colab/RuntimeTemplate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ iam_policy:
import_format:
- 'projects/{{project}}/locations/{{location}}/notebookRuntimeTemplates/{{runtime_template}}'
- '{{runtime_template}}'
custom_code:
post_create: 'templates/terraform/post_create/accesspolicy.tmpl'
examples:
- name: 'colab_runtime_template_basic'
primary_resource_id: 'runtime-template'
Expand All @@ -62,12 +64,11 @@ parameters:
required: true
url_param_only: true
description: 'The location for the resource: https://cloud.google.com/colab/docs/locations'
properties:
- name: 'name'
type: String
default_from_api: true
url_param_only: true
description: 'The resource name of the Runtime Template'
properties:
- name: 'displayName'
type: String
description:
Expand Down
11 changes: 11 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,11 @@
// 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 AccessPolicy name, id to %s", name)
if err := d.Set("name", name); err != nil {
return fmt.Errorf("Error setting name: %s", err)
}
d.SetId(name)

0 comments on commit d582945

Please sign in to comment.