Skip to content

Commit 8711b2f

Browse files
authored
Merge pull request #5 from rackspace-infrastructure-automation/billing_mode
Billing mode
2 parents b8ac9df + 8ce7eb4 commit 8711b2f

File tree

4 files changed

+45
-12
lines changed

4 files changed

+45
-12
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
| Name | Description | Type | Default | Required |
44
|------|-------------|:----:|:-----:|:-----:|
55
| attributes | List of nested attribute definitions. Only required for hash_key (always) and range_key (if used) attributes. Attributes have name and type. Type must be a scalar type: S, N, or B for (S)tring, (N)umber or (B)inary data. i.e. [{ name=<hash_key> type=<data_type>}] | list | n/a | yes |
6+
| enable\_pay\_per\_request | Controls how you are charged for read and write throughput and how you manage capacity. If True, DynamoDB charges you for the data reads and writes your application performs on your tables. You do not need to specify how much read and write throughput you expect your application to perform because DynamoDB instantly accommodates your workloads as they ramp up or down. [On-Demand Pricing](https://aws.amazon.com/dynamodb/pricing/on-demand/) If False, you specify the number of `read_capacity_units` and `write_capacity_units` per second that you expect your workload to require. [Provisioned Pricing](https://aws.amazon.com/dynamodb/pricing/provisioned/) | string | `"false"` | no |
67
| hash\_key | ** Forces new resource ** Must contain only alphanumberic characters, dash (-), underscore (_) or dot (.). Needs to be defined by type in attributes. | string | n/a | yes |
78
| point\_in\_time\_recovery | Enable point in time recovery for the table. | string | `"false"` | no |
89
| range\_key | ** Forces new resource ** RangeType PrimaryKey Name. If used, it will need to be defined by type in attributes | string | `""` | no |
9-
| read\_capacity\_units | Provisioned read throughput. Should be between 5 and 10000 | string | `"5"` | no |
10+
| read\_capacity\_units | Provisioned read throughput. Should be between 5 and 10000. Ignored if `enable_pay_per_request` is set to `true`. | string | `"5"` | no |
1011
| table\_encryption | Server side table encryption at rest. i.e. true | false | string | `"true"` | no |
1112
| table\_name | The name of the table, this needs to be unique within a region. | string | n/a | yes |
12-
| write\_capacity\_units | Provisioned write throughput. Should be between 5 and 10000. | string | `"10"` | no |
13+
| write\_capacity\_units | Provisioned write throughput. Should be between 5 and 10000. Ignored if `enable_pay_per_request` is set to `true`. | string | `"10"` | no |
1314

1415
## Outputs
1516

examples/example.tf

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,39 @@ provider "aws" {
33
region = "us-west-2"
44
}
55

6-
module "dynamo" {
7-
source = "git@github.com/rackspace-infrastructure-automation/aws-terraform-dynamo//?ref=v0.0.1"
8-
9-
table_name = "<TableName>"
10-
hash_key = "<HashKeyName>"
11-
range_key = "<RangeKey>"
12-
read_capacity_units = 5
13-
write_capacity_units = 10
6+
module "dynamo_table_provisioned" {
7+
source = "git@github.com/rackspace-infrastructure-automation/aws-terraform-dynamo//?ref=v0.0.2"
8+
9+
table_name = "<TableName>"
10+
hash_key = "<HashKeyName>"
11+
range_key = "<RangeKey>"
12+
enable_pay_per_request = false
13+
read_capacity_units = 5
14+
write_capacity_units = 10
15+
16+
attributes = [
17+
{
18+
name = "<HashKeyName>"
19+
type = "S"
20+
},
21+
{
22+
name = "<RangeKey>"
23+
type = "N"
24+
},
25+
]
26+
27+
table_encryption = true
28+
29+
point_in_time_recovery = true
30+
}
31+
32+
module "dynamo_table_pay_per_requst" {
33+
source = "git@github.com/rackspace-infrastructure-automation/aws-terraform-dynamo//?ref=v0.0.2"
34+
35+
table_name = "<TableName>"
36+
hash_key = "<HashKeyName>"
37+
range_key = "<RangeKey>"
38+
enable_pay_per_request = true
1439

1540
attributes = [
1641
{

main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
resource "aws_dynamodb_table" "basic-dynamodb-table" {
22
name = "${var.table_name}"
3+
billing_mode = "${var.enable_pay_per_request ? "PAY_PER_REQUEST":"PROVISIONED"}"
34
read_capacity = "${var.read_capacity_units}"
45
write_capacity = "${var.write_capacity_units}"
56
hash_key = "${var.hash_key}"

variables.tf

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ variable "table_name" {
33
type = "string"
44
}
55

6+
variable "enable_pay_per_request" {
7+
description = "Controls how you are charged for read and write throughput and how you manage capacity. If True, DynamoDB charges you for the data reads and writes your application performs on your tables. You do not need to specify how much read and write throughput you expect your application to perform because DynamoDB instantly accommodates your workloads as they ramp up or down. [On-Demand Pricing](https://aws.amazon.com/dynamodb/pricing/on-demand/) If False, you specify the number of `read_capacity_units` and `write_capacity_units` per second that you expect your workload to require. [Provisioned Pricing](https://aws.amazon.com/dynamodb/pricing/provisioned/)"
8+
type = "string"
9+
default = false
10+
}
11+
612
variable "hash_key" {
713
description = "** Forces new resource ** Must contain only alphanumberic characters, dash (-), underscore (_) or dot (.). Needs to be defined by type in attributes."
814
type = "string"
@@ -15,7 +21,7 @@ variable "range_key" {
1521
}
1622

1723
variable "read_capacity_units" {
18-
description = "Provisioned read throughput. Should be between 5 and 10000"
24+
description = "Provisioned read throughput. Should be between 5 and 10000. Ignored if `enable_pay_per_request` is set to `true`."
1925
type = "string"
2026
default = 5
2127
}
@@ -27,7 +33,7 @@ variable "table_encryption" {
2733
}
2834

2935
variable "write_capacity_units" {
30-
description = "Provisioned write throughput. Should be between 5 and 10000."
36+
description = "Provisioned write throughput. Should be between 5 and 10000. Ignored if `enable_pay_per_request` is set to `true`."
3137
type = "string"
3238
default = 10
3339
}

0 commit comments

Comments
 (0)