Skip to content

Commit

Permalink
Support for change_feed_enabled in azurerm_storage_account (#11695)
Browse files Browse the repository at this point in the history
Fix #6627

=== RUN TestAccStorageAccount_blobProperties
=== PAUSE TestAccStorageAccount_blobProperties
=== CONT TestAccStorageAccount_blobProperties
--- PASS: TestAccStorageAccount_blobProperties (325.58s)

All tests have passed.
  • Loading branch information
yupwei68 authored May 13, 2021
1 parent 841514a commit 7189cba
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
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 @@ -1798,6 +1804,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 @@ -1823,6 +1832,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 @@ -2201,11 +2214,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 @@ -2221,6 +2238,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 @@ -1773,6 +1774,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 @@ -1849,7 +1851,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

0 comments on commit 7189cba

Please sign in to comment.