github.com/darmach/terratest@v0.34.8-0.20210517103231-80931f95e3ff/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  
     6  terraform {
     7    # This module is now only being tested with Terraform 0.13.x. However, to make upgrading easier, we are setting
     8    # 0.12.26 as the minimum version, as that version added support for required_providers with source URLs, making it
     9    # forwards compatible with 0.13.x code.
    10    required_version = ">= 0.12.26"
    11  }
    12  
    13  # ---------------------------------------------------------------------------------------------------------------------
    14  # CREATE THE DYNAMODB TABLE
    15  # ---------------------------------------------------------------------------------------------------------------------
    16  
    17  resource "aws_dynamodb_table" "example" {
    18    name         = var.table_name
    19    hash_key     = "userId"
    20    range_key    = "department"
    21    billing_mode = "PAY_PER_REQUEST"
    22  
    23    server_side_encryption {
    24      enabled = true
    25    }
    26    point_in_time_recovery {
    27      enabled = true
    28    }
    29  
    30    attribute {
    31      name = "userId"
    32      type = "S"
    33    }
    34    attribute {
    35      name = "department"
    36      type = "S"
    37    }
    38  
    39    ttl {
    40      enabled        = true
    41      attribute_name = "expires"
    42    }
    43  
    44    tags = {
    45      Environment = "production"
    46    }
    47  }
    48