forked from cloudposse/terraform-aws-dynamodb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.yaml
196 lines (176 loc) · 6.64 KB
/
README.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#
# This is the canonical configuration for the `README.md`
# Run `make readme` to rebuild the `README.md`
#
# Name of this project
name: terraform-aws-dynamodb
# Tags of this project
tags:
- aws
- terraform
- terraform-modules
- databases
- autoscaling
- dynamodb
- dynamodb-table
- dynamodb-database
# Categories of this project
categories:
- terraform-modules/databases
# Logo for this project
#logo: docs/logo.png
# License of this project
license: "APACHE2"
# Canonical GitHub repo
github_repo: cloudposse/terraform-aws-dynamodb
# Badges to display
badges:
- name: "Latest Release"
image: "https://img.shields.io/github/release/cloudposse/terraform-aws-dynamodb.svg"
url: "https://github.com/cloudposse/terraform-aws-dynamodb/releases/latest"
- name: "Slack Community"
image: "https://slack.cloudposse.com/badge.svg"
url: "https://slack.cloudposse.com"
related:
- name: "terraform-aws-dynamodb-autoscaler"
description: "Terraform module to provision DynamoDB autoscaler"
url: "https://github.com/cloudposse/terraform-aws-dynamodb-autoscaler"
- name: "terraform-aws-tfstate-backend"
description: "Provision an S3 bucket to store terraform.tfstate file and a DynamoDB table to lock the state file to prevent concurrent modifications and state corruption"
url: "https://github.com/cloudposse/terraform-aws-tfstate-backend"
- name: "terraform-aws-elasticache-redis"
description: "Terraform module to provision an ElastiCache Redis Cluster"
url: "https://github.com/cloudposse/terraform-aws-elasticache-redis"
- name: "terraform-aws-elasticache-memcached"
description: "Terraform Module for ElastiCache Memcached Cluster"
url: "https://github.com/cloudposse/terraform-aws-elasticache-memcached"
- name: "terraform-aws-elasticache-cloudwatch-sns-alarms"
description: "Terraform module that configures CloudWatch SNS alerts for ElastiCache"
url: "https://github.com/cloudposse/terraform-aws-elasticache-cloudwatch-sns-alarms"
- name: "terraform-aws-rds-cluster"
description: "Terraform module to provision an RDS Aurora cluster for MySQL or Postgres"
url: "https://github.com/cloudposse/terraform-aws-rds-cluster"
- name: "terraform-aws-rds"
description: "Terraform module to provision AWS RDS instances"
url: "https://github.com/cloudposse/terraform-aws-rds"
# Short description of this project
description: |-
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`
# How to use this project
usage: |2-
For a complete example, see [examples/complete](examples/complete).
For automated tests of the complete example using [bats](https://github.com/bats-core/bats-core) and [Terratest](https://github.com/gruntwork-io/terratest) (which tests and deploys the example on AWS), see [test](test).
```hcl
module "dynamodb_table" {
source = "cloudposse/dynamodb/aws"
# Cloud Posse recommends pinning every module to a specific version
# version = "x.x.x"
namespace = "eg"
stage = "dev"
name = "cluster"
hash_key = "HashKey"
range_key = "RangeKey"
autoscale_write_target = 50
autoscale_read_target = 50
autoscale_min_read_capacity = 5
autoscale_max_read_capacity = 20
autoscale_min_write_capacity = 5
autoscale_max_write_capacity = 20
enable_autoscaler = true
}
```
## Advanced Usage
With additional attributes, global secondary indexes and `non_key_attributes` (see [examples/complete](examples/complete)).
```hcl
module "dynamodb_table" {
source = "cloudposse/dynamodb/aws"
# Cloud Posse recommends pinning every module to a specific version
# version = "x.x.x"
namespace = "eg"
stage = "dev"
name = "cluster"
hash_key = "HashKey"
range_key = "RangeKey"
autoscale_write_target = 50
autoscale_read_target = 50
autoscale_min_read_capacity = 5
autoscale_max_read_capacity = 20
autoscale_min_write_capacity = 5
autoscale_max_write_capacity = 20
enable_autoscaler = true
dynamodb_attributes = [
{
name = "DailyAverage"
type = "N"
},
{
name = "HighWater"
type = "N"
},
{
name = "Timestamp"
type = "S"
}
]
local_secondary_index_map = [
{
name = "TimestampSortIndex"
range_key = "Timestamp"
projection_type = "INCLUDE"
non_key_attributes = ["HashKey", "RangeKey"]
},
{
name = "HighWaterIndex"
range_key = "Timestamp"
projection_type = "INCLUDE"
non_key_attributes = ["HashKey", "RangeKey"]
}
]
global_secondary_index_map = [
{
name = "DailyAverageIndex"
hash_key = "DailyAverage"
range_key = "HighWater"
write_capacity = 5
read_capacity = 5
projection_type = "INCLUDE"
non_key_attributes = ["HashKey", "RangeKey"]
}
]
replicas = ["us-east-1"]
}
```
__NOTE:__ Variables "global_secondary_index_map" and "local_secondary_index_map" have a predefined schema, but in some cases not all fields are required or needed.
For example:
* `non_key_attributes` can't be specified for Global Secondary Indexes (GSIs) when `projection_type` is `ALL`
* `read_capacity` and `write_capacity` are not required for GSIs
In these cases, set the fields to `null` and Terraform will treat them as if they were not provided at all, but will not complain about missing values:
```hcl
global_secondary_index_map = [
{
write_capacity = null
read_capacity = null
projection_type = "ALL"
non_key_attributes = null
}
]
```
See [Terraform types and values](https://www.terraform.io/docs/configuration/expressions.html#types-and-values) for more details.
include:
- "docs/targets.md"
- "docs/terraform.md"
# Contributors to this project
contributors:
- name: "Erik Osterman"
github: "osterman"
- name: "Andriy Knysh"
github: "aknysh"
- name: "Jamie Nelson"
github: "Jamie-BitFlight"
- name: "Daren Desjardins"
github: "darend"
- name: "Maarten van der Hoef"
github: "maartenvanderhoef"