diff --git a/mmv1/templates/terraform/custom_import/bigquery_reservation_capacity_commitment_set_id.go.erb b/mmv1/templates/terraform/custom_import/bigquery_reservation_capacity_commitment_set_id.go.erb new file mode 100644 index 000000000000..0f3665a4d3df --- /dev/null +++ b/mmv1/templates/terraform/custom_import/bigquery_reservation_capacity_commitment_set_id.go.erb @@ -0,0 +1,22 @@ +config := meta.(*transport_tpg.Config) +if err := tpgresource.ParseImportId([]string{ + "^projects/(?P[^/]+)/locations/(?P[^/]+)/capacityCommitments/(?P[^/]+)$", + "^(?P[^/]+)/(?P[^/]+)/(?P[^/]+)$", + "^(?P[^/]+)/(?P[^/]+)$", +}, d, config); err != nil { + return nil, err +} + +// Set name based on the components +if err := d.Set("name", "projects/{{project}}/locations/{{location}}/capacityCommitments/{{capacity_commitment_id}}"); err != nil { + return nil, fmt.Errorf("Error setting name: %s", err) +} + +// Replace import id for the resource id +id, err := tpgresource.ReplaceVars(d, config, d.Get("name").(string)) +if err != nil { + return nil, fmt.Errorf("Error constructing id: %s", err) +} +d.SetId(id) + +return []*schema.ResourceData{d}, nil \ No newline at end of file