Skip to content

Commit 6e177c6

Browse files
self_link 4.0.0 changes (#5314) (#10424)
* Remove several self link fields * Add note on snapshot * Remove uses of keyring.self_link in tests and docs * Unused var * Remove references in tests * Change kms key ring data source id format, add note to upgrade guide Signed-off-by: Modular Magician <[email protected]>
1 parent ecf6b21 commit 6e177c6

24 files changed

+61
-79
lines changed

.changelog/5314.txt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
```release-note:breaking-change
2+
pubsub: removed `path` field from `google_pubsub_subscription`
3+
```
4+
```release-note:breaking-change
5+
kms: removed `self_link` field from `google_kms_crypto_key` and `google_kms_key_ring`
6+
```
7+
```release-note:breaking-change
8+
compute: removed `source_disk_link` field from `google_compute_snapshot`
9+
```

google/data_source_google_kms_crypto_key_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func TestAccDataSourceGoogleKmsCryptoKey_basic(t *testing.T) {
2222
Steps: []resource.TestStep{
2323
{
2424
Config: testAccDataSourceGoogleKmsCryptoKey_basic(kms.KeyRing.Name, cryptoKeyId),
25-
Check: resource.TestMatchResourceAttr("data.google_kms_crypto_key.kms_crypto_key", "self_link", regexp.MustCompile(kms.CryptoKey.Name)),
25+
Check: resource.TestMatchResourceAttr("data.google_kms_crypto_key.kms_crypto_key", "id", regexp.MustCompile(kms.CryptoKey.Name)),
2626
},
2727
},
2828
})

google/data_source_google_kms_key_ring.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func dataSourceGoogleKmsKeyRingRead(d *schema.ResourceData, meta interface{}) er
2929
Location: d.Get("location").(string),
3030
Project: project,
3131
}
32-
d.SetId(keyRingId.terraformId())
32+
d.SetId(keyRingId.keyRingId())
3333

3434
return resourceKMSKeyRingRead(d, meta)
3535
}

google/data_source_google_kms_key_ring_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func TestAccDataSourceGoogleKmsKeyRing_basic(t *testing.T) {
2121
Steps: []resource.TestStep{
2222
{
2323
Config: testAccDataSourceGoogleKmsKeyRing_basic(keyRingId),
24-
Check: resource.TestMatchResourceAttr("data.google_kms_key_ring.kms_key_ring", "self_link", regexp.MustCompile(kms.KeyRing.Name)),
24+
Check: resource.TestMatchResourceAttr("data.google_kms_key_ring.kms_key_ring", "id", regexp.MustCompile(kms.KeyRing.Name)),
2525
},
2626
},
2727
})

