@@ -202,6 +202,11 @@ If the value if set to true, any delete cluster operation will fail.
202
202
Default value is true.` ,
203
203
Default : true ,
204
204
},
205
+ "kms_key" : {
206
+ Type : schema .TypeString ,
207
+ Optional : true ,
208
+ Description : `The KMS key used to encrypt the at-rest data of the cluster.` ,
209
+ },
205
210
"maintenance_policy" : {
206
211
Type : schema .TypeList ,
207
212
Optional : true ,
@@ -722,6 +727,12 @@ func resourceRedisClusterCreate(d *schema.ResourceData, meta interface{}) error
722
727
} else if v , ok := d .GetOkExists ("cross_cluster_replication_config" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (crossClusterReplicationConfigProp )) && (ok || ! reflect .DeepEqual (v , crossClusterReplicationConfigProp )) {
723
728
obj ["crossClusterReplicationConfig" ] = crossClusterReplicationConfigProp
724
729
}
730
+ kmsKeyProp , err := expandRedisClusterKmsKey (d .Get ("kms_key" ), d , config )
731
+ if err != nil {
732
+ return err
733
+ } else if v , ok := d .GetOkExists ("kms_key" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (kmsKeyProp )) && (ok || ! reflect .DeepEqual (v , kmsKeyProp )) {
734
+ obj ["kmsKey" ] = kmsKeyProp
735
+ }
725
736
726
737
url , err := tpgresource .ReplaceVars (d , config , "{{RedisBasePath}}projects/{{project}}/locations/{{region}}/clusters?clusterId={{name}}" )
727
738
if err != nil {
@@ -892,6 +903,9 @@ func resourceRedisClusterRead(d *schema.ResourceData, meta interface{}) error {
892
903
if err := d .Set ("psc_service_attachments" , flattenRedisClusterPscServiceAttachments (res ["pscServiceAttachments" ], d , config )); err != nil {
893
904
return fmt .Errorf ("Error reading Cluster: %s" , err )
894
905
}
906
+ if err := d .Set ("kms_key" , flattenRedisClusterKmsKey (res ["kmsKey" ], d , config )); err != nil {
907
+ return fmt .Errorf ("Error reading Cluster: %s" , err )
908
+ }
895
909
896
910
return nil
897
911
}
@@ -960,6 +974,12 @@ func resourceRedisClusterUpdate(d *schema.ResourceData, meta interface{}) error
960
974
} else if v , ok := d .GetOkExists ("cross_cluster_replication_config" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , crossClusterReplicationConfigProp )) {
961
975
obj ["crossClusterReplicationConfig" ] = crossClusterReplicationConfigProp
962
976
}
977
+ kmsKeyProp , err := expandRedisClusterKmsKey (d .Get ("kms_key" ), d , config )
978
+ if err != nil {
979
+ return err
980
+ } else if v , ok := d .GetOkExists ("kms_key" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , kmsKeyProp )) {
981
+ obj ["kmsKey" ] = kmsKeyProp
982
+ }
963
983
964
984
url , err := tpgresource .ReplaceVars (d , config , "{{RedisBasePath}}projects/{{project}}/locations/{{region}}/clusters/{{name}}" )
965
985
if err != nil {
@@ -1001,6 +1021,10 @@ func resourceRedisClusterUpdate(d *schema.ResourceData, meta interface{}) error
1001
1021
if d .HasChange ("cross_cluster_replication_config" ) {
1002
1022
updateMask = append (updateMask , "crossClusterReplicationConfig" )
1003
1023
}
1024
+
1025
+ if d .HasChange ("kms_key" ) {
1026
+ updateMask = append (updateMask , "kmsKey" )
1027
+ }
1004
1028
// updateMask is a URL parameter but not present in the schema, so ReplaceVars
1005
1029
// won't set it
1006
1030
url , err = transport_tpg .AddQueryParams (url , map [string ]string {"updateMask" : strings .Join (updateMask , "," )})
@@ -1791,6 +1815,10 @@ func flattenRedisClusterPscServiceAttachmentsConnectionType(v interface{}, d *sc
1791
1815
return v
1792
1816
}
1793
1817
1818
+ func flattenRedisClusterKmsKey (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1819
+ return v
1820
+ }
1821
+
1794
1822
func expandRedisClusterAuthorizationMode (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1795
1823
return v , nil
1796
1824
}
@@ -2348,3 +2376,7 @@ func expandRedisClusterCrossClusterReplicationConfigMembershipSecondaryClustersU
2348
2376
func expandRedisClusterCrossClusterReplicationConfigUpdateTime (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
2349
2377
return v , nil
2350
2378
}
2379
+
2380
+ func expandRedisClusterKmsKey (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
2381
+ return v , nil
2382
+ }
0 commit comments