Skip to content

Commit

Permalink
azurerm_redis_cache - support storage_account_subscription_id pro…
Browse files Browse the repository at this point in the history
…perty (#24101)

* support storage account subscrition id for redis

* update code
  • Loading branch information
sinbai authored Dec 11, 2023
1 parent 5c11965 commit a2db80c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
4 changes: 4 additions & 0 deletions internal/services/redis/redis_cache_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ func dataSourceRedisCache() *pluginsdk.Resource {
Type: pluginsdk.TypeBool,
Computed: true,
},
"storage_account_subscription_id": {
Type: pluginsdk.TypeString,
Computed: true,
},
},
},
},
Expand Down
11 changes: 11 additions & 0 deletions internal/services/redis/redis_cache_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ func resourceRedisCache() *pluginsdk.Resource {
Optional: true,
Default: true,
},
"storage_account_subscription_id": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: validation.IsUUID,
},
},
},
},
Expand Down Expand Up @@ -902,6 +907,10 @@ func expandRedisConfiguration(d *pluginsdk.ResourceData) (*redis.RedisCommonProp
value := isAuthNotRequiredAsString(authEnabled)
output.Authnotrequired = utils.String(value)
}

if v := raw["storage_account_subscription_id"].(string); v != "" {
output.StorageSubscriptionId = pointer.To(v)
}
return output, nil
}

Expand Down Expand Up @@ -1048,6 +1057,8 @@ func flattenRedisConfiguration(input *redis.RedisCommonPropertiesRedisConfigurat
outputs["enable_authentication"] = isAuthRequiredAsBool(*v)
}

outputs["storage_account_subscription_id"] = pointer.From(input.StorageSubscriptionId)

return []interface{}{outputs}, nil
}

Expand Down
11 changes: 6 additions & 5 deletions internal/services/redis/redis_cache_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -851,13 +851,14 @@ resource "azurerm_redis_cache" "test" {
enable_non_ssl_port = false
redis_configuration {
rdb_backup_enabled = true
rdb_backup_frequency = 60
rdb_backup_max_snapshot_count = 1
rdb_storage_connection_string = azurerm_storage_account.test.primary_connection_string
rdb_backup_enabled = true
rdb_backup_frequency = 60
rdb_backup_max_snapshot_count = 1
rdb_storage_connection_string = azurerm_storage_account.test.primary_connection_string
storage_account_subscription_id = "%s"
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomInteger)
`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomInteger, data.Client().SubscriptionID)
}

func (RedisCacheResource) aofBackupDisabled(data acceptance.TestData) string {
Expand Down
2 changes: 2 additions & 0 deletions website/docs/d/redis_cache.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ A `redis_configuration` block exports the following:

~> **Note:** There's a bug in the Redis API where the original storage connection string isn't being returned, which [is being tracked in this issue](https://github.com/Azure/azure-rest-api-specs/issues/3037). In the interim you can use [the `ignore_changes` attribute to ignore changes to this field](https://www.terraform.io/language/meta-arguments/lifecycle#ignore_changess) e.g.:

* `storage_account_subscription_id` - The ID of the Subscription containing the Storage Account.

## Timeouts

The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions:
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/redis_cache.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ redis_configuration {

~> **NOTE:** There's a bug in the Redis API where the original storage connection string isn't being returned, which [is being tracked in this issue](https://github.com/Azure/azure-rest-api-specs/issues/3037). In the interim you can use [the `ignore_changes` attribute to ignore changes to this field](https://www.terraform.io/language/meta-arguments/lifecycle#ignore_changess) e.g.:

* `storage_account_subscription_id` - (Optional) The ID of the Subscription containing the Storage Account.

```hcl
resource "azurerm_redis_cache" "example" {
# ...
Expand Down

0 comments on commit a2db80c

Please sign in to comment.