google/provider_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ resource "google_kms_key_ring" "project-2-keyring" {
796796
resource "google_kms_crypto_key" "project-2-key" {
797797
provider = google.project-1-token
798798
name = "%s"
799-
key_ring = google_kms_key_ring.project-2-keyring.self_link
799+
key_ring = google_kms_key_ring.project-2-keyring.id
800800
}
801801
802802
data "google_kms_secret_ciphertext" "project-2-ciphertext" {

google/resource_compute_snapshot.go

-8
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,6 @@ snapshot using a customer-supplied encryption key.`,
199199
storage, this number is expected to change with snapshot
200200
creation/deletion.`,
201201
},
202-
"source_disk_link": {
203-
Type: schema.TypeString,
204-
Computed: true,
205-
Deprecated: "Deprecated in favor of source_disk, which contains a compatible value. This field will be removed in the next major release of the provider.",
206-
},
207202
"project": {
208203
Type: schema.TypeString,
209204
Optional: true,
@@ -843,8 +838,5 @@ func resourceComputeSnapshotDecoder(d *schema.ResourceData, meta interface{}, re
843838
res["sourceDiskEncryptionKey"] = transformed
844839
}
845840

846-
if err := d.Set("source_disk_link", ConvertSelfLinkToV1(res["sourceDisk"].(string))); err != nil {
847-
return nil, fmt.Errorf("Error setting source_disk_link: %s", err)
848-
}
849841
return res, nil
850842
}

google/resource_container_analysis_occurrence_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,11 @@ data "google_kms_key_ring" "keyring" {
178178
179179
data "google_kms_crypto_key" "crypto-key" {
180180
name = "%{crypto_key}"
181-
key_ring = data.google_kms_key_ring.keyring.self_link
181+
key_ring = data.google_kms_key_ring.keyring.id
182182
}
183183
184184
data "google_kms_crypto_key_version" "version" {
185-
crypto_key = data.google_kms_crypto_key.crypto-key.self_link
185+
crypto_key = data.google_kms_crypto_key.crypto-key.id
186186
}
187187
188188
resource "google_container_analysis_occurrence" "occurrence" {
@@ -240,12 +240,12 @@ data "google_kms_key_ring" "keyring" {
240240
241241
data "google_kms_crypto_key" "crypto-key1" {
242242
name = "%{key1}"
243-
key_ring = data.google_kms_key_ring.keyring.self_link
243+
key_ring = data.google_kms_key_ring.keyring.id
244244
}
245245
246246
data "google_kms_crypto_key" "crypto-key2" {
247247
name = "%{key2}"
248-
key_ring = data.google_kms_key_ring.keyring.self_link
248+
key_ring = data.google_kms_key_ring.keyring.id
249249
}
250250
251251
data "google_kms_crypto_key_version" "version-key1" {

google/resource_healthcare_dataset.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -322,14 +322,10 @@ func expandHealthcareDatasetTimeZone(v interface{}, d TerraformResourceData, con
322322
}
323323

324324
func resourceHealthcareDatasetDecoder(d *schema.ResourceData, meta interface{}, res map[string]interface{}) (map[string]interface{}, error) {
325-
// Take the returned long form of the name and use it as `self_link`.
326-
// Then modify the name to be the user specified form.
325+
// Modify the name to be the user specified form.
327326
// We can't just ignore_read on `name` as the linter will
328327
// complain that the returned `res` is never used afterwards.
329328
// Some field needs to be actually set, and we chose `name`.
330-
if err := d.Set("self_link", res["name"].(string)); err != nil {
331-
return nil, fmt.Errorf("Error setting self_link: %s", err)
332-
}
333329
res["name"] = d.Get("name").(string)
334330
return res, nil
335331
}

google/resource_healthcare_dicom_store.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -386,14 +386,10 @@ func expandHealthcareDicomStoreNotificationConfigPubsubTopic(v interface{}, d Te
386386
}
387387

388388
func resourceHealthcareDicomStoreDecoder(d *schema.ResourceData, meta interface{}, res map[string]interface{}) (map[string]interface{}, error) {
389-
// Take the returned long form of the name and use it as `self_link`.
390-
// Then modify the name to be the user specified form.
389+
// Modify the name to be the user specified form.
391390
// We can't just ignore_read on `name` as the linter will
392391
// complain that the returned `res` is never used afterwards.
393392
// Some field needs to be actually set, and we chose `name`.
394-
if err := d.Set("self_link", res["name"].(string)); err != nil {
395-
return nil, fmt.Errorf("Error setting self_link: %s", err)
396-
}
397393
res["name"] = d.Get("name").(string)
398394
return res, nil
399395
}

google/resource_healthcare_fhir_store.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -801,14 +801,10 @@ func expandHealthcareFhirStoreStreamConfigsBigqueryDestinationSchemaConfigRecurs
801801
}
802802

803803
func resourceHealthcareFhirStoreDecoder(d *schema.ResourceData, meta interface{}, res map[string]interface{}) (map[string]interface{}, error) {
804-
// Take the returned long form of the name and use it as `self_link`.
805-
// Then modify the name to be the user specified form.
804+
// Modify the name to be the user specified form.
806805
// We can't just ignore_read on `name` as the linter will
807806
// complain that the returned `res` is never used afterwards.
808807
// Some field needs to be actually set, and we chose `name`.
809-
if err := d.Set("self_link", res["name"].(string)); err != nil {
810-
return nil, fmt.Errorf("Error setting self_link: %s", err)
811-
}
812808
res["name"] = d.Get("name").(string)
813809
return res, nil
814810
}

google/resource_healthcare_hl7_v2_store.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -681,14 +681,10 @@ func expandHealthcareHl7V2StoreNotificationConfigPubsubTopic(v interface{}, d Te
681681
}
682682

683683
func resourceHealthcareHl7V2StoreDecoder(d *schema.ResourceData, meta interface{}, res map[string]interface{}) (map[string]interface{}, error) {
684-
// Take the returned long form of the name and use it as `self_link`.
685-
// Then modify the name to be the user specified form.
684+
// Modify the name to be the user specified form.
686685
// We can't just ignore_read on `name` as the linter will
687686
// complain that the returned `res` is never used afterwards.
688687
// Some field needs to be actually set, and we chose `name`.
689-
if err := d.Set("self_link", res["name"].(string)); err != nil {
690-
return nil, fmt.Errorf("Error setting self_link: %s", err)
691-
}
692688
res["name"] = d.Get("name").(string)
693689
return res, nil
694690
}

google/resource_kms_crypto_key.go

+1-11
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,6 @@ See the [algorithm reference](https://cloud.google.com/kms/docs/reference/rest/v
139139
},
140140
},
141141
},
142-
"self_link": {
143-
Type: schema.TypeString,
144-
Computed: true,
145-
Deprecated: "Deprecated in favor of id, which contains an identical value. This field will be removed in the next major release of the provider.",
146-
Description: "The self link of the created KeyRing in the format projects/{project}/locations/{location}/keyRings/{name}.",
147-
},
148142
},
149143
UseJSONNumber: true,
150144
}
@@ -577,14 +571,10 @@ func resourceKMSCryptoKeyUpdateEncoder(d *schema.ResourceData, meta interface{},
577571
}
578572

