diff --git a/products/appengine/terraform.yaml b/products/appengine/terraform.yaml index 829d31ed1ae8..c842440ca40c 100644 --- a/products/appengine/terraform.yaml +++ b/products/appengine/terraform.yaml @@ -14,8 +14,7 @@ --- !ruby/object:Provider::Terraform::Config overrides: !ruby/object:Overrides::ResourceOverrides FirewallRule: !ruby/object:Overrides::Terraform::ResourceOverride - id_format: "{{project}}/{{priority}}" - import_format: ["{{project}}/{{priority}}"] + import_format: ["apps/{{project}}/firewall/ingressRules/{{priority}}"] examples: - !ruby/object:Provider::Terraform::Examples name: "app_engine_firewall_rule_basic" @@ -25,7 +24,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides test_env_vars: org_id: :ORG_ID StandardAppVersion: !ruby/object:Overrides::Terraform::ResourceOverride - id_format: "apps/{{project}}/services/{{service}}/versions/{{version_id}}" import_format: ["apps/{{project}}/services/{{service}}/versions/{{version_id}}"] mutex: "apps/{{project}}" parameters: @@ -73,8 +71,8 @@ overrides: !ruby/object:Overrides::ResourceOverrides exclude: true DomainMapping: !ruby/object:Overrides::Terraform::ResourceOverride self_link: 'apps/{{project}}/domainMappings/{{domain_name}}' - id_format: "{{domain_name}}" - import_format: ["{{domain_name}}"] + id_format: 'apps/{{project}}/domainMappings/{{domain_name}}' + import_format: ['apps/{{project}}/domainMappings/{{domain_name}}'] examples: - !ruby/object:Provider::Terraform::Examples name: "app_engine_domain_mapping_basic" diff --git a/products/bigquery/terraform.yaml b/products/bigquery/terraform.yaml index f1ceb67f45a6..4dfb56def1b6 100644 --- a/products/bigquery/terraform.yaml +++ b/products/bigquery/terraform.yaml @@ -15,8 +15,7 @@ legacy_name: 'bigquery' overrides: !ruby/object:Overrides::ResourceOverrides Dataset: !ruby/object:Overrides::Terraform::ResourceOverride - id_format: "{{project}}:{{dataset_id}}" - import_format: ["{{project}}:{{dataset_id}}", "{{project}}/{{dataset_id}}", "{{dataset_id}}"] + import_format: ["projects/{{project}}/datasets/{{dataset_id}}"] delete_url: projects/{{project}}/datasets/{{dataset_id}}?deleteContents={{delete_contents_on_destroy}} examples: - !ruby/object:Provider::Terraform::Examples diff --git a/products/bigtable/terraform.yaml b/products/bigtable/terraform.yaml index 6e8c7204446d..44a112c82ee1 100644 --- a/products/bigtable/terraform.yaml +++ b/products/bigtable/terraform.yaml @@ -14,7 +14,7 @@ --- !ruby/object:Provider::Terraform::Config overrides: !ruby/object:Overrides::ResourceOverrides AppProfile: !ruby/object:Overrides::Terraform::ResourceOverride - id_format: "{{project}}/{{instance}}/{{app_profile_id}}" + id_format: "projects/{{project}}/instances/{{instance}}/appProfiles/{{app_profile_id}}" import_format: ["projects/{{project}}/instances/{{instance}}/appProfiles/{{app_profile_id}}"] examples: - !ruby/object:Provider::Terraform::Examples diff --git a/products/binaryauthorization/terraform.yaml b/products/binaryauthorization/terraform.yaml index fff7c4a35222..7408351a5dc7 100644 --- a/products/binaryauthorization/terraform.yaml +++ b/products/binaryauthorization/terraform.yaml @@ -15,7 +15,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides Attestor: !ruby/object:Overrides::Terraform::ResourceOverride import_format: ["projects/{{project}}/attestors/{{name}}"] - id_format: "{{project}}/{{name}}" examples: - !ruby/object:Provider::Terraform::Examples name: "binary_authorization_attestor_basic" @@ -54,7 +53,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides attestationAuthorityNote.publicKeys.id: !ruby/object:Overrides::Terraform::PropertyOverride default_from_api: true Policy: !ruby/object:Overrides::Terraform::ResourceOverride - id_format: "{{project}}" + id_format: "projects/{{project}}" import_format: ["projects/{{project}}"] custom_code: !ruby/object:Provider::Terraform::CustomCode constants: 'templates/terraform/constants/binaryauthorization_policy.erb' diff --git a/products/cloudbuild/terraform.yaml b/products/cloudbuild/terraform.yaml index cbfbb0a330f9..1b5f5f6b81a1 100644 --- a/products/cloudbuild/terraform.yaml +++ b/products/cloudbuild/terraform.yaml @@ -17,7 +17,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides Trigger: !ruby/object:Overrides::Terraform::ResourceOverride # import by default only works with old-style self links ending in a name import_format: ["projects/{{project}}/triggers/{{trigger_id}}"] - id_format: '{{project}}/{{trigger_id}}' + id_format: 'projects/{{project}}/triggers/{{trigger_id}}' self_link: 'projects/{{project}}/triggers/{{trigger_id}}' examples: - !ruby/object:Provider::Terraform::Examples diff --git a/products/cloudfunctions/terraform.yaml b/products/cloudfunctions/terraform.yaml index 98f88077c493..ad900171f724 100644 --- a/products/cloudfunctions/terraform.yaml +++ b/products/cloudfunctions/terraform.yaml @@ -16,7 +16,7 @@ legacy_name: 'cloudfunctions' overrides: !ruby/object:Overrides::ResourceOverrides CloudFunction: !ruby/object:Overrides::Terraform::ResourceOverride legacy_name: 'google_cloudfunctions_function' - id_format: '{{project}}/{{region}}/{{cloud_function}}' + id_format: 'projects/{{project}}/locations/{{region}}/functions/{{cloud_function}}' base_url: projects/{{project}}/locations/{{region}}/functions import_format: ["projects/{{project}}/locations/{{region}}/functions/{{cloud_function}}"] exclude_resource: true diff --git a/products/cloudscheduler/terraform.yaml b/products/cloudscheduler/terraform.yaml index 8730f55d3a83..943c4c74597d 100644 --- a/products/cloudscheduler/terraform.yaml +++ b/products/cloudscheduler/terraform.yaml @@ -14,6 +14,7 @@ --- !ruby/object:Provider::Terraform::Config overrides: !ruby/object:Overrides::ResourceOverrides Job: !ruby/object:Overrides::Terraform::ResourceOverride + id_format: 'projects/{{project}}/locations/{{region}}/jobs/{{name}}' custom_code: !ruby/object:Provider::Terraform::CustomCode constants: templates/terraform/constants/scheduler_auth.erb resource_definition: templates/terraform/resource_definition/scheduler_auth.erb diff --git a/products/compute/terraform.yaml b/products/compute/terraform.yaml index 37910133e3c8..0135f4be705e 100644 --- a/products/compute/terraform.yaml +++ b/products/compute/terraform.yaml @@ -14,7 +14,6 @@ --- !ruby/object:Provider::Terraform::Config overrides: !ruby/object:Overrides::ResourceOverrides Address: !ruby/object:Overrides::Terraform::ResourceOverride - id_format: "{{project}}/{{region}}/{{name}}" examples: - !ruby/object:Provider::Terraform::Examples name: "address_basic" @@ -71,7 +70,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides custom_code: !ruby/object:Provider::Terraform::CustomCode post_create: templates/terraform/post_create/labels.erb Autoscaler: !ruby/object:Overrides::Terraform::ResourceOverride - id_format: "{{zone}}/{{name}}" examples: - !ruby/object:Provider::Terraform::Examples name: "autoscaler_single_instance" @@ -1048,7 +1046,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides Region: !ruby/object:Overrides::Terraform::ResourceOverride exclude: true RegionAutoscaler: !ruby/object:Overrides::Terraform::ResourceOverride - id_format: "{{region}}/{{name}}" examples: - !ruby/object:Provider::Terraform::Examples name: "region_autoscaler_beta" @@ -1361,7 +1358,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides `next_hop_instance`. Omit if `next_hop_instance` is specified as a URL. Router: !ruby/object:Overrides::Terraform::ResourceOverride - id_format: "{{region}}/{{name}}" mutex: router/{{region}}/{{name}} examples: - !ruby/object:Provider::Terraform::Examples diff --git a/products/containeranalysis/terraform.yaml b/products/containeranalysis/terraform.yaml index 6fcf384ae447..99a3579f59f6 100644 --- a/products/containeranalysis/terraform.yaml +++ b/products/containeranalysis/terraform.yaml @@ -14,6 +14,7 @@ --- !ruby/object:Provider::Terraform::Config overrides: !ruby/object:Overrides::ResourceOverrides Note: !ruby/object:Overrides::Terraform::ResourceOverride + id_format: "projects/{{project}}/notes/{{name}}" import_format: ["projects/{{project}}/notes/{{name}}"] custom_code: !ruby/object:Provider::Terraform::CustomCode pre_update: 'templates/terraform/pre_update/containeranalysis_note.erb' diff --git a/products/dns/terraform.yaml b/products/dns/terraform.yaml index 574d36a18baf..9074542696a3 100644 --- a/products/dns/terraform.yaml +++ b/products/dns/terraform.yaml @@ -14,6 +14,7 @@ --- !ruby/object:Provider::Terraform::Config overrides: !ruby/object:Overrides::ResourceOverrides ManagedZone: !ruby/object:Overrides::Terraform::ResourceOverride + id_format: 'projects/{{project}}/managedZones/{{name}}' examples: - !ruby/object:Provider::Terraform::Examples name: "dns_managed_zone_basic" @@ -97,6 +98,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides diff_suppress_func: 'caseDiffSuppress' custom_flatten: templates/terraform/custom_flatten/default_if_empty.erb Policy: !ruby/object:Overrides::Terraform::ResourceOverride + id_format: 'projects/{{project}}/policies/{{name}}' examples: - !ruby/object:Provider::Terraform::Examples name: "dns_policy_basic" diff --git a/products/filestore/terraform.yaml b/products/filestore/terraform.yaml index 6a4a9ca8b9df..f20a9567914f 100644 --- a/products/filestore/terraform.yaml +++ b/products/filestore/terraform.yaml @@ -19,8 +19,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides update_minutes: 6 delete_minutes: 6 autogen_async: true - id_format: "{{project}}/{{zone}}/{{name}}" - import_format: ["projects/{{project}}/locations/{{zone}}/instances/{{name}}"] examples: - !ruby/object:Provider::Terraform::Examples name: "filestore_instance_basic" diff --git a/products/pubsub/terraform.yaml b/products/pubsub/terraform.yaml index 57dec762fbe9..6c0d8fd52857 100644 --- a/products/pubsub/terraform.yaml +++ b/products/pubsub/terraform.yaml @@ -14,7 +14,6 @@ --- !ruby/object:Provider::Terraform::Config overrides: !ruby/object:Overrides::ResourceOverrides Topic: !ruby/object:Overrides::Terraform::ResourceOverride - id_format: "projects/{{project}}/topics/{{name}}" error_retry_predicates: ["pubsubTopicProjectNotReady"] iam_policy: !ruby/object:Api::Resource::IamPolicy parent_resource_attribute: 'topic' @@ -50,7 +49,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides encoder: templates/terraform/encoders/no_send_name.go.erb update_encoder: templates/terraform/update_encoder/pubsub_topic.erb Subscription: !ruby/object:Overrides::Terraform::ResourceOverride - id_format: "projects/{{project}}/subscriptions/{{name}}" examples: - !ruby/object:Provider::Terraform::Examples name: "pubsub_subscription_push" diff --git a/products/redis/terraform.yaml b/products/redis/terraform.yaml index 59eacce05ad2..291474d603d1 100644 --- a/products/redis/terraform.yaml +++ b/products/redis/terraform.yaml @@ -19,8 +19,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides update_minutes: 10 delete_minutes: 10 autogen_async: true - id_format: "{{project}}/{{region}}/{{name}}" - import_format: ["projects/{{project}}/locations/{{region}}/instances/{{name}}"] custom_code: !ruby/object:Provider::Terraform::CustomCode encoder: templates/terraform/encoders/redis_location_id_for_fallback_zone.go.erb examples: diff --git a/products/runtimeconfig/terraform.yaml b/products/runtimeconfig/terraform.yaml index 3f6a3b8ce15d..6aca227268e2 100644 --- a/products/runtimeconfig/terraform.yaml +++ b/products/runtimeconfig/terraform.yaml @@ -16,7 +16,6 @@ legacy_name: runtimeconfig overrides: !ruby/object:Overrides::ResourceOverrides Config: !ruby/object:Overrides::Terraform::ResourceOverride exclude_resource: true - id_format: 'projects/{{project}}/configs/{{config}}' import_format: ["projects/{{project}}/configs/{{config}}"] examples: - !ruby/object:Provider::Terraform::Examples diff --git a/products/securityscanner/terraform.yaml b/products/securityscanner/terraform.yaml index 66e7a5436f98..dae06d1a6e1b 100644 --- a/products/securityscanner/terraform.yaml +++ b/products/securityscanner/terraform.yaml @@ -13,7 +13,6 @@ --- !ruby/object:Provider::Terraform::Config overrides: !ruby/object:Overrides::ResourceOverrides ScanConfig: !ruby/object:Overrides::Terraform::ResourceOverride - import_format: ["{{name}}"] examples: - !ruby/object:Provider::Terraform::Examples name: "scan_config_basic" diff --git a/products/sourcerepo/terraform.yaml b/products/sourcerepo/terraform.yaml index 2c18421b498d..a03836a963ac 100644 --- a/products/sourcerepo/terraform.yaml +++ b/products/sourcerepo/terraform.yaml @@ -19,7 +19,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides exclude: false method_name_separator: ':' parent_resource_attribute: 'repository' - id_format: '{{project}}/{{name}}' examples: - !ruby/object:Provider::Terraform::Examples name: "sourcerepo_repository_basic" diff --git a/products/spanner/terraform.yaml b/products/spanner/terraform.yaml index fa7d29732465..16765e710866 100644 --- a/products/spanner/terraform.yaml +++ b/products/spanner/terraform.yaml @@ -15,7 +15,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides Database: !ruby/object:Overrides::Terraform::ResourceOverride autogen_async: true - id_format: "{{project}}/{{instance}}/{{name}}" import_format: - "projects/{{project}}/instances/{{instance}}/databases/{{name}}" - "instances/{{instance}}/databases/{{name}}" diff --git a/products/sql/terraform.yaml b/products/sql/terraform.yaml index 0488eec48868..6b217793c43b 100644 --- a/products/sql/terraform.yaml +++ b/products/sql/terraform.yaml @@ -16,12 +16,9 @@ client_name: 'SqlAdmin' overrides: !ruby/object:Overrides::ResourceOverrides Database: !ruby/object:Overrides::Terraform::ResourceOverride mutex: "google-sql-database-instance-{{project}}-{{instance}}" - id_format: "{{instance}}:{{name}}" import_format: ["projects/{{project}}/instances/{{instance}}/databases/{{name}}", "{{project}}/{{instance}}/{{name}}", "instances/{{instance}}/databases/{{name}}", - # support for a legacy import format - "{{instance}}:{{name}}", "{{instance}}/{{name}}", "{{name}}"] examples: diff --git a/products/tpu/terraform.yaml b/products/tpu/terraform.yaml index 56f9b85a58cc..857085513288 100644 --- a/products/tpu/terraform.yaml +++ b/products/tpu/terraform.yaml @@ -18,8 +18,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides insert_minutes: 15 update_minutes: 15 delete_minutes: 15 - id_format: "{{project}}/{{zone}}/{{name}}" - import_format: ["projects/{{project}}/locations/{{zone}}/nodes/{{name}}"] autogen_async: true examples: - !ruby/object:Provider::Terraform::Examples diff --git a/third_party/terraform/resources/resource_bigquery_table.go.erb b/third_party/terraform/resources/resource_bigquery_table.go.erb index ba85b62d3c39..34f0314201d3 100644 --- a/third_party/terraform/resources/resource_bigquery_table.go.erb +++ b/third_party/terraform/resources/resource_bigquery_table.go.erb @@ -479,7 +479,7 @@ func resourceBigQueryTableCreate(d *schema.ResourceData, meta interface{}) error log.Printf("[INFO] BigQuery table %s has been created", res.Id) - d.SetId(fmt.Sprintf("%s:%s.%s", res.TableReference.ProjectId, res.TableReference.DatasetId, res.TableReference.TableId)) + d.SetId(fmt.Sprintf("projects/%s/datasets/%s/tables/%s", res.TableReference.ProjectId, res.TableReference.DatasetId, res.TableReference.TableId)) return resourceBigQueryTableRead(d, meta) } @@ -847,12 +847,11 @@ type bigQueryTableId struct { } func parseBigQueryTableId(id string) (*bigQueryTableId, error) { - // Expected format is "PROJECT:DATASET.TABLE", but the project can itself have . and : in it. - // Those characters are not valid dataset or table components, so just split on the last two. - matchRegex := regexp.MustCompile("^(.+):([^:.]+)\\.([^:.]+)$") + // Expected format is "projects/{{project}}/datasets/{{dataset}}/tables/{{table}}" + matchRegex := regexp.MustCompile("^projects/(.+)/datasets/(.+)/tables/(.+)$") subMatches := matchRegex.FindStringSubmatch(id) if subMatches == nil { - return nil, fmt.Errorf("Invalid BigQuery table specifier. Expecting {project}:{dataset-id}.{table-id}, got %s", id) + return nil, fmt.Errorf("Invalid BigQuery table specifier. Expecting projects/{{project}}/datasets/{{dataset}}/tables/{{table}}, got %s", id) } return &bigQueryTableId{ Project: subMatches[1], diff --git a/third_party/terraform/resources/resource_bigtable_instance.go b/third_party/terraform/resources/resource_bigtable_instance.go index 8a5ba3976957..7c4b28ee31e5 100644 --- a/third_party/terraform/resources/resource_bigtable_instance.go +++ b/third_party/terraform/resources/resource_bigtable_instance.go @@ -131,7 +131,11 @@ func resourceBigtableInstanceCreate(d *schema.ResourceData, meta interface{}) er return fmt.Errorf("Error creating instance. %s", err) } - d.SetId(conf.InstanceID) + id, err := replaceVars(d, config, "projects/{{project}}/instances/{{name}}") + if err != nil { + return fmt.Errorf("Error constructing id: %s", err) + } + d.SetId(id) return resourceBigtableInstanceRead(d, meta) } @@ -366,7 +370,7 @@ func resourceBigtableInstanceImport(d *schema.ResourceData, meta interface{}) ([ } // Replace import id for the resource id - id, err := replaceVars(d, config, "{{name}}") + id, err := replaceVars(d, config, "projects/{{project}}/instances/{{name}}") if err != nil { return nil, fmt.Errorf("Error constructing id: %s", err) } diff --git a/third_party/terraform/resources/resource_bigtable_table.go b/third_party/terraform/resources/resource_bigtable_table.go index 0c7678cd5cac..d5b55b08b72d 100644 --- a/third_party/terraform/resources/resource_bigtable_table.go +++ b/third_party/terraform/resources/resource_bigtable_table.go @@ -111,7 +111,11 @@ func resourceBigtableTableCreate(d *schema.ResourceData, meta interface{}) error } } - d.SetId(name) + id, err := replaceVars(d, config, "projects/{{project}}/instances/{{instance_id}}/tables/{{name}}") + if err != nil { + return fmt.Errorf("Error constructing id: %s", err) + } + d.SetId(id) return resourceBigtableTableRead(d, meta) }