diff --git a/main.tf b/main.tf index 464c4e2..e6bd8fd 100644 --- a/main.tf +++ b/main.tf @@ -3,7 +3,20 @@ ################################################################################ locals { - create_smb_active_directory_settings = (var.join_smb_domain == true && length(var.domain_controllers) > 0 && length(var.domain_name) > 0 && length(var.domain_password) > 0 && length(var.domain_username) > 0) + + # Check whether all SMB Active Directory Settings are present + join_smb_domain_true = var.join_smb_domain == true + domain_controllers_exist = length(var.domain_controllers) > 0 + domain_name_exists = length(var.domain_name) > 0 + domain_password_exists = length(var.domain_password) > 0 + domain_username_exists = length(var.domain_username) > 0 + + create_smb_active_directory_settings = (local.join_smb_domain_true && + local.domain_controllers_exist && + local.domain_name_exists && + local.domain_password_exists && + local.domain_username_exists) + } resource "aws_storagegateway_gateway" "mysgw" { diff --git a/modules/s3-nfs-share/main.tf b/modules/s3-nfs-share/main.tf index e9aa5f0..93f3a01 100644 --- a/modules/s3-nfs-share/main.tf +++ b/modules/s3-nfs-share/main.tf @@ -22,8 +22,6 @@ resource "aws_storagegateway_nfs_file_share" "nfsshare" { cache_stale_timeout_in_seconds = var.cache_timout } - tags = { - Environment = "dev" - Application = "serviceA" - } + tags = var.tags + } diff --git a/modules/s3-nfs-share/variables.tf b/modules/s3-nfs-share/variables.tf index 5d2cbe8..aa53a1b 100644 --- a/modules/s3-nfs-share/variables.tf +++ b/modules/s3-nfs-share/variables.tf @@ -43,6 +43,11 @@ variable "cache_timout" { type = number description = "Cache stale timeout for automated cache refresh in seconds. Default is set to 1 hour (3600 seconds) can be changed to as low as 5 minutes (300 seconds)" default = "3600" + + validation { + condition = var.cache_timout == 0 || (var.cache_timout >= 300 && var.cache_timout <= 2592000) + error_message = "Valid Values for Cache Stale Timeout: 0, 300 to 2,592,000 seconds (5 minutes to 30 days)" + } } variable "directory_mode" { @@ -83,3 +88,9 @@ variable "owner_id" { } } +variable "tags" { + type = map(any) + description = "(Optional) Key-value map of resource tags." + default = {} +} +