diff --git a/azurerm/resource_arm_redis_cache.go b/azurerm/resource_arm_redis_cache.go index f25c321d66d04..9cf8a968337b5 100644 --- a/azurerm/resource_arm_redis_cache.go +++ b/azurerm/resource_arm_redis_cache.go @@ -119,6 +119,10 @@ func resourceArmRedisCache() *schema.Resource { Type: schema.TypeString, Optional: true, }, + "notify_keyspace_events": { + Type: schema.TypeString, + Optional: true, + }, }, }, }, @@ -423,6 +427,10 @@ func expandRedisConfiguration(d *schema.ResourceData) *map[string]*string { output["rdb-storage-connection-string"] = utils.String(v.(string)) } + if v, ok := d.GetOk("redis_configuration.0.notify_keyspace_events"); ok { + output["notify-keyspace-events"] = utils.String(v.(string)) + } + return &output } @@ -439,6 +447,7 @@ func flattenRedisConfiguration(configuration *map[string]*string) map[string]*st redisConfiguration["rdb_backup_frequency"] = config["rdb-backup-frequency"] redisConfiguration["rdb_backup_max_snapshot_count"] = config["rdb-backup-max-snapshot-count"] redisConfiguration["rdb_storage_connection_string"] = config["rdb-storage-connection-string"] + redisConfiguration["notify_keyspace_events"] = config["notify-keyspace-events"] return redisConfiguration } diff --git a/azurerm/resource_arm_redis_cache_test.go b/azurerm/resource_arm_redis_cache_test.go index 765061aac4b74..8d99132a04755 100644 --- a/azurerm/resource_arm_redis_cache_test.go +++ b/azurerm/resource_arm_redis_cache_test.go @@ -325,6 +325,26 @@ func testCheckAzureRMRedisCacheDestroy(s *terraform.State) error { return nil } +func TestAccAzureRMRedisCache_SubscribeAllEvents(t *testing.T) { + ri := acctest.RandInt() + rs := acctest.RandString(4) + config := testAccAzureRMRedisCacheSubscribeAllEvents(ri, rs, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMRedisCacheDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMRedisCacheExists("azurerm_redis_cache.test"), + ), + }, + }, + }) +} + func testAccAzureRMRedisCache_basic(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { @@ -504,3 +524,35 @@ resource "azurerm_redis_cache" "test" { } `, rInt, location, rString, rInt) } + +func testAccAzureRMRedisCacheSubscribeAllEvents(rInt int, rString string, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} +resource "azurerm_storage_account" "test" { + name = "unlikely23exst2acct%s" + resource_group_name = "${azurerm_resource_group.test.name}" + + location = "${azurerm_resource_group.test.location}" + account_type = "Standard_GRS" + + tags { + environment = "staging" + } +} +resource "azurerm_redis_cache" "test" { + name = "acctestRedis-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + capacity = 3 + family = "P" + sku_name = "Premium" + enable_non_ssl_port = false + redis_configuration { + notify_keyspace_events = "KAE" + } +} +`, rInt, location, rString, rInt) +} diff --git a/website/docs/r/redis_cache.html.markdown b/website/docs/r/redis_cache.html.markdown index f45d65c5b5e2d..070d0c38e241e 100644 --- a/website/docs/r/redis_cache.html.markdown +++ b/website/docs/r/redis_cache.html.markdown @@ -153,6 +153,7 @@ The pricing group for the Redis Family - either "C" or "P" at present. * `rdb_backup_frequency` - (Optional) The Backup Frequency in Minutes. Only supported on Premium SKU's. Possible values are: `15`, `30`, `60`, `360`, `720` and `1440`. * `rdb_backup_max_snapshot_count` - (Optional) The maximum number of snapshots to create as a backup. Only supported for Premium SKU's. * `rdb_storage_connection_string` - (Optional) The Connection String to the Storage Account. Only supported for Premium SKU's. In the format: `DefaultEndpointsProtocol=https;BlobEndpoint=${azurerm_storage_account.test.primary_blob_endpoint};AccountName=${azurerm_storage_account.test.name};AccountKey=${azurerm_storage_account.test.primary_access_key}`. +* `notify_keyspace_events` - (Optional) Keyspace notifications allows clients to subscribe to Pub/Sub channels in order to receive events affecting the Redis data set in some way. [Reference](https://redis.io/topics/notifications#configuration) ```hcl redis_configuration {