Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support on_demand_throughput #90

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ Users of Terragrunt can achieve similar results by using modules provided in the
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.64 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.72.1 |

## Providers

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

## Modules

Expand Down Expand Up @@ -115,6 +115,7 @@ No modules.
| <a name="input_import_table"></a> [import\_table](#input\_import\_table) | Configurations for importing s3 data into a new table. | `any` | `{}` | no |
| <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 |
| <a name="input_name"></a> [name](#input\_name) | Name of the DynamoDB table | `string` | `null` | no |
| <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 |
| <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 |
| <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 |
| <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 |
Expand Down
2 changes: 1 addition & 1 deletion examples/autoscaling/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Note that this example may create resources which can cost money (AWS Elastic IP
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.64 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.72.1 |
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2.0 |

## Providers
Expand Down
2 changes: 1 addition & 1 deletion examples/autoscaling/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.64"
version = ">= 5.72.1"
}
random = {
source = "hashicorp/random"
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Note that this example may create resources which can cost money (AWS Elastic IP
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.64 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.72.1 |
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2.0 |

## Providers
Expand Down
10 changes: 10 additions & 0 deletions examples/basic/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,19 @@ module "dynamodb_table" {
range_key = "age"
projection_type = "INCLUDE"
non_key_attributes = ["id"]

on_demand_throughput = {
max_write_request_units = 1
max_read_request_units = 1
}
}
]

on_demand_throughput = {
max_read_request_units = 1
max_write_request_units = 1
}

tags = {
Terraform = "true"
Environment = "staging"
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.64"
version = ">= 5.72.1"
}
random = {
source = "hashicorp/random"
Expand Down
6 changes: 3 additions & 3 deletions examples/global-tables/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ Note that this example may create resources which can cost money (AWS Elastic IP
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.64 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.72.1 |
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2.0 |

## Providers

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

## Modules
Expand Down
2 changes: 1 addition & 1 deletion examples/global-tables/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.64"
version = ">= 5.72.1"
}
random = {
source = "hashicorp/random"
Expand Down
2 changes: 1 addition & 1 deletion examples/s3-import/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Note that this example may create resources which can cost money (AWS Elastic IP
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.64 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.72.1 |
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2.0 |

## Providers
Expand Down
2 changes: 1 addition & 1 deletion examples/s3-import/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.64"
version = ">= 5.72.1"
}
random = {
source = "hashicorp/random"
Expand Down
36 changes: 36 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ resource "aws_dynamodb_table" "this" {
read_capacity = lookup(global_secondary_index.value, "read_capacity", null)
write_capacity = lookup(global_secondary_index.value, "write_capacity", null)
non_key_attributes = lookup(global_secondary_index.value, "non_key_attributes", null)

dynamic "on_demand_throughput" {
for_each = try([global_secondary_index.value.on_demand_throughput], [])

content {
max_read_request_units = try(on_demand_throughput.value.max_read_request_units, null)
max_write_request_units = try(on_demand_throughput.value.max_write_request_units, null)
}
}
}
}

Expand Down Expand Up @@ -106,6 +115,15 @@ resource "aws_dynamodb_table" "this" {
}
}

dynamic "on_demand_throughput" {
for_each = length(var.on_demand_throughput) > 0 ? [var.on_demand_throughput] : []

content {
max_read_request_units = try(on_demand_throughput.value.max_read_request_units, null)
bryantbiggs marked this conversation as resolved.
Show resolved Hide resolved
max_write_request_units = try(on_demand_throughput.value.max_write_request_units, null)
}
}

tags = merge(
var.tags,
{
Expand Down Expand Up @@ -178,6 +196,15 @@ resource "aws_dynamodb_table" "autoscaled" {
read_capacity = lookup(global_secondary_index.value, "read_capacity", null)
write_capacity = lookup(global_secondary_index.value, "write_capacity", null)
non_key_attributes = lookup(global_secondary_index.value, "non_key_attributes", null)

dynamic "on_demand_throughput" {
for_each = try([global_secondary_index.value.on_demand_throughput], [])

content {
max_read_request_units = try(on_demand_throughput.value.max_read_request_units, null)
max_write_request_units = try(on_demand_throughput.value.max_write_request_units, null)
}
}
}
}

Expand Down Expand Up @@ -228,6 +255,15 @@ resource "aws_dynamodb_table" "autoscaled" {
}
}

dynamic "on_demand_throughput" {
for_each = length(var.on_demand_throughput) > 0 ? [var.on_demand_throughput] : []

content {
max_read_request_units = try(on_demand_throughput.value.max_read_request_units, null)
max_write_request_units = try(on_demand_throughput.value.max_write_request_units, null)
}
}

tags = merge(
var.tags,
{
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ variable "ignore_changes_global_secondary_index" {
default = false
}

variable "on_demand_throughput" {
description = "Sets the maximum number of read and write units for the specified on-demand table"
type = any
default = {}
}

variable "restore_date_time" {
description = "Time of the point-in-time recovery point to restore."
type = string
Expand Down
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.64"
version = ">= 5.72.1"
}
}
}
1 change: 1 addition & 0 deletions wrappers/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module "wrapper" {
import_table = try(each.value.import_table, var.defaults.import_table, {})
local_secondary_indexes = try(each.value.local_secondary_indexes, var.defaults.local_secondary_indexes, [])
name = try(each.value.name, var.defaults.name, null)
on_demand_throughput = try(each.value.on_demand_throughput, var.defaults.on_demand_throughput, {})
point_in_time_recovery_enabled = try(each.value.point_in_time_recovery_enabled, var.defaults.point_in_time_recovery_enabled, false)
range_key = try(each.value.range_key, var.defaults.range_key, null)
read_capacity = try(each.value.read_capacity, var.defaults.read_capacity, null)
Expand Down
2 changes: 1 addition & 1 deletion wrappers/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.64"
version = ">= 5.72.1"
}
}
}