Skip to content

Commit e47cf5f

Browse files
authored
on_demand_throughput (#90)
1 parent 0e806ea commit e47cf5f

File tree

15 files changed

+68
-14
lines changed

15 files changed

+68
-14
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ Users of Terragrunt can achieve similar results by using modules provided in the
6868
| Name | Version |
6969
|------|---------|
7070
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
71-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.64 |
71+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.72.1 |
7272

7373
## Providers
7474

7575
| Name | Version |
7676
|------|---------|
77-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.64 |
77+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.72.1 |
7878

7979
## Modules
8080

@@ -115,6 +115,7 @@ No modules.
115115
| <a name="input_import_table"></a> [import\_table](#input\_import\_table) | Configurations for importing s3 data into a new table. | `any` | `{}` | no |
116116
| <a name="input_local_secondary_indexes"></a> [local\_secondary\_indexes](#input\_local\_secondary\_indexes) | Describe an LSI on the table; these can only be allocated at creation so you cannot change this definition after you have created the resource. | `any` | `[]` | no |
117117
| <a name="input_name"></a> [name](#input\_name) | Name of the DynamoDB table | `string` | `null` | no |
118+
| <a name="input_on_demand_throughput"></a> [on\_demand\_throughput](#input\_on\_demand\_throughput) | Sets the maximum number of read and write units for the specified on-demand table | `any` | `{}` | no |
118119
| <a name="input_point_in_time_recovery_enabled"></a> [point\_in\_time\_recovery\_enabled](#input\_point\_in\_time\_recovery\_enabled) | Whether to enable point-in-time recovery | `bool` | `false` | no |
119120
| <a name="input_range_key"></a> [range\_key](#input\_range\_key) | The attribute to use as the range (sort) key. Must also be defined as an attribute | `string` | `null` | no |
120121
| <a name="input_read_capacity"></a> [read\_capacity](#input\_read\_capacity) | The number of read units for this table. If the billing\_mode is PROVISIONED, this field should be greater than 0 | `number` | `null` | no |

examples/autoscaling/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Note that this example may create resources which can cost money (AWS Elastic IP
2020
| Name | Version |
2121
|------|---------|
2222
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
23-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.64 |
23+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.72.1 |
2424
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2.0 |
2525

2626
## Providers

examples/autoscaling/versions.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 5.64"
7+
version = ">= 5.72.1"
88
}
99
random = {
1010
source = "hashicorp/random"

examples/basic/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Note that this example may create resources which can cost money (AWS Elastic IP
2020
| Name | Version |
2121
|------|---------|
2222
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
23-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.64 |
23+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.72.1 |
2424
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2.0 |
2525

2626
## Providers

examples/basic/main.tf

+10
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,19 @@ module "dynamodb_table" {
3737
range_key = "age"
3838
projection_type = "INCLUDE"
3939
non_key_attributes = ["id"]
40+
41+
on_demand_throughput = {
42+
max_write_request_units = 1
43+
max_read_request_units = 1
44+
}
4045
}
4146
]
4247

48+
on_demand_throughput = {
49+
max_read_request_units = 1
50+
max_write_request_units = 1
51+
}
52+
4353
tags = {
4454
Terraform = "true"
4555
Environment = "staging"

examples/basic/versions.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 5.64"
7+
version = ">= 5.72.1"
88
}
99
random = {
1010
source = "hashicorp/random"

examples/global-tables/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ Note that this example may create resources which can cost money (AWS Elastic IP
2020
| Name | Version |
2121
|------|---------|
2222
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
23-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.64 |
23+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.72.1 |
2424
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2.0 |
2525

2626
## Providers
2727

2828
| Name | Version |
2929
|------|---------|
30-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.64 |
31-
| <a name="provider_aws.euwest2"></a> [aws.euwest2](#provider\_aws.euwest2) | >= 5.64 |
30+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.72.1 |
31+
| <a name="provider_aws.euwest2"></a> [aws.euwest2](#provider\_aws.euwest2) | >= 5.72.1 |
3232
| <a name="provider_random"></a> [random](#provider\_random) | >= 2.0 |
3333

3434
## Modules

examples/global-tables/versions.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 5.64"
7+
version = ">= 5.72.1"
88
}
99
random = {
1010
source = "hashicorp/random"

examples/s3-import/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Note that this example may create resources which can cost money (AWS Elastic IP
2020
| Name | Version |
2121
|------|---------|
2222
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
23-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.64 |
23+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.72.1 |
2424
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2.0 |
2525

2626
## Providers

examples/s3-import/versions.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 5.64"
7+
version = ">= 5.72.1"
88
}
99
random = {
1010
source = "hashicorp/random"

main.tf

+36
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ resource "aws_dynamodb_table" "this" {
5656
read_capacity = lookup(global_secondary_index.value, "read_capacity", null)
5757
write_capacity = lookup(global_secondary_index.value, "write_capacity", null)
5858
non_key_attributes = lookup(global_secondary_index.value, "non_key_attributes", null)
59+
60+
dynamic "on_demand_throughput" {
61+
for_each = try([global_secondary_index.value.on_demand_throughput], [])
62+
63+
content {
64+
max_read_request_units = try(on_demand_throughput.value.max_read_request_units, null)
65+
max_write_request_units = try(on_demand_throughput.value.max_write_request_units, null)
66+
}
67+
}
5968
}
6069
}
6170

@@ -106,6 +115,15 @@ resource "aws_dynamodb_table" "this" {
106115
}
107116
}
108117

118+
dynamic "on_demand_throughput" {
119+
for_each = length(var.on_demand_throughput) > 0 ? [var.on_demand_throughput] : []
120+
121+
content {
122+
max_read_request_units = try(on_demand_throughput.value.max_read_request_units, null)
123+
max_write_request_units = try(on_demand_throughput.value.max_write_request_units, null)
124+
}
125+
}
126+
109127
tags = merge(
110128
var.tags,
111129
{
@@ -178,6 +196,15 @@ resource "aws_dynamodb_table" "autoscaled" {
178196
read_capacity = lookup(global_secondary_index.value, "read_capacity", null)
179197
write_capacity = lookup(global_secondary_index.value, "write_capacity", null)
180198
non_key_attributes = lookup(global_secondary_index.value, "non_key_attributes", null)
199+
200+
dynamic "on_demand_throughput" {
201+
for_each = try([global_secondary_index.value.on_demand_throughput], [])
202+
203+
content {
204+
max_read_request_units = try(on_demand_throughput.value.max_read_request_units, null)
205+
max_write_request_units = try(on_demand_throughput.value.max_write_request_units, null)
206+
}
207+
}
181208
}
182209
}
183210

@@ -228,6 +255,15 @@ resource "aws_dynamodb_table" "autoscaled" {
228255
}
229256
}
230257

258+
dynamic "on_demand_throughput" {
259+
for_each = length(var.on_demand_throughput) > 0 ? [var.on_demand_throughput] : []
260+
261+
content {
262+
max_read_request_units = try(on_demand_throughput.value.max_read_request_units, null)
263+
max_write_request_units = try(on_demand_throughput.value.max_write_request_units, null)
264+
}
265+
}
266+
231267
tags = merge(
232268
var.tags,
233269
{

variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@ variable "ignore_changes_global_secondary_index" {
180180
default = false
181181
}
182182

183+
variable "on_demand_throughput" {
184+
description = "Sets the maximum number of read and write units for the specified on-demand table"
185+
type = any
186+
default = {}
187+
}
188+
183189
variable "restore_date_time" {
184190
description = "Time of the point-in-time recovery point to restore."
185191
type = string

versions.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 5.64"
7+
version = ">= 5.72.1"
88
}
99
}
1010
}

wrappers/main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ module "wrapper" {
2222
import_table = try(each.value.import_table, var.defaults.import_table, {})
2323
local_secondary_indexes = try(each.value.local_secondary_indexes, var.defaults.local_secondary_indexes, [])
2424
name = try(each.value.name, var.defaults.name, null)
25+
on_demand_throughput = try(each.value.on_demand_throughput, var.defaults.on_demand_throughput, {})
2526
point_in_time_recovery_enabled = try(each.value.point_in_time_recovery_enabled, var.defaults.point_in_time_recovery_enabled, false)
2627
range_key = try(each.value.range_key, var.defaults.range_key, null)
2728
read_capacity = try(each.value.read_capacity, var.defaults.read_capacity, null)

wrappers/versions.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 5.64"
7+
version = ">= 5.72.1"
88
}
99
}
1010
}

0 commit comments

Comments
 (0)