From ab41e3eadaca001a1f8a4d56f745d5f9938311ed Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Mon, 28 Sep 2020 18:36:43 +0000 Subject: [PATCH] replaced timestamp ids (#4018) Co-authored-by: Edward Sun Signed-off-by: Modular Magician --- .changelog/4018.txt | 3 +++ google/data_source_google_client_config.go | 3 +-- google/data_source_google_client_openid_userinfo.go | 3 +-- google/data_source_google_composer_image_versions.go | 3 +-- google/data_source_google_compute_node_types.go | 3 +-- google/data_source_google_compute_regions.go | 3 +-- google/data_source_google_compute_zones.go | 3 +-- google/data_source_google_kms_secret.go | 3 +-- google/data_source_google_kms_secret_ciphertext.go | 3 +-- google/data_source_google_monitoring_uptime_check_ips.go | 3 +-- google/data_source_google_service_account_access_token.go | 3 +-- google/data_source_google_service_account_id_token.go | 6 ++---- google/data_source_tpu_tensorflow_versions.go | 3 +-- 13 files changed, 16 insertions(+), 26 deletions(-) create mode 100644 .changelog/4018.txt diff --git a/.changelog/4018.txt b/.changelog/4018.txt new file mode 100644 index 00000000000..93c6f429276 --- /dev/null +++ b/.changelog/4018.txt @@ -0,0 +1,3 @@ +```release-note:bug +Fixed data sources with timestamp IDs + ``` diff --git a/google/data_source_google_client_config.go b/google/data_source_google_client_config.go index 68801f4b4de..96b7fc42892 100644 --- a/google/data_source_google_client_config.go +++ b/google/data_source_google_client_config.go @@ -2,7 +2,6 @@ package google import ( "fmt" - "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -38,7 +37,7 @@ func dataSourceGoogleClientConfig() *schema.Resource { func dataSourceClientConfigRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) - d.SetId(time.Now().UTC().String()) + d.SetId(fmt.Sprintf("projects/%s/regions/%s/zones/%s", config.Project, config.Region, config.Zone)) if err := d.Set("project", config.Project); err != nil { return fmt.Errorf("Error setting project: %s", err) } diff --git a/google/data_source_google_client_openid_userinfo.go b/google/data_source_google_client_openid_userinfo.go index 19829bfb713..3c0f5f6a398 100644 --- a/google/data_source_google_client_openid_userinfo.go +++ b/google/data_source_google_client_openid_userinfo.go @@ -2,7 +2,6 @@ package google import ( "fmt" - "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -33,7 +32,7 @@ func dataSourceGoogleClientOpenIDUserinfoRead(d *schema.ResourceData, meta inter if err != nil { return err } - d.SetId(time.Now().UTC().String()) + d.SetId(email) if err := d.Set("email", email); err != nil { return fmt.Errorf("Error setting email: %s", err) } diff --git a/google/data_source_google_composer_image_versions.go b/google/data_source_google_composer_image_versions.go index 0db6d77a0b7..4418980a82f 100644 --- a/google/data_source_google_composer_image_versions.go +++ b/google/data_source_google_composer_image_versions.go @@ -3,7 +3,6 @@ package google import ( "fmt" "log" - "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -84,7 +83,7 @@ func dataSourceGoogleComposerImageVersionsRead(d *schema.ResourceData, meta inte if err := d.Set("project", project); err != nil { return fmt.Errorf("Error setting project: %s", err) } - d.SetId(time.Now().UTC().String()) + d.SetId(fmt.Sprintf("projects/%s/regions/%s", project, region)) return nil } diff --git a/google/data_source_google_compute_node_types.go b/google/data_source_google_compute_node_types.go index 5625e13f516..80dc9fde736 100644 --- a/google/data_source_google_compute_node_types.go +++ b/google/data_source_google_compute_node_types.go @@ -4,7 +4,6 @@ import ( "fmt" "log" "sort" - "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "google.golang.org/api/compute/v1" @@ -69,7 +68,7 @@ func dataSourceGoogleComputeNodeTypesRead(d *schema.ResourceData, meta interface if err := d.Set("zone", zone); err != nil { return fmt.Errorf("Error setting zone: %s", err) } - d.SetId(time.Now().UTC().String()) + d.SetId(fmt.Sprintf("projects/%s/zones/%s", project, zone)) return nil } diff --git a/google/data_source_google_compute_regions.go b/google/data_source_google_compute_regions.go index ad62e9e08fc..5a3ff548b6d 100644 --- a/google/data_source_google_compute_regions.go +++ b/google/data_source_google_compute_regions.go @@ -4,7 +4,6 @@ import ( "fmt" "log" "sort" - "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -69,7 +68,7 @@ func dataSourceGoogleComputeRegionsRead(d *schema.ResourceData, meta interface{} if err := d.Set("project", project); err != nil { return fmt.Errorf("Error setting project: %s", err) } - d.SetId(time.Now().UTC().String()) + d.SetId(fmt.Sprintf("projects/%s", project)) return nil } diff --git a/google/data_source_google_compute_zones.go b/google/data_source_google_compute_zones.go index ecf97d9cf78..b486fd2a344 100644 --- a/google/data_source_google_compute_zones.go +++ b/google/data_source_google_compute_zones.go @@ -5,7 +5,6 @@ import ( "log" "sort" "strings" - "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -92,7 +91,7 @@ func dataSourceGoogleComputeZonesRead(d *schema.ResourceData, meta interface{}) if err := d.Set("project", project); err != nil { return fmt.Errorf("Error setting project: %s", err) } - d.SetId(time.Now().UTC().String()) + d.SetId(fmt.Sprintf("projects/%s/regions/%s", project, region)) return nil } diff --git a/google/data_source_google_kms_secret.go b/google/data_source_google_kms_secret.go index fc2fbd04a66..c4829469802 100644 --- a/google/data_source_google_kms_secret.go +++ b/google/data_source_google_kms_secret.go @@ -7,7 +7,6 @@ import ( "fmt" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "log" - "time" ) func dataSourceGoogleKmsSecret() *schema.Resource { @@ -78,7 +77,7 @@ func dataSourceGoogleKmsSecretRead(d *schema.ResourceData, meta interface{}) err if err := d.Set("plaintext", string(plaintext[:])); err != nil { return fmt.Errorf("Error setting plaintext: %s", err) } - d.SetId(time.Now().UTC().String()) + d.SetId(fmt.Sprintf("%s:%s", d.Get("crypto_key").(string), ciphertext)) return nil } diff --git a/google/data_source_google_kms_secret_ciphertext.go b/google/data_source_google_kms_secret_ciphertext.go index db12e101137..274de784c1a 100644 --- a/google/data_source_google_kms_secret_ciphertext.go +++ b/google/data_source_google_kms_secret_ciphertext.go @@ -6,7 +6,6 @@ import ( "encoding/base64" "fmt" "log" - "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -70,7 +69,7 @@ func dataSourceGoogleKmsSecretCiphertextRead(d *schema.ResourceData, meta interf if err := d.Set("ciphertext", encryptResponse.Ciphertext); err != nil { return fmt.Errorf("Error setting ciphertext: %s", err) } - d.SetId(time.Now().UTC().String()) + d.SetId(d.Get("crypto_key").(string)) return nil } diff --git a/google/data_source_google_monitoring_uptime_check_ips.go b/google/data_source_google_monitoring_uptime_check_ips.go index 79da6e1ee5a..7a0315562fa 100644 --- a/google/data_source_google_monitoring_uptime_check_ips.go +++ b/google/data_source_google_monitoring_uptime_check_ips.go @@ -2,7 +2,6 @@ package google import ( "fmt" - "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -56,7 +55,7 @@ func dataSourceGoogleMonitoringUptimeCheckIpsRead(d *schema.ResourceData, meta i if err := d.Set("uptime_check_ips", uptimeCheckIps); err != nil { return fmt.Errorf("Error retrieving monitoring uptime check ips: %s", err) } - d.SetId(time.Now().UTC().String()) + d.SetId("uptime_check_ips_id") return nil } diff --git a/google/data_source_google_service_account_access_token.go b/google/data_source_google_service_account_access_token.go index c2d0837be0d..335083eab48 100644 --- a/google/data_source_google_service_account_access_token.go +++ b/google/data_source_google_service_account_access_token.go @@ -5,7 +5,6 @@ import ( "log" "strings" - "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" iamcredentials "google.golang.org/api/iamcredentials/v1" @@ -80,7 +79,7 @@ func dataSourceGoogleServiceAccountAccessTokenRead(d *schema.ResourceData, meta return err } - d.SetId(time.Now().UTC().String()) + d.SetId(name) if err := d.Set("access_token", at.AccessToken); err != nil { return fmt.Errorf("Error setting access_token: %s", err) } diff --git a/google/data_source_google_service_account_id_token.go b/google/data_source_google_service_account_id_token.go index 893a4cacb0a..5af48255860 100644 --- a/google/data_source_google_service_account_id_token.go +++ b/google/data_source_google_service_account_id_token.go @@ -1,8 +1,6 @@ package google import ( - "time" - "fmt" "strings" @@ -97,7 +95,7 @@ func dataSourceGoogleServiceAccountIdTokenRead(d *schema.ResourceData, meta inte return fmt.Errorf("error calling iamcredentials.GenerateIdToken: %v", err) } - d.SetId(time.Now().UTC().String()) + d.SetId(d.Get("target_service_account").(string)) if err := d.Set("id_token", at.Token); err != nil { return fmt.Errorf("Error setting id_token: %s", err) } @@ -129,7 +127,7 @@ func dataSourceGoogleServiceAccountIdTokenRead(d *schema.ResourceData, meta inte return fmt.Errorf("unable to retrieve Token: %v", err) } - d.SetId(time.Now().UTC().String()) + d.SetId(targetAudience) if err := d.Set("id_token", idToken.AccessToken); err != nil { return fmt.Errorf("Error setting id_token: %s", err) } diff --git a/google/data_source_tpu_tensorflow_versions.go b/google/data_source_tpu_tensorflow_versions.go index f1cdf457f14..3079cdf1d78 100644 --- a/google/data_source_tpu_tensorflow_versions.go +++ b/google/data_source_tpu_tensorflow_versions.go @@ -4,7 +4,6 @@ import ( "fmt" "log" "sort" - "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -79,7 +78,7 @@ func dataSourceTpuTensorFlowVersionsRead(d *schema.ResourceData, meta interface{ if err := d.Set("project", project); err != nil { return fmt.Errorf("Error setting project: %s", err) } - d.SetId(time.Now().UTC().String()) + d.SetId(fmt.Sprintf("projects/%s/zones/%s", project, zone)) return nil }