579573
func resourceKMSCryptoKeyDecoder(d *schema.ResourceData, meta interface{}, res map[string]interface{}) (map[string]interface{}, error) {
580-
// Take the returned long form of the name and use it as `self_link`.
581-
// Then modify the name to be the user specified form.
574+
// Modify the name to be the user specified form.
582575
// We can't just ignore_read on `name` as the linter will
583576
// complain that the returned `res` is never used afterwards.
584577
// Some field needs to be actually set, and we chose `name`.
585-
if err := d.Set("self_link", res["name"].(string)); err != nil {
586-
return nil, fmt.Errorf("Error setting self_link: %s", err)
587-
}
588578
res["name"] = d.Get("name").(string)
589579
return res, nil
590580
}

google/resource_kms_crypto_key_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ resource "google_kms_key_ring" "key_ring" {
457457
458458
resource "google_kms_crypto_key" "crypto_key" {
459459
name = "%s"
460-
key_ring = google_kms_key_ring.key_ring.self_link
460+
key_ring = google_kms_key_ring.key_ring.id
461461
labels = {
462462
key = "value"
463463
}
@@ -487,7 +487,7 @@ resource "google_kms_key_ring" "key_ring" {
487487
488488
resource "google_kms_crypto_key" "crypto_key" {
489489
name = "%s"
490-
key_ring = google_kms_key_ring.key_ring.self_link
490+
key_ring = google_kms_key_ring.key_ring.id
491491
rotation_period = "%s"
492492
}
493493
`, projectId, projectId, projectOrg, projectBillingAccount, keyRingName, cryptoKeyName, rotationPeriod)
@@ -515,7 +515,7 @@ resource "google_kms_key_ring" "key_ring" {
515515
516516
resource "google_kms_crypto_key" "crypto_key" {
517517
name = "%s"
518-
key_ring = google_kms_key_ring.key_ring.self_link
518+
key_ring = google_kms_key_ring.key_ring.id
519519
}
520520
`, projectId, projectId, projectOrg, projectBillingAccount, keyRingName, cryptoKeyName)
521521
}
@@ -542,7 +542,7 @@ resource "google_kms_key_ring" "key_ring" {
542542
543543
resource "google_kms_crypto_key" "crypto_key" {
544544
name = "%s"
545-
key_ring = google_kms_key_ring.key_ring.self_link
545+
key_ring = google_kms_key_ring.key_ring.id
546546
purpose = "ASYMMETRIC_SIGN"
547547
548548
version_template {
@@ -596,7 +596,7 @@ resource "google_kms_key_ring" "key_ring" {
596596
597597
resource "google_kms_crypto_key" "crypto_key" {
598598
name = "%s"
599-
key_ring = google_kms_key_ring.key_ring.self_link
599+
key_ring = google_kms_key_ring.key_ring.id
600600
labels = {
601601
key = "value"
602602
}
@@ -627,7 +627,7 @@ resource "google_kms_key_ring" "key_ring" {
627627
628628
resource "google_kms_crypto_key" "crypto_key" {
629629
name = "%s"
630-
key_ring = google_kms_key_ring.key_ring.self_link
630+
key_ring = google_kms_key_ring.key_ring.id
631631
labels = {
632632
key = "value"
633633
}

google/resource_kms_key_ring.go

+1-11
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@ A full list of valid locations can be found by running 'gcloud kms locations lis
5252
ForceNew: true,
5353
Description: `The resource name for the KeyRing.`,
5454
},
55-
"self_link": {
56-
Type: schema.TypeString,
57-
Computed: true,
58-
Deprecated: "Deprecated in favor of id, which contains an identical value. This field will be removed in the next major release of the provider.",
59-
Description: "The self link of the created KeyRing in the format projects/{project}/locations/{location}/keyRings/{name}.",
60-
},
6155
"project": {
6256
Type: schema.TypeString,
6357
Optional: true,
@@ -230,14 +224,10 @@ func resourceKMSKeyRingEncoder(d *schema.ResourceData, meta interface{}, obj map
230224
}
231225

232226
func resourceKMSKeyRingDecoder(d *schema.ResourceData, meta interface{}, res map[string]interface{}) (map[string]interface{}, error) {
233-
// Take the returned long form of the name and use it as `self_link`.
234-
// Then modify the name to be the user specified form.
227+
// Modify the name to be the user specified form.
235228
// We can't just ignore_read on `name` as the linter will
236229
// complain that the returned `res` is never used afterwards.
237230
// Some field needs to be actually set, and we chose `name`.
238-
if err := d.Set("self_link", res["name"].(string)); err != nil {
239-
return nil, fmt.Errorf("Error setting self_link: %s", err)
240-
}
241231
res["name"] = d.Get("name").(string)
242232
return res, nil
243233
}

google/resource_pubsub_subscription_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ func TestAccPubsubSubscription_update(t *testing.T) {
6161

6262
topic := fmt.Sprintf("tf-test-topic-%s", randString(t, 10))
6363
subscriptionShort := fmt.Sprintf("tf-test-sub-%s", randString(t, 10))
64-
subscriptionLong := fmt.Sprintf("projects/%s/subscriptions/%s", getTestProjectFromEnv(), subscriptionShort)
6564

6665
vcrTest(t, resource.TestCase{
6766
PreCheck: func() { testAccPreCheck(t) },

google/resource_vpc_access_connector.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -434,14 +434,10 @@ func resourceVPCAccessConnectorEncoder(d *schema.ResourceData, meta interface{},
434434
}
435435

436436
func resourceVPCAccessConnectorDecoder(d *schema.ResourceData, meta interface{}, res map[string]interface{}) (map[string]interface{}, error) {
437-
// Take the returned long form of the name and use it as `self_link`.
438-
// Then modify the name to be the user specified form.
437+
// Modify the name to be the user specified form.
439438
// We can't just ignore_read on `name` as the linter will
440439
// complain that the returned `res` is never used afterwards.
441440
// Some field needs to be actually set, and we chose `name`.
442-
if err := d.Set("self_link", res["name"].(string)); err != nil {
443-
return nil, fmt.Errorf("Error setting self_link: %s", err)
444-
}
445441
res["name"] = d.Get("name").(string)
446442
return res, nil
447443
}

website/docs/d/kms_crypto_key.html.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ data "google_kms_key_ring" "my_key_ring" {
2727
2828
data "google_kms_crypto_key" "my_crypto_key" {
2929
name = "my-crypto-key"
30-
key_ring = data.google_kms_key_ring.my_key_ring.self_link
30+
key_ring = data.google_kms_key_ring.my_key_ring.id
3131
}
3232
```
3333

website/docs/d/kms_secret.html.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ resource "google_kms_key_ring" "my_key_ring" {
3333
3434
resource "google_kms_crypto_key" "my_crypto_key" {
3535
name = "my-crypto-key"
36-
key_ring = google_kms_key_ring.my_key_ring.self_link
36+
key_ring = google_kms_key_ring.my_key_ring.id
3737
}
3838
```
3939

website/docs/d/kms_secret_asymmetric.html.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ resource "google_kms_key_ring" "my_key_ring" {
3636
3737
resource "google_kms_crypto_key" "my_crypto_key" {
3838
name = "my-crypto-key"
39-
key_ring = google_kms_key_ring.my_key_ring.self_link
39+
key_ring = google_kms_key_ring.my_key_ring.id
4040
purpose = "ASYMMETRIC_DECRYPT"
4141
version_template {
4242
algorithm = "RSA_DECRYPT_OAEP_4096_SHA256"

website/docs/d/kms_secret_ciphertext.html.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ resource "google_kms_key_ring" "my_key_ring" {
3535
3636
resource "google_kms_crypto_key" "my_crypto_key" {
3737
name = "my-crypto-key"
38-
key_ring = google_kms_key_ring.my_key_ring.self_link
38+
key_ring = google_kms_key_ring.my_key_ring.id
3939
}
4040
```
4141

website/docs/guides/version_4_upgrade.html.markdown

+26
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,32 @@ This field was incorrectly included in the GA `google` provider in past releases
402402
In order to continue to use the feature, add `provider = google-beta` to your
403403
resource definition.
404404

405+
## Resource: `google_compute_snapshot`
406+
407+
### `source_disk_link` is now removed
408+
409+
Removed in favor of `source_disk`.
410+
411+
## Resource: `google_kms_crypto_key`
412+
413+
### `self_link` is now removed
414+
415+
Removed in favor of `id`.
416+
417+
## Resource: `google_kms_key_ring`
418+
419+
### `self_link` is now removed
420+
421+
Removed in favor of `id`.
422+
423+
## Datasource: `google_kms_key_ring`
424+
425+
### `id` now matches the `google_kms_key_ring` id format
426+
427+
The format has changed to better match the resource's ID format.
428+
429+
Interpolations based on the `id` of the datasource may require updates.
430+
405431
## Resource: `google_data_loss_prevention_trigger`
406432

407433
### Exactly one of `inspect_job.0.storage_config.0.cloud_storage_options.0.file_set.0.url` or `inspect_job.0.storage_config.0.cloud_storage_options.0.file_set.0.regex_file_set` is required

website/docs/r/container_analysis_occurrence.html.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ data "google_kms_key_ring" "keyring" {
6767
6868
data "google_kms_crypto_key" "crypto-key" {
6969
name = "my-key"
70-
key_ring = data.google_kms_key_ring.keyring.self_link
70+
key_ring = data.google_kms_key_ring.keyring.id
7171
}
7272
7373
data "google_kms_crypto_key_version" "version" {

website/docs/r/kms_crypto_key.html.markdown

-2
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,6 @@ In addition to the arguments listed above, the following computed attributes are
158158
* `id` - an identifier for the resource with format `{{key_ring}}/cryptoKeys/{{name}}`
159159

160160

161-
* `self_link`: Deprecated in favor of `id`, which contains an identical value. This field will be removed in the next major release of the provider.
162-
163161
## Timeouts
164162

165163
This resource provides the following

website/docs/r/kms_key_ring.html.markdown

-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ In addition to the arguments listed above, the following computed attributes are
7575
* `id` - an identifier for the resource with format `projects/{{project}}/locations/{{location}}/keyRings/{{name}}`
7676

7777

78-
* `self_link`: The self link of the created KeyRing in the format `projects/{project}/locations/{location}/keyRings/{name}`
79-
8078
## Timeouts
8179

8280
This resource provides the following

0 commit comments

Comments
 (0)