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

Support for change_feed_enabled in azurerm_storage_account #11695

Merged
merged 2 commits into from
May 13, 2021
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
20 changes: 19 additions & 1 deletion azurerm/internal/services/storage/storage_account_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,12 @@ func resourceStorageAccount() *schema.Resource {
Default: false,
},

"change_feed_enabled": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},

"default_service_version": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -1761,6 +1767,9 @@ func expandBlobProperties(input []interface{}) *storage.BlobServiceProperties {
CorsRules: &[]storage.CorsRule{},
},
IsVersioningEnabled: utils.Bool(false),
ChangeFeed: &storage.ChangeFeed{
Enabled: utils.Bool(false),
},
LastAccessTimeTrackingPolicy: &storage.LastAccessTimeTrackingPolicy{
Enable: utils.Bool(false),
},
Expand All @@ -1786,6 +1795,10 @@ func expandBlobProperties(input []interface{}) *storage.BlobServiceProperties {

props.IsVersioningEnabled = utils.Bool(v["versioning_enabled"].(bool))

props.ChangeFeed = &storage.ChangeFeed{
Enabled: utils.Bool(v["change_feed_enabled"].(bool)),
}

if version, ok := v["default_service_version"].(string); ok && version != "" {
props.DefaultServiceVersion = utils.String(version)
}
Expand Down Expand Up @@ -2164,11 +2177,15 @@ func flattenBlobProperties(input storage.BlobServiceProperties) []interface{} {
flattenedContainerDeletePolicy = flattenBlobPropertiesDeleteRetentionPolicy(containerDeletePolicy)
}

versioning := false
versioning, changeFeed := false, false
if input.BlobServicePropertiesProperties.IsVersioningEnabled != nil {
versioning = *input.BlobServicePropertiesProperties.IsVersioningEnabled
}

if v := input.BlobServicePropertiesProperties.ChangeFeed; v != nil && v.Enabled != nil {
changeFeed = *v.Enabled
}

var defaultServiceVersion string
if input.BlobServicePropertiesProperties.DefaultServiceVersion != nil {
defaultServiceVersion = *input.BlobServicePropertiesProperties.DefaultServiceVersion
Expand All @@ -2184,6 +2201,7 @@ func flattenBlobProperties(input storage.BlobServiceProperties) []interface{} {
"cors_rule": flattenedCorsRules,
"delete_retention_policy": flattenedDeletePolicy,
"versioning_enabled": versioning,
"change_feed_enabled": changeFeed,
"default_service_version": defaultServiceVersion,
"last_access_time_enabled": LastAccessTimeTrackingPolicy,
"container_delete_retention_policy": flattenedContainerDeletePolicy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ func TestAccStorageAccount_blobProperties(t *testing.T) {
check.That(data.ResourceName).Key("blob_properties.0.cors_rule.#").HasValue("2"),
check.That(data.ResourceName).Key("blob_properties.0.delete_retention_policy.0.days").HasValue("7"),
check.That(data.ResourceName).Key("blob_properties.0.versioning_enabled").HasValue("false"),
check.That(data.ResourceName).Key("blob_properties.0.change_feed_enabled").HasValue("false"),
),
},
data.ImportStep(),
Expand Down Expand Up @@ -1756,6 +1757,7 @@ resource "azurerm_storage_account" "test" {

default_service_version = "2019-07-07"
versioning_enabled = true
change_feed_enabled = true
last_access_time_enabled = true
container_delete_retention_policy {
days = 7
Expand Down Expand Up @@ -1832,7 +1834,8 @@ resource "azurerm_storage_account" "test" {
account_replication_type = "LRS"

blob_properties {
versioning_enabled = true
versioning_enabled = true
change_feed_enabled = true
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString)
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/storage_account.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ A `blob_properties` block supports the following:

* `versioning_enabled` - (Optional) Is versioning enabled? Default to `false`.

* `change_feed_enabled` - (Optional) Is the blob service properties for change feed events enabled? Default to `false`.

* `default_service_version` - (Optional) The API Version which should be used by default for requests to the Data Plane API if an incoming request doesn't specify an API Version. Defaults to `2020-06-12`.

* `last_access_time_enabled` - (Optional) Is the last access time based tracking enabled? Default to `false`.
Expand Down