github.com/swisspost/terratest@v0.0.0-20230214120104-7ec6de2e1ae0/examples/terraform-aws-dynamodb-example/main.tf (about) 1 # --------------------------------------------------------------------------------------------------------------------- 2 # PIN TERRAFORM VERSION TO >= 0.12 3 # The examples have been upgraded to 0.12 syntax 4 # --------------------------------------------------------------------------------------------------------------------- 5 provider "aws" { 6 region = var.region 7 } 8 9 terraform { 10 # This module is now only being tested with Terraform 0.13.x. However, to make upgrading easier, we are setting 11 # 0.12.26 as the minimum version, as that version added support for required_providers with source URLs, making it 12 # forwards compatible with 0.13.x code. 13 required_version = ">= 0.12.26" 14 } 15 16 # --------------------------------------------------------------------------------------------------------------------- 17 # CREATE THE DYNAMODB TABLE 18 # --------------------------------------------------------------------------------------------------------------------- 19 20 resource "aws_dynamodb_table" "example" { 21 name = var.table_name 22 hash_key = "userId" 23 range_key = "department" 24 billing_mode = "PAY_PER_REQUEST" 25 26 server_side_encryption { 27 enabled = true 28 } 29 point_in_time_recovery { 30 enabled = true 31 } 32 33 attribute { 34 name = "userId" 35 type = "S" 36 } 37 attribute { 38 name = "department" 39 type = "S" 40 } 41 42 ttl { 43 enabled = true 44 attribute_name = "expires" 45 } 46 47 tags = { 48 Environment = "production" 49 } 50 } 51