Skip to content

Commit d974f34

Browse files
authored
Add variables to specify data types for Hash and Range keys (#25)
1 parent f973d85 commit d974f34

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ Available targets:
148148
lint Lint terraform code
149149
150150
```
151-
152151
## Inputs
153152

154153
| Name | Description | Type | Default | Required |
@@ -168,10 +167,12 @@ Available targets:
168167
| enable_streams | Enable DynamoDB streams | string | `false` | no |
169168
| global_secondary_index_map | Additional global secondary indexes in the form of a list of mapped values | list | `<list>` | no |
170169
| hash_key | DynamoDB table Hash Key | string | - | yes |
170+
| hash_key_type | Hash Key type, which must be a scalar type: `S`, `N`, or `B` for (S)tring, (N)umber or (B)inary data | string | `S` | no |
171171
| local_secondary_index_map | Additional local secondary indexes in the form of a list of mapped values | list | `<list>` | no |
172172
| name | Name (e.g. `app` or `cluster`) | string | - | yes |
173173
| namespace | Namespace (e.g. `eg` or `cp`) | string | - | yes |
174174
| range_key | DynamoDB table Range Key | string | `` | no |
175+
| range_key_type | Range Key type, which must be a scalar type: `S`, `N`, or `B` for (S)tring, (N)umber or (B)inary data | string | `S` | no |
175176
| stage | Stage (e.g. `prod`, `dev`, `staging`, `infra`) | string | - | yes |
176177
| stream_view_type | When an item in the table is modified, what information is written to the stream | string | `` | no |
177178
| tags | Additional tags (e.g. map(`BusinessUnit`,`XYZ`) | map | `<map>` | no |

docs/terraform.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
## Inputs
32

43
| Name | Description | Type | Default | Required |
@@ -18,10 +17,12 @@
1817
| enable_streams | Enable DynamoDB streams | string | `false` | no |
1918
| global_secondary_index_map | Additional global secondary indexes in the form of a list of mapped values | list | `<list>` | no |
2019
| hash_key | DynamoDB table Hash Key | string | - | yes |
20+
| hash_key_type | Hash Key type, which must be a scalar type: `S`, `N`, or `B` for (S)tring, (N)umber or (B)inary data | string | `S` | no |
2121
| local_secondary_index_map | Additional local secondary indexes in the form of a list of mapped values | list | `<list>` | no |
2222
| name | Name (e.g. `app` or `cluster`) | string | - | yes |
2323
| namespace | Namespace (e.g. `eg` or `cp`) | string | - | yes |
2424
| range_key | DynamoDB table Range Key | string | `` | no |
25+
| range_key_type | Range Key type, which must be a scalar type: `S`, `N`, or `B` for (S)tring, (N)umber or (B)inary data | string | `S` | no |
2526
| stage | Stage (e.g. `prod`, `dev`, `staging`, `infra`) | string | - | yes |
2627
| stream_view_type | When an item in the table is modified, what information is written to the stream | string | `` | no |
2728
| tags | Additional tags (e.g. map(`BusinessUnit`,`XYZ`) | map | `<map>` | no |

main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module "dynamodb_label" {
2-
source = "git::https://github.com/cloudposse/terraform-terraform-label.git?ref=tags/0.1.6"
2+
source = "git::https://github.com/cloudposse/terraform-terraform-label.git?ref=tags/0.2.1"
33
namespace = "${var.namespace}"
44
stage = "${var.stage}"
55
name = "${var.name}"
@@ -12,11 +12,11 @@ locals {
1212
attributes = [
1313
{
1414
name = "${var.range_key}"
15-
type = "S"
15+
type = "${var.range_key_type}"
1616
},
1717
{
1818
name = "${var.hash_key}"
19-
type = "S"
19+
type = "${var.hash_key_type}"
2020
},
2121
"${var.dynamodb_attributes}",
2222
]
@@ -80,7 +80,7 @@ resource "aws_dynamodb_table" "default" {
8080
}
8181

8282
module "dynamodb_autoscaler" {
83-
source = "git::https://github.com/cloudposse/terraform-aws-dynamodb-autoscaler.git?ref=tags/0.2.4"
83+
source = "git::https://github.com/cloudposse/terraform-aws-dynamodb-autoscaler.git?ref=tags/0.2.5"
8484
enabled = "${var.enable_autoscaler}"
8585
namespace = "${var.namespace}"
8686
stage = "${var.stage}"

variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,24 @@ variable "hash_key" {
9090
description = "DynamoDB table Hash Key"
9191
}
9292

93+
variable "hash_key_type" {
94+
type = "string"
95+
default = "S"
96+
description = "Hash Key type, which must be a scalar type: `S`, `N`, or `B` for (S)tring, (N)umber or (B)inary data"
97+
}
98+
9399
variable "range_key" {
94100
type = "string"
95101
default = ""
96102
description = "DynamoDB table Range Key"
97103
}
98104

105+
variable "range_key_type" {
106+
type = "string"
107+
default = "S"
108+
description = "Range Key type, which must be a scalar type: `S`, `N`, or `B` for (S)tring, (N)umber or (B)inary data"
109+
}
110+
99111
variable "ttl_attribute" {
100112
type = "string"
101113
default = "Expires"

0 commit comments

Comments
 (0)