Skip to content

Commit

Permalink
fix: added parameter region to google_vertex_ai_featurestore_entityty…
Browse files Browse the repository at this point in the history
…pe (#6588) (#12959)

* fix: added parameter region to google_vertex_ai_featurestore_entitytype

* Revert "fix: added parameter region to google_vertex_ai_featurestore_entitytype"

This reverts commit ddf67919b021469c9f3e4593426bfedd127cd6fb.

* fix: extract region from the featurestore id

* fix: add custom_import for the region field

* fix: 2nd attempt to fix the custom_import override

* fix: 3rd attempt to fix the custom_import for the region field

* fix: 4th attempt to fix the custom_import for the region field

* fix: reverted the custom_import back

* fix: use the right import code for the custom_import

Signed-off-by: Modular Magician <magic-modules@google.com>

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician committed Nov 7, 2022
1 parent 30fbef4 commit 6464764
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/6588.txt
@@ -0,0 +1,3 @@
```release-note:bug
vertex_ai: made google_vertex_ai_featurestore_entitytype always use regional endpoint corresponding to parent's region
```
33 changes: 33 additions & 0 deletions google/resource_vertex_ai_featurestore_entitytype.go
Expand Up @@ -104,6 +104,11 @@ If this is populated with [FeaturestoreMonitoringConfig.monitoring_interval] spe
Computed: true,
Description: `The timestamp of when the featurestore was last updated in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits.`,
},
"region": {
Type: schema.TypeString,
Computed: true,
Description: "The region of the EntityType.",
},
},
UseJSONNumber: true,
}
Expand Down Expand Up @@ -131,6 +136,11 @@ func resourceVertexAIFeaturestoreEntitytypeCreate(d *schema.ResourceData, meta i
obj["monitoringConfig"] = monitoringConfigProp
}

obj, err = resourceVertexAIFeaturestoreEntitytypeEncoder(d, meta, obj)
if err != nil {
return err
}

url, err := replaceVars(d, config, "{{VertexAIBasePath}}{{featurestore}}/entityTypes?entityTypeId={{name}}")
if err != nil {
return err
Expand Down Expand Up @@ -253,6 +263,11 @@ func resourceVertexAIFeaturestoreEntitytypeUpdate(d *schema.ResourceData, meta i
obj["monitoringConfig"] = monitoringConfigProp
}

obj, err = resourceVertexAIFeaturestoreEntitytypeEncoder(d, meta, obj)
if err != nil {
return err
}

url, err := replaceVars(d, config, "{{VertexAIBasePath}}{{featurestore}}/entityTypes/{{name}}")
if err != nil {
return err
Expand Down Expand Up @@ -355,6 +370,13 @@ func resourceVertexAIFeaturestoreEntitytypeImport(d *schema.ResourceData, meta i
}
d.SetId(id)

featurestore := d.Get("featurestore").(string)

re := regexp.MustCompile("^projects/(.+)/locations/(.+)/featurestores/(.+)$")
if parts := re.FindStringSubmatch(featurestore); parts != nil {
d.Set("region", parts[2])
}

return []*schema.ResourceData{d}, nil
}

Expand Down Expand Up @@ -452,3 +474,14 @@ func expandVertexAIFeaturestoreEntitytypeMonitoringConfigSnapshotAnalysis(v inte
func expandVertexAIFeaturestoreEntitytypeMonitoringConfigSnapshotAnalysisDisabled(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}

func resourceVertexAIFeaturestoreEntitytypeEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) {
if v, ok := d.GetOk("featurestore"); ok {
re := regexp.MustCompile("projects/(.+)/locations/(.+)/featurestores/(.+)$")
if parts := re.FindStringSubmatch(v.(string)); parts != nil {
d.Set("region", parts[2])
}
}

return obj, nil
}

0 comments on commit 6464764

Please sign in to comment.