diff --git a/README.md b/README.md index c6d562f..021f929 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,9 @@ Terraform module to provision a DynamoDB table with autoscaling. Autoscaler scales up/down the provisioned OPS for the DynamoDB table based on the load. +## Requirements + +This module requires [AWS Provider](https://github.com/terraform-providers/terraform-provider-aws) `>= 1.17.0` ## Usage @@ -83,7 +86,10 @@ module "dynamodb_table" { | `hash_key` | `` | DynamoDB table Hash Key | Yes | | `range_key` | `` | DynamoDB table Range Key | Yes | | `ttl_attribute` | `` | DynamoDB table TTL attribute | No | +| `enable_streams` | `false` | Enable DynamoDB streams | No | +| `stream_view_type` | `` | When an item in the table is modified, what information is written to the stream | If `enable_streams` is true | | `enable_encryption` | `true` | Enable DynamoDB server-side encryption | No | +| `enable_point_in_time_recovery` | `true` | Enable DynamoDB point-in-time recovery | No | | `attributes` | `[]` | Additional attributes (_e.g._ `policy` or `role`) | No | | `tags` | `{}` | Additional tags (_e.g._ `map("BusinessUnit","XYZ")` | No | | `delimiter` | `-` | Delimiter to be used between `namespace`, `stage`, `name`, and `attributes` | No | diff --git a/main.tf b/main.tf index 8f0e352..b89adee 100644 --- a/main.tf +++ b/main.tf @@ -27,16 +27,22 @@ resource "null_resource" "global_secondary_indexes" { } resource "aws_dynamodb_table" "default" { - name = "${module.dynamodb_label.id}" - read_capacity = "${var.autoscale_min_read_capacity}" - write_capacity = "${var.autoscale_min_write_capacity}" - hash_key = "${var.hash_key}" - range_key = "${var.range_key}" + name = "${module.dynamodb_label.id}" + read_capacity = "${var.autoscale_min_read_capacity}" + write_capacity = "${var.autoscale_min_write_capacity}" + hash_key = "${var.hash_key}" + range_key = "${var.range_key}" + stream_enabled = "${var.enable_streams}" + stream_view_type = "${var.stream_view_type}" server_side_encryption { enabled = "${var.enable_encryption}" } + point_in_time_recovery { + enabled = "${var.enable_point_in_time_recovery}" + } + lifecycle { ignore_changes = ["read_capacity", "write_capacity"] } diff --git a/variables.tf b/variables.tf index e8c4a57..4a4bf24 100644 --- a/variables.tf +++ b/variables.tf @@ -61,12 +61,30 @@ variable "autoscale_max_write_capacity" { description = "DynamoDB autoscaling max write capacity" } +variable "enable_streams" { + type = "string" + default = "false" + description = "Enable DynamoDB streams" +} + +variable "stream_view_type" { + type = "string" + default = "" + description = "When an item in the table is modified, what information is written to the stream" +} + variable "enable_encryption" { type = "string" default = "true" description = "Enable DynamoDB server-side encryption" } +variable "enable_point_in_time_recovery" { + type = "string" + default = "true" + description = "Enable DynamoDB point in time recovery" +} + variable "hash_key" { type = "string" description = "DynamoDB table Hash Key"