@@ -104,6 +104,14 @@ projects/{network_project_id_or_number}/global/networks/{network_id}.`,
104
104
Description : `The nodeType for the Redis cluster.
105
105
If not provided, REDIS_HIGHMEM_MEDIUM will be used as default Possible values: ["REDIS_SHARED_CORE_NANO", "REDIS_HIGHMEM_MEDIUM", "REDIS_HIGHMEM_XLARGE", "REDIS_STANDARD_SMALL"]` ,
106
106
},
107
+ "redis_configs" : {
108
+ Type : schema .TypeMap ,
109
+ Optional : true ,
110
+ Description : `Configure Redis Cluster behavior using a subset of native Redis configuration parameters.
111
+ Please check Memorystore documentation for the list of supported parameters:
112
+ https://cloud.google.com/memorystore/docs/cluster/supported-instance-configurations` ,
113
+ Elem : & schema.Schema {Type : schema .TypeString },
114
+ },
107
115
"region" : {
108
116
Type : schema .TypeString ,
109
117
Computed : true ,
@@ -309,6 +317,12 @@ func resourceRedisClusterCreate(d *schema.ResourceData, meta interface{}) error
309
317
} else if v , ok := d .GetOkExists ("shard_count" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (shardCountProp )) && (ok || ! reflect .DeepEqual (v , shardCountProp )) {
310
318
obj ["shardCount" ] = shardCountProp
311
319
}
320
+ redisConfigsProp , err := expandRedisClusterRedisConfigs (d .Get ("redis_configs" ), d , config )
321
+ if err != nil {
322
+ return err
323
+ } else if v , ok := d .GetOkExists ("redis_configs" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (redisConfigsProp )) && (ok || ! reflect .DeepEqual (v , redisConfigsProp )) {
324
+ obj ["redisConfigs" ] = redisConfigsProp
325
+ }
312
326
313
327
url , err := tpgresource .ReplaceVars (d , config , "{{RedisBasePath}}projects/{{project}}/locations/{{region}}/clusters?clusterId={{name}}" )
314
328
if err != nil {
@@ -455,6 +469,9 @@ func resourceRedisClusterRead(d *schema.ResourceData, meta interface{}) error {
455
469
if err := d .Set ("shard_count" , flattenRedisClusterShardCount (res ["shardCount" ], d , config )); err != nil {
456
470
return fmt .Errorf ("Error reading Cluster: %s" , err )
457
471
}
472
+ if err := d .Set ("redis_configs" , flattenRedisClusterRedisConfigs (res ["redisConfigs" ], d , config )); err != nil {
473
+ return fmt .Errorf ("Error reading Cluster: %s" , err )
474
+ }
458
475
459
476
return nil
460
477
}
@@ -493,6 +510,12 @@ func resourceRedisClusterUpdate(d *schema.ResourceData, meta interface{}) error
493
510
} else if v , ok := d .GetOkExists ("shard_count" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , shardCountProp )) {
494
511
obj ["shardCount" ] = shardCountProp
495
512
}
513
+ redisConfigsProp , err := expandRedisClusterRedisConfigs (d .Get ("redis_configs" ), d , config )
514
+ if err != nil {
515
+ return err
516
+ } else if v , ok := d .GetOkExists ("redis_configs" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , redisConfigsProp )) {
517
+ obj ["redisConfigs" ] = redisConfigsProp
518
+ }
496
519
497
520
url , err := tpgresource .ReplaceVars (d , config , "{{RedisBasePath}}projects/{{project}}/locations/{{region}}/clusters/{{name}}" )
498
521
if err != nil {
@@ -514,6 +537,10 @@ func resourceRedisClusterUpdate(d *schema.ResourceData, meta interface{}) error
514
537
if d .HasChange ("shard_count" ) {
515
538
updateMask = append (updateMask , "shardCount" )
516
539
}
540
+
541
+ if d .HasChange ("redis_configs" ) {
542
+ updateMask = append (updateMask , "redisConfigs" )
543
+ }
517
544
// updateMask is a URL parameter but not present in the schema, so ReplaceVars
518
545
// won't set it
519
546
url , err = transport_tpg .AddQueryParams (url , map [string ]string {"updateMask" : strings .Join (updateMask , "," )})
@@ -875,6 +902,10 @@ func flattenRedisClusterShardCount(v interface{}, d *schema.ResourceData, config
875
902
return v // let terraform core handle it otherwise
876
903
}
877
904
905
+ func flattenRedisClusterRedisConfigs (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
906
+ return v
907
+ }
908
+
878
909
func expandRedisClusterAuthorizationMode (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
879
910
return v , nil
880
911
}
@@ -920,3 +951,14 @@ func expandRedisClusterReplicaCount(v interface{}, d tpgresource.TerraformResour
920
951
func expandRedisClusterShardCount (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
921
952
return v , nil
922
953
}
954
+
955
+ func expandRedisClusterRedisConfigs (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (map [string ]string , error ) {
956
+ if v == nil {
957
+ return map [string ]string {}, nil
958
+ }
959
+ m := make (map [string ]string )
960
+ for k , val := range v .(map [string ]interface {}) {
961
+ m [k ] = val .(string )
962
+ }
963
+ return m , nil
964
+ }
0 commit comments