Fix validation blocks in AWS bootstrap identity variables

This commit is contained in:
cloudneutral 2025-12-10 15:28:32 +08:00
parent cb065aae70
commit b2b2807a73

View File

@ -14,6 +14,11 @@ variable "create_role" {
description = "Whether to create the Terraform deploy IAM role"
type = bool
default = true
validation {
condition = var.create_role || (var.existing_role_arn != null && var.existing_role_name != null)
error_message = "existing_role_name and existing_role_arn must be provided when create_role is false."
}
}
variable "existing_role_name" {
@ -34,12 +39,6 @@ variable "role_name" {
default = null
}
variable "create_user" {
description = "Whether to create the IAM user for Terraform"
type = bool
default = true
}
variable "existing_user_name" {
description = "Existing IAM username to reference when create_user is false"
type = string
@ -52,12 +51,13 @@ variable "terraform_user_name" {
default = null
}
validation "require_existing_role_arn_when_not_creating" {
condition = var.create_role || (var.existing_role_arn != null && var.existing_role_name != null)
error_message = "existing_role_name and existing_role_arn must be provided when create_role is false."
}
variable "create_user" {
description = "Whether to create the IAM user for Terraform"
type = bool
default = true
validation "require_existing_user_name_when_not_creating" {
condition = var.create_user || var.existing_user_name != null
error_message = "existing_user_name must be provided when create_user is false."
validation {
condition = var.create_user || var.existing_user_name != null
error_message = "existing_user_name must be provided when create_user is false."
}
}