@@ -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
5756to 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