Skip to content

Commit

Permalink
Merge pull request #21 from habr-mms/enhanced_settings_for_nfs
Browse files Browse the repository at this point in the history
feat: Settings for nfs
  • Loading branch information
habr-mms authored Mar 17, 2023
2 parents 2162402 + 6396428 commit bb5d209
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 18 deletions.
20 changes: 20 additions & 0 deletions examples/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ module "storage" {
service = "service_name"
}
}
filestorage = {
name = "servicefilestg"
resource_group_name = "service-infrastructure-rg"
location = "westeurope"
account_kind = "FileStorage"
account_tier = "Premium"
account_replication_type = "LRS"
enable_https_traffic_only = false
tags = {
service = "service_name"
}
}
}
storage_container = {
terraform = {
Expand All @@ -23,4 +35,12 @@ module "storage" {
}
}
}
storage_share = {
nfsfiles = {
storage_account_name = module.storage.storage_account.filestorage.name
access_tier = "Premium"
enabled_protocol = "NFS"
quota = 100
}
}
}
18 changes: 10 additions & 8 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ resource "azurerm_storage_account" "storage_account" {
}

dynamic "blob_properties" {
for_each = local.storage_account[each.key].blob_properties != {} ? [1] : []
for_each = local.storage_account[each.key].account_kind != "FileStorage" ? [1] : []
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
Expand Down Expand Up @@ -84,7 +84,7 @@ resource "azurerm_storage_account" "storage_account" {
}

dynamic "queue_properties" {
for_each = local.storage_account[each.key].queue_properties != {} ? [1] : []
for_each = local.storage_account[each.key].queue_properties.cors_rule != {} || local.storage_account[each.key].queue_properties.logging != {} || local.storage_account[each.key].queue_properties.minute_metrics != {} || local.storage_account[each.key].queue_properties.hour_metrics != {} ? [1] : []
content {
dynamic "cors_rule" {
for_each = local.storage_account[each.key].queue_properties.cors_rule
Expand Down Expand Up @@ -198,19 +198,21 @@ resource "azurerm_storage_share" "storage_share" {
name = local.storage_share[each.key].name == "" ? each.key : local.storage_share[each.key].name
metadata = local.storage_share[each.key].metadata
storage_account_name = local.storage_share[each.key].storage_account_name
access_tier = local.storage_share[each.key].access_tier
enabled_protocol = local.storage_share[each.key].enabled_protocol
quota = local.storage_share[each.key].quota

dynamic "acl" {
for_each = local.storage_account[each.key].acl == true ? [1] : []
for_each = local.storage_share[each.key].acl != {} ? [1] : []
content {
id = local.storage_account[each.key].acl[acl.key].id
id = local.storage_share[each.key].acl[acl.key].id

dynamic "access_policy" {
for_each = local.storage_account[each.key].acl[acl.key].access_policy
for_each = local.storage_share[each.key].acl[acl.key].access_policy != {} ? [1] : []
content {
permissions = local.storage_account[each.key].acl[acl.key].access_policy[access_policy.key].permissions
start = local.storage_account[each.key].acl[acl.key].access_policy[access_policy.key].start
expiry = local.storage_account[each.key].acl[acl.key].access_policy[access_policy.key].expiry
permissions = local.storage_share[each.key].acl[acl.key].access_policy[access_policy.key].permissions
start = local.storage_share[each.key].acl[acl.key].access_policy[access_policy.key].start
expiry = local.storage_share[each.key].acl[acl.key].access_policy[access_policy.key].expiry
}
}
}
Expand Down
16 changes: 7 additions & 9 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,13 @@ locals {
tags = {}
}
storage_share = {
name = ""
metadata = {}
quota = "50"
acl = {
permissions = "rl"
start = ""
expiry = ""
}
tags = {}
name = ""
metadata = {}
access_tier = "Hot"
enabled_protocol = null
quota = "50"
acl = {}
tags = {}
}
storage_share_directory = {
name = ""
Expand Down
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
azurerm = {
source = "registry.terraform.io/hashicorp/azurerm"
version = ">=3.5"
version = ">=3.6"
}
}
required_version = ">=1.1"
Expand Down

0 comments on commit bb5d209

Please sign in to comment.