diff --git a/.changelog/12574.txt b/.changelog/12574.txt new file mode 100644 index 00000000000..35f2e92158d --- /dev/null +++ b/.changelog/12574.txt @@ -0,0 +1,3 @@ +```release-note:bug +cloudlogging: fixed bug in `google_logging_project_bucket_config` that if providing "project" in the format of `` , the create url will contains "projects/" twice. +``` \ No newline at end of file diff --git a/google/services/logging/resource_logging_project_bucket_config.go b/google/services/logging/resource_logging_project_bucket_config.go index 8322268c6be..48c0c770921 100644 --- a/google/services/logging/resource_logging_project_bucket_config.go +++ b/google/services/logging/resource_logging_project_bucket_config.go @@ -133,15 +133,16 @@ For example: jsonPayload.request.status`, } func projectBucketConfigID(d *schema.ResourceData, config *transport_tpg.Config) (string, error) { - project := d.Get("project").(string) + projectID := d.Get("project").(string) location := d.Get("location").(string) bucketID := d.Get("bucket_id").(string) - if !strings.HasPrefix(project, "project") { - project = "projects/" + project + if strings.HasPrefix(projectID, "projects/") { + // Remove "projects/" prefix if it exists + projectID = strings.TrimPrefix(projectID, "projects/") } - id := fmt.Sprintf("%s/locations/%s/buckets/%s", project, location, bucketID) + id := fmt.Sprintf("projects/%s/locations/%s/buckets/%s", projectID, location, bucketID) return id, nil }