Skip to content

Commit 02f4412

Browse files
mark field as updatable (#4371) (#2942)
Co-authored-by: upodroid <[email protected]> Signed-off-by: Modular Magician <[email protected]> Co-authored-by: upodroid <[email protected]>
1 parent e0420f6 commit 02f4412

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

.changelog/4371.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
pubsub: marked `kms_key_name` field in `google_pubsub_topic` as updatable
3+
```

google-beta/resource_pubsub_topic.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ func resourcePubsubTopic() *schema.Resource {
5252
"kms_key_name": {
5353
Type: schema.TypeString,
5454
Optional: true,
55-
ForceNew: true,
5655
Description: `The resource name of the Cloud KMS CryptoKey to be used to protect access
5756
to messages published on this topic. Your project's PubSub service account
5857
('service-{{PROJECT_NUMBER}}@gcp-sa-pubsub.iam.gserviceaccount.com') must have
@@ -282,6 +281,12 @@ func resourcePubsubTopicUpdate(d *schema.ResourceData, meta interface{}) error {
282281
billingProject = project
283282

284283
obj := make(map[string]interface{})
284+
kmsKeyNameProp, err := expandPubsubTopicKmsKeyName(d.Get("kms_key_name"), d, config)
285+
if err != nil {
286+
return err
287+
} else if v, ok := d.GetOkExists("kms_key_name"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, kmsKeyNameProp)) {
288+
obj["kmsKeyName"] = kmsKeyNameProp
289+
}
285290
labelsProp, err := expandPubsubTopicLabels(d.Get("labels"), d, config)
286291
if err != nil {
287292
return err
@@ -308,6 +313,10 @@ func resourcePubsubTopicUpdate(d *schema.ResourceData, meta interface{}) error {
308313
log.Printf("[DEBUG] Updating Topic %q: %#v", d.Id(), obj)
309314
updateMask := []string{}
310315

316+
if d.HasChange("kms_key_name") {
317+
updateMask = append(updateMask, "kmsKeyName")
318+
}
319+
311320
if d.HasChange("labels") {
312321
updateMask = append(updateMask, "labels")
313322
}

0 commit comments

Comments
 (0)