Skip to content

Commit

Permalink
Add support for point-in-time recovery and streams (#9)
Browse files Browse the repository at this point in the history
* Add support for point-in-time recovery

* Add support for streams

* Fix variable name

* fix default value

* Document minimum provider version

* Add stream_view_type
  • Loading branch information
darend authored and aknysh committed Jun 8, 2018
1 parent 3a428bb commit 7f2ebb3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 |
Expand Down
16 changes: 11 additions & 5 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
Expand Down
18 changes: 18 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 7f2ebb3

Please sign in to comment.