DynamoDB attribute enum mapping in terraform


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…


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.


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"


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".”

Could you explain in more detail exactly what you are trying to do and could you include the core you are trying, that isn’t working?

Hey Kumar,

There is no value in attribute. You are only defining attributes here, Please refer to the documentation here


Yes I know that, I just given some raw code what iam trying to do for understanding. How should I map those predefined values(enum types) to that attribute or how should I add validation to those attribute values someone enters data to dynamodb?