Skip to content

Commit 2116c81

Browse files
authored
feat: Added functionality (#1)
## Description <!--- Describe your changes in detail --> ## Motivation and Context <!--- Why is this change required? What problem does it solve? --> <!--- If it fixes an open issue, please link to the issue here. --> ## Breaking Changes <!-- Does this break backwards compatibility with the current major version? --> <!-- If so, please provide an explanation why it is necessary. --> ## How Has This Been Tested? - [ ] I have updated at least one of the `examples/*` to demonstrate and validate my change(s) - [ ] I have tested and validated these changes using one or more of the provided `examples/*` projects <!--- Users should start with an existing example as its written, deploy it, then check their changes against it --> <!--- This will highlight breaking/disruptive changes. Once you have checked, deploy your changes to verify --> <!--- Please describe how you tested your changes --> - [ ] I have executed `pre-commit run -a` on my pull request <!--- Please see https://github.com/antonbabenko/pre-commit-terraform#how-to-install for how to install -->
1 parent 5c8a147 commit 2116c81

17 files changed

+327
-1
lines changed

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
terragrunt 0.42.2
2-
terraform 1.3.5
2+
terraform 1.3.6
33
terraform-docs 0.16.0
44
tflint 0.43.0

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,53 @@
11
# terraform-aws-dynamodb-tables
22
Terraform module which create a dynamodb tables incl. indices and scaling via the terraform-aws-dynamodb-autoscaler module
3+
4+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
5+
## Requirements
6+
7+
| Name | Version |
8+
|------|---------|
9+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.6 |
10+
11+
## Providers
12+
13+
No providers.
14+
15+
## Modules
16+
17+
| Name | Source | Version |
18+
|------|--------|---------|
19+
| <a name="module_table"></a> [table](#module\_table) | github.com/justtrackio/terraform-aws-dynamodb-table | v1.0.1 |
20+
| <a name="module_this"></a> [this](#module\_this) | cloudposse/label/null | 0.25.0 |
21+
22+
## Resources
23+
24+
No resources.
25+
26+
## Inputs
27+
28+
| Name | Description | Type | Default | Required |
29+
|------|-------------|------|---------|:--------:|
30+
| <a name="input_additional_tag_map"></a> [additional\_tag\_map](#input\_additional\_tag\_map) | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.<br>This is for some rare cases where resources want additional configuration of tags<br>and therefore take a list of maps with tag key, value, and additional configuration. | `map(string)` | `{}` | no |
31+
| <a name="input_attributes"></a> [attributes](#input\_attributes) | ID element. Additional attributes (e.g. `workers` or `cluster`) to add to `id`,<br>in the order they appear in the list. New attributes are appended to the<br>end of the list. The elements of the list are joined by the `delimiter`<br>and treated as a single ID element. | `list(string)` | `[]` | no |
32+
| <a name="input_context"></a> [context](#input\_context) | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | `any` | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "descriptor_formats": {},<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_key_case": null,<br> "label_order": [],<br> "label_value_case": null,<br> "labels_as_tags": [<br> "unset"<br> ],<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {},<br> "tenant": null<br>}</pre> | no |
33+
| <a name="input_delimiter"></a> [delimiter](#input\_delimiter) | Delimiter to be used between ID elements.<br>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no |
34+
| <a name="input_descriptor_formats"></a> [descriptor\_formats](#input\_descriptor\_formats) | Describe additional descriptors to be output in the `descriptors` output map.<br>Map of maps. Keys are names of descriptors. Values are maps of the form<br>`{<br> format = string<br> labels = list(string)<br>}`<br>(Type is `any` so the map values can later be enhanced to provide additional options.)<br>`format` is a Terraform format string to be passed to the `format()` function.<br>`labels` is a list of labels, in order, to pass to `format()` function.<br>Label values will be normalized before being passed to `format()` so they will be<br>identical to how they appear in `id`.<br>Default is `{}` (`descriptors` output will be empty). | `any` | `{}` | no |
35+
| <a name="input_enabled"></a> [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
36+
| <a name="input_environment"></a> [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
37+
| <a name="input_id_length_limit"></a> [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).<br>Set to `0` for unlimited length.<br>Set to `null` for keep the existing setting, which defaults to `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
38+
| <a name="input_label_key_case"></a> [label\_key\_case](#input\_label\_key\_case) | Controls the letter case of the `tags` keys (label names) for tags generated by this module.<br>Does not affect keys of tags passed in via the `tags` input.<br>Possible values: `lower`, `title`, `upper`.<br>Default value: `title`. | `string` | `null` | no |
39+
| <a name="input_label_order"></a> [label\_order](#input\_label\_order) | The order in which the labels (ID elements) appear in the `id`.<br>Defaults to ["namespace", "environment", "stage", "name", "attributes"].<br>You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present. | `list(string)` | `null` | no |
40+
| <a name="input_label_value_case"></a> [label\_value\_case](#input\_label\_value\_case) | Controls the letter case of ID elements (labels) as included in `id`,<br>set as tag values, and output by this module individually.<br>Does not affect values of tags passed in via the `tags` input.<br>Possible values: `lower`, `title`, `upper` and `none` (no transformation).<br>Set this to `title` and set `delimiter` to `""` to yield Pascal Case IDs.<br>Default value: `lower`. | `string` | `null` | no |
41+
| <a name="input_labels_as_tags"></a> [labels\_as\_tags](#input\_labels\_as\_tags) | Set of labels (ID elements) to include as tags in the `tags` output.<br>Default is to include all labels.<br>Tags with empty values will not be included in the `tags` output.<br>Set to `[]` to suppress all generated tags.<br>**Notes:**<br> The value of the `name` tag, if included, will be the `id`, not the `name`.<br> Unlike other `null-label` inputs, the initial setting of `labels_as_tags` cannot be<br> changed in later chained modules. Attempts to change it will be silently ignored. | `set(string)` | <pre>[<br> "default"<br>]</pre> | no |
42+
| <a name="input_name"></a> [name](#input\_name) | ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.<br>This is the only ID element not also included as a `tag`.<br>The "name" tag is set to the full `id` string. There is no tag with the value of the `name` input. | `string` | `null` | no |
43+
| <a name="input_namespace"></a> [namespace](#input\_namespace) | ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique | `string` | `null` | no |
44+
| <a name="input_regex_replace_chars"></a> [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.<br>Characters matching the regex will be removed from the ID elements.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
45+
| <a name="input_stage"></a> [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
46+
| <a name="input_tables"></a> [tables](#input\_tables) | Tables to be created | <pre>map(object({<br> autoscaler = optional(object({<br> attributes = optional(list(string), [])<br> enabled = optional(bool, true)<br> max_read_capacity = optional(number, 1000)<br> max_write_capacity = optional(number, 1000)<br> min_read_capacity = optional(number, 1)<br> min_write_capacity = optional(number, 1)<br> read_schedule = optional(list(object({<br> schedule = string<br> min_capacity = number<br> max_capacity = number<br> })), [])<br> read_schedule_index = optional(list(object({<br> schedule = string<br> min_capacity = number<br> max_capacity = number<br> })), [])<br> read_target = optional(number, 75)<br> write_schedule = optional(list(object({<br> schedule = string<br> min_capacity = number<br> max_capacity = number<br> })), [])<br> write_schedule_index = optional(list(object({<br> schedule = string<br> min_capacity = number<br> max_capacity = number<br> })), [])<br> write_target = optional(number, 75)<br> tags = optional(map(string), {})<br> }), {})<br> global_secondary_index_map = optional(list(object({<br> hash_key = string<br> name = string<br> non_key_attributes = list(string)<br> projection_type = string<br> range_key = string<br> read_capacity = number<br> write_capacity = number<br> })), [])<br> local_secondary_index_map = optional(list(object({<br> name = string<br> non_key_attributes = list(string)<br> projection_type = string<br> range_key = string<br> })), [])<br> table = object({<br> attributes = optional(list(object({<br> name = string<br> type = string<br> })), [])<br> billing_mode = optional(string, "PROVISIONED")<br> encryption = optional(object({<br> enabled = optional(bool, false)<br> kms_key_arn = optional(string, "")<br> }), {})<br> point_in_time_recovery = optional(object({<br> enabled = optional(bool, false)<br> }), {})<br> streams = optional(object({<br> enabled = optional(bool, false)<br> view_type = optional(string, "")<br> }), {})<br> exists = optional(bool, true)<br> hash_key = string<br> hash_key_type = optional(string, "S")<br> range_key = optional(string, "")<br> range_key_type = optional(string, "S")<br> replicas = optional(list(string), [])<br> tags = optional(object({<br> enabled = optional(bool, true)<br> }), {})<br> ttl = optional(object({<br> attribute = optional(string, "ttl")<br> enabled = optional(bool, true)<br> }), {})<br> })<br> }))</pre> | `{}` | no |
47+
| <a name="input_tags"></a> [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).<br>Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no |
48+
| <a name="input_tenant"></a> [tenant](#input\_tenant) | ID element \_(Rarely used, not included by default)\_. A customer identifier, indicating who this instance of a resource is for | `string` | `null` | no |
49+
50+
## Outputs
51+
52+
No outputs.
53+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

examples/basic/main.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module "example" {
2+
source = "../.."
3+
4+
environment = "example"
5+
6+
tables = {
7+
basic = {
8+
table = {
9+
hash_key = "id"
10+
}
11+
}
12+
}
13+
}

examples/basic/outputs.tf

Whitespace-only changes.

examples/basic/providers.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
provider "aws" {
2+
region = "eu-central-1"
3+
}

examples/basic/variables.tf

Whitespace-only changes.

examples/basic/versions.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
required_providers {
3+
aws = {
4+
source = "hashicorp/aws"
5+
version = "4.45.0"
6+
}
7+
}
8+
9+
required_version = "1.3.6"
10+
}

examples/full/main.tf

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
module "example" {
2+
source = "../.."
3+
4+
environment = "example"
5+
6+
tables = {
7+
full = {
8+
autoscaler = {
9+
attributes = ["foo"]
10+
enabled = true
11+
max_read_capacity = 500
12+
max_write_capacity = 500
13+
min_read_capacity = 2
14+
min_write_capacity = 2
15+
read_schedule = [{
16+
schedule = "cron(0 5 ? * * *)"
17+
min_capacity = 3
18+
max_capacity = 501
19+
}]
20+
read_schedule_index = [{
21+
schedule = "cron(0 5 ? * * *)"
22+
min_capacity = 4
23+
max_capacity = 502
24+
}]
25+
read_target = 80
26+
write_schedule = [{
27+
schedule = "cron(0 5 ? * * *)"
28+
min_capacity = 3
29+
max_capacity = 501
30+
}]
31+
write_schedule_index = [{
32+
schedule = "cron(0 5 ? * * *)"
33+
min_capacity = 4
34+
max_capacity = 502
35+
}]
36+
write_target = 80
37+
tags = {
38+
Foo = "Bar"
39+
}
40+
}
41+
global_secondary_index_map = [
42+
{
43+
hash_key = "foo"
44+
name = "fooIdx"
45+
non_key_attributes = ["bar"]
46+
projection_type = "INCLUDE"
47+
range_key = "created_at"
48+
read_capacity = 3
49+
write_capacity = 3
50+
}
51+
]
52+
local_secondary_index_map = [
53+
{
54+
name = "foo2Idx"
55+
non_key_attributes = ["bar"]
56+
projection_type = "INCLUDE"
57+
range_key = "created_at"
58+
}
59+
]
60+
table = {
61+
attributes = [
62+
{
63+
name = "foo"
64+
type = "S"
65+
}
66+
]
67+
billing_mode = "PROVISIONED"
68+
encryption = {
69+
enabled = true
70+
kms_key_arn = "arn:aws:kms:eu-central-1:123456789123:key/d187ad95-05de-4695-b9c9-a9b2895fa4cc"
71+
}
72+
point_in_time_recovery = {
73+
enabled = false
74+
}
75+
streams = {
76+
enabled = true
77+
view_type = "NEW_AND_OLD_IMAGES"
78+
}
79+
exists = false
80+
hash_key = "id"
81+
hash_key_type = "S"
82+
range_key = "created_at"
83+
range_key_type = "N"
84+
replicas = []
85+
tags = {
86+
enabled = true
87+
}
88+
ttl = {
89+
attribute = "time-to-live"
90+
enabled = true
91+
}
92+
}
93+
}
94+
}
95+
}

examples/full/outputs.tf

Whitespace-only changes.

examples/full/providers.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
provider "aws" {
2+
region = "eu-central-1"
3+
}

0 commit comments

Comments
 (0)