diff --git a/.changelog/4262.txt b/.changelog/4262.txt new file mode 100644 index 0000000000..3eb7d39ecb --- /dev/null +++ b/.changelog/4262.txt @@ -0,0 +1,3 @@ +```release-note:bug +datacatalog: fixed permadiff on import for tags with a taxonomy set in config. +``` diff --git a/google-beta/resource_data_catalog_policy_tag.go b/google-beta/resource_data_catalog_policy_tag.go index 186417971c..fe1831f75d 100644 --- a/google-beta/resource_data_catalog_policy_tag.go +++ b/google-beta/resource_data_catalog_policy_tag.go @@ -296,12 +296,14 @@ func resourceDataCatalogPolicyTagDelete(d *schema.ResourceData, meta interface{} func resourceDataCatalogPolicyTagImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { config := meta.(*Config) - // current import_formats can't import fields with forward slashes in their value - if err := parseImportId([]string{"(?P.+)"}, d, config); err != nil { + if err := parseImportId([]string{ + "(?Pprojects/[^/]+/locations/[^/]+/taxonomies/[^/]+)/policyTags/(?P.+)"}, d, config); err != nil { return nil, err } - name := d.Get("name").(string) + originalName := d.Get("name").(string) + originalTaxonomy := d.Get("taxonomy").(string) + name := fmt.Sprintf("%s/policyTags/%s", originalTaxonomy, originalName) if err := d.Set("name", name); err != nil { return nil, fmt.Errorf("Error setting name: %s", err) diff --git a/google-beta/resource_data_catalog_taxonomy.go b/google-beta/resource_data_catalog_taxonomy.go index 8eca7e5040..38fffcb0fb 100644 --- a/google-beta/resource_data_catalog_taxonomy.go +++ b/google-beta/resource_data_catalog_taxonomy.go @@ -324,12 +324,14 @@ func resourceDataCatalogTaxonomyDelete(d *schema.ResourceData, meta interface{}) func resourceDataCatalogTaxonomyImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { config := meta.(*Config) - // current import_formats can't import fields with forward slashes in their value - if err := parseImportId([]string{"(?P.+)"}, d, config); err != nil { + if err := parseImportId([]string{ + "(?Pprojects/[^/]+/locations/[^/]+/taxonomies/[^/]+)/policyTags/(?P.+)"}, d, config); err != nil { return nil, err } - name := d.Get("name").(string) + originalName := d.Get("name").(string) + originalTaxonomy := d.Get("taxonomy").(string) + name := fmt.Sprintf("%s/policyTags/%s", originalTaxonomy, originalName) if err := d.Set("name", name); err != nil { return nil, fmt.Errorf("Error setting name: %s", err)