Hi,
I am trying to map the enum values to dynamodb attributes on terraform. However it’s not working…
I also tried by adding validation check for those enums while inserting data but it’s not working.
Someone help me please…
Thanks…
The below is something raw that I am trying on terraform 0.14. For eg:, As explained below I want game title value to throw error if someone inserts alphabet “d”.
Note*: Looking for enums kind of type but as you know terraform supports only B, N, S.
I am new to terraform and trying to understand.
dynamosample.tf
————————
resource "aws_dynamodb_table" "basic-dynamodb-table" {
name = "GameScores"
billing_mode = "PROVISIONED"
read_capacity = 20
write_capacity = 20
hash_key = "UserId"
range_key = "GameTitle"
attribute {
name = "UserId"
type = "S"
}
attribute {
name = "GameTitle"
type = "S"
value=var.input_variable
}
Variables.tf
——————
variable “input_parameter” {
type = string
default = “a”
validation {
condition = contains([“a”, “b”, “c”], var.input_parameter)
error_message = “Allowed values for input_parameter are "a", "b", or "c".”
}
}