diff --git a/.changelog/6588.txt b/.changelog/6588.txt new file mode 100644 index 00000000000..6c89d301f02 --- /dev/null +++ b/.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 +``` diff --git a/google/resource_vertex_ai_featurestore_entitytype.go b/google/resource_vertex_ai_featurestore_entitytype.go index b2dd2489cd1..3f018b92cfb 100644 --- a/google/resource_vertex_ai_featurestore_entitytype.go +++ b/google/resource_vertex_ai_featurestore_entitytype.go @@ -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, } @@ -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 @@ -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 @@ -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 } @@ -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 +}