Skip to content

Commit f7bb667

Browse files
Khuzaima-ShakeelKhuzaima-Shakeel
authored andcommitted
resolve review comments
1 parent 471407c commit f7bb667

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

variables.tf

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ variable "create_vpc" {
88
default = true
99

1010
validation {
11-
condition = var.create_vpc || var.existing_vpc_id != null
12-
error_message = "If 'create_vpc' is false, then you must provide a value for 'existing_vpc_id'."
11+
condition = !(var.create_vpc == false && var.existing_vpc_id == null)
12+
error_message = "You must either enable 'create_vpc' or provide 'existing_vpc_id', but not both or neither."
1313
}
1414

1515
validation {
1616
condition = !(var.create_vpc == false && var.create_subnets == true)
17-
error_message = "If 'create_vpc' is false, then 'create_subnets' must also be false. You cannot create subnets without providing a VPC."
17+
error_message = "If create_vpc is false, then create_subnets must also be false. You cannot create subnets without first creating a VPC."
1818
}
1919
}
2020

@@ -393,11 +393,6 @@ variable "create_subnets" {
393393
description = "Indicates whether user wants to use existing subnets or create new. Set it to true to create new subnets."
394394
type = bool
395395
default = true
396-
397-
validation {
398-
condition = var.create_subnets || length(var.existing_subnets) > 0
399-
error_message = "If 'create_subnets' is false, then you must provide a non-empty list for 'existing_subnets'."
400-
}
401396
}
402397

403398
variable "existing_subnets" {
@@ -408,6 +403,14 @@ variable "existing_subnets" {
408403
}))
409404
default = []
410405
nullable = false
406+
407+
validation {
408+
condition = (
409+
(var.create_subnets && length(var.existing_subnets) == 0) ||
410+
(!var.create_subnets && length(var.existing_subnets) > 0)
411+
)
412+
error_message = "You must either set 'create_subnets' to true and not provide 'existing_subnets', or set it to false and provide a non-empty list of 'existing_subnets'."
413+
}
411414
}
412415

413416
##############################################################################
@@ -471,8 +474,8 @@ variable "security_group_rules" {
471474
}
472475

473476
validation {
474-
error_message = "var.clean_default_sg_acl is true and var.security_group_rules are not empty, which are in direct conflict. If you want to clean the default SG, you must not pass security_group_rules."
475-
condition = !(var.clean_default_sg_acl && length(var.security_group_rules) > 0)
477+
condition = !(var.clean_default_sg_acl && var.security_group_rules != null && length(var.security_group_rules) > 0)
478+
error_message = "var.clean_default_sg_acl is true and var.security_group_rules are not empty, which are in direct conflict. If you want to clean the default VPC Security Group, you must not pass security_group_rules."
476479
}
477480
}
478481

@@ -531,7 +534,7 @@ variable "enable_vpc_flow_logs" {
531534
: (var.existing_storage_bucket_name != null)
532535
)
533536
)
534-
error_message = "To enable VPC flow logs, provide COS bucket name. If authorization policy creation is enabled, also provide COS instance GUID."
537+
error_message = "To enable VPC Flow Logs, provide COS Bucket name. If you're creating an authorization policy then also provide COS instance GUID."
535538
}
536539
}
537540

0 commit comments

Comments
 (0)