Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replaced timestamp ids in 12 data sources #7375

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/4018.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
Fixed data sources with timestamp IDs
```
3 changes: 1 addition & 2 deletions google/data_source_google_client_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package google

import (
"fmt"
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
Expand Down Expand Up @@ -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)
}
Expand Down
3 changes: 1 addition & 2 deletions google/data_source_google_client_openid_userinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package google

import (
"fmt"
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
Expand Down Expand Up @@ -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)
}
Expand Down
3 changes: 1 addition & 2 deletions google/data_source_google_composer_image_versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package google
import (
"fmt"
"log"
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 1 addition & 2 deletions google/data_source_google_compute_node_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"log"
"sort"
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"google.golang.org/api/compute/v1"
Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 1 addition & 2 deletions google/data_source_google_compute_regions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 1 addition & 2 deletions google/data_source_google_compute_zones.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
3 changes: 1 addition & 2 deletions google/data_source_google_kms_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"log"
"time"
)

func dataSourceGoogleKmsSecret() *schema.Resource {
Expand Down Expand Up @@ -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
}
3 changes: 1 addition & 2 deletions google/data_source_google_kms_secret_ciphertext.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"encoding/base64"
"fmt"
"log"
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
Expand Down Expand Up @@ -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
}
3 changes: 1 addition & 2 deletions google/data_source_google_monitoring_uptime_check_ips.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package google

import (
"fmt"
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
Expand Down Expand Up @@ -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
}

Expand Down
3 changes: 1 addition & 2 deletions google/data_source_google_service_account_access_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"log"

"strings"
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
iamcredentials "google.golang.org/api/iamcredentials/v1"
Expand Down Expand Up @@ -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)
}
Expand Down
6 changes: 2 additions & 4 deletions google/data_source_google_service_account_id_token.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package google

import (
"time"

"fmt"
"strings"

Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down
3 changes: 1 addition & 2 deletions google/data_source_tpu_tensorflow_versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"log"
"sort"
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
Expand Down Expand Up @@ -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
}
Expand Down