Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: added parameter region to google_vertex_ai_featurestore_entitytype #12959

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
}