Difference between revisions of "Terraform resource: aws dynamodb table"

From wikieduonline
Jump to navigation Jump to search
Tags: Mobile web edit, Mobile edit
Tags: Mobile web edit, Mobile edit
 
Line 13: Line 13:
 
   [[hash_key]]      = "UserId"
 
   [[hash_key]]      = "UserId"
 
   range_key      = "GameTitle"
 
   range_key      = "GameTitle"
 
+
 
   attribute {
 
   attribute {
 
     name = "UserId"
 
     name = "UserId"
 
     type = "S"
 
     type = "S"
 
   }
 
   }
 
+
 
   attribute {
 
   attribute {
 
     name = "GameTitle"
 
     name = "GameTitle"
 
     type = "S"
 
     type = "S"
 
   }
 
   }
 
+
 
   attribute {
 
   attribute {
 
     name = "TopScore"
 
     name = "TopScore"
 
     type = "N"
 
     type = "N"
 
   }
 
   }
 
+
 
   ttl {
 
   ttl {
 
     attribute_name = "TimeToExist"
 
     attribute_name = "TimeToExist"
 
     enabled        = false
 
     enabled        = false
 
   }
 
   }
 
+
 
   global_secondary_index {
 
   global_secondary_index {
 
     name              = "GameTitleIndex"
 
     name              = "GameTitleIndex"
 
     hash_key          = "GameTitle"
 
     hash_key          = "GameTitle"
 
     range_key          = "TopScore"
 
     range_key          = "TopScore"
     write_capacity    = 10
+
     [[write_capacity]]     = 10
     read_capacity      = 10
+
     [[read_capacity]]     = 10
 
     projection_type    = "INCLUDE"
 
     projection_type    = "INCLUDE"
 
     non_key_attributes = ["UserId"]
 
     non_key_attributes = ["UserId"]

Latest revision as of 04:51, 28 March 2023

aws_dynamodb_table

  • billing_mode: [ PROVISIONED | PAY_PER_REQUEST ]

Official example[edit]

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"
 }

 attribute {
   name = "TopScore"
   type = "N"
 }

 ttl {
   attribute_name = "TimeToExist"
   enabled        = false
 }

 global_secondary_index {
   name               = "GameTitleIndex"
   hash_key           = "GameTitle"
   range_key          = "TopScore"
   write_capacity     = 10
   read_capacity      = 10
   projection_type    = "INCLUDE"
   non_key_attributes = ["UserId"]
 }
 tags = {
   Name        = "dynamodb-table-1"
   Environment = "production"
 }
}

See also[edit]

Advertising: