diff --git a/main.tf b/main.tf index 2cce087..161c87f 100644 --- a/main.tf +++ b/main.tf @@ -56,16 +56,16 @@ resource "azurerm_storage_account" "storage_account" { content { versioning_enabled = local.storage_account[each.key].blob_properties.versioning_enabled change_feed_enabled = local.storage_account[each.key].blob_properties.change_feed_enabled - default_service_version = local.storage_account[each.key].blob_properties.change_feed_default_service_versionenabled + default_service_version = local.storage_account[each.key].blob_properties.default_service_version last_access_time_enabled = local.storage_account[each.key].blob_properties.last_access_time_enabled dynamic "cors_rule" { for_each = local.storage_account[each.key].blob_properties.cors_rule content { - allowed_headers = local.storage_account[each.key].blob_properties.cors_rule.allowed_headers - allowed_methods = local.storage_account[each.key].blob_properties.cors_rule.allowed_methods - allowed_origins = local.storage_account[each.key].blob_properties.cors_rule.allowed_origins - exposed_headers = local.storage_account[each.key].blob_properties.cors_rule.exposed_headers - max_age_in_seconds = local.storage_account[each.key].blob_properties.cors_rule.max_age_in_seconds + allowed_headers = local.storage_account[each.key].blob_properties.cors_rule[cors_rule.key].allowed_headers + allowed_methods = local.storage_account[each.key].blob_properties.cors_rule[cors_rule.key].allowed_methods + allowed_origins = local.storage_account[each.key].blob_properties.cors_rule[cors_rule.key].allowed_origins + exposed_headers = local.storage_account[each.key].blob_properties.cors_rule[cors_rule.key].exposed_headers + max_age_in_seconds = local.storage_account[each.key].blob_properties.cors_rule[cors_rule.key].max_age_in_seconds } } dynamic "delete_retention_policy" { @@ -77,7 +77,7 @@ resource "azurerm_storage_account" "storage_account" { dynamic "container_delete_retention_policy" { for_each = local.storage_account[each.key].blob_properties.container_delete_retention_policy content { - days = local.storage_account[each.key].blob_properties.delete_retention_policy.days + days = local.storage_account[each.key].blob_properties.container_delete_retention_policy.days } } } @@ -89,11 +89,11 @@ resource "azurerm_storage_account" "storage_account" { dynamic "cors_rule" { for_each = local.storage_account[each.key].queue_properties.cors_rule content { - allowed_headers = local.storage_account[each.key].queue_properties.cors_rule.allowed_headers - allowed_methods = local.storage_account[each.key].queue_properties.cors_rule.allowed_methods - allowed_origins = local.storage_account[each.key].queue_properties.cors_rule.allowed_origins - exposed_headers = local.storage_account[each.key].queue_properties.cors_rule.exposed_headers - max_age_in_seconds = local.storage_account[each.key].queue_properties.cors_rule.max_age_in_seconds + allowed_headers = local.storage_account[each.key].queue_properties.cors_rule[cors_rule.key].allowed_headers + allowed_methods = local.storage_account[each.key].queue_properties.cors_rule[cors_rule.key].allowed_methods + allowed_origins = local.storage_account[each.key].queue_properties.cors_rule[cors_rule.key].allowed_origins + exposed_headers = local.storage_account[each.key].queue_properties.cors_rule[cors_rule.key].exposed_headers + max_age_in_seconds = local.storage_account[each.key].queue_properties.cors_rule[cors_rule.key].max_age_in_seconds } } dynamic "logging" { diff --git a/variables.tf b/variables.tf index a961af0..2c52f01 100644 --- a/variables.tf +++ b/variables.tf @@ -49,9 +49,22 @@ locals { type = "" identity_ids = null } - blob_properties = {} - queue_properties = {} - static_website = {} + blob_properties = { + versioning_enabled = false + change_feed_enabled = false + default_service_version = "2020-06-12" + last_access_time_enabled = false + cors_rule = {} + delete_retention_policy = {} + container_delete_retention_policy = {} + } + queue_properties = { + cors_rule = {} + logging = {} + minute_metrics = {} + hour_metrics = {} + } + static_website = {} network_rules = { default_action = "" bypass = null @@ -94,6 +107,18 @@ locals { for storage_account in keys(var.storage_account) : storage_account => merge(local.default.storage_account, var.storage_account[storage_account]) } + storage_account_blob_properties_values = { + for storage_account in keys(var.storage_account) : + storage_account => { + blob_properties = merge(local.default.storage_account.blob_properties, local.storage_account_values[storage_account].blob_properties) + } + } + storage_account_queue_properties_values = { + for storage_account in keys(var.storage_account) : + storage_account => { + queue_properties = merge(local.default.storage_account.queue_properties, local.storage_account_values[storage_account].queue_properties) + } + } storage_share_values = { for storage_share in keys(var.storage_share) : storage_share => merge(local.default.storage_share, var.storage_share[storage_share]) @@ -108,6 +133,28 @@ locals { #for config in ["custom_domain", "customer_managed_key", "identity", "blob_properties", "queue_properties", "static_website", "network_rules", "azure_files_authentication", "routing", "queue_encryption_key_type", "table_encryption_key_type", "infrastructure_encryption_enabled"] : for config in ["custom_domain", "customer_managed_key", "identity", "static_website", "azure_files_authentication", "routing", ] : config => merge(local.default.storage_account[config], local.storage_account_values[storage_account][config]) + }, + { + blob_properties = merge( + local.storage_account_blob_properties_values[storage_account].blob_properties, + { + cors_rule = { + for key in keys(local.storage_account_blob_properties_values[storage_account].blob_properties.cors_rule) : + key => merge(local.default.storage_account.blob_properties.cors_rule, local.storage_account_blob_properties_values[storage_account].blob_properties.cors_rule[key]) + } + } + ) + }, + { + queue_properties = merge( + local.storage_account_queue_properties_values[storage_account].queue_properties, + { + cors_rule = { + for key in keys(local.storage_account_queue_properties_values[storage_account].queue_properties.cors_rule) : + key => merge(local.default.storage_account.queue_properties.cors_rule, local.storage_account_queue_properties_values[storage_account].queue_properties.cors_rule[key]) + } + } + ) } ) }