Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_redis_cache - support storage_account_subscription_id property #24101

Merged
merged 2 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -224,6 +224,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 @@ -883,6 +888,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 @@ -1021,6 +1030,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 @@ -808,13 +808,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 @@ -156,6 +156,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
Loading