Skip to content

Commit

Permalink
allow to add additional attributes and tags to autoscaler (#52)
Browse files Browse the repository at this point in the history
* allow to add additional attributes and tags to autoscaler
This is to avoid adding a region prefix to dynamodb tables because the autoscaler IAM role requires additional region indicator in its names

* use map type for tags variable

* remove markdown comments from diff

* Updated README.md

Co-authored-by: actions-bot <[email protected]>
  • Loading branch information
etwillbefine and actions-bot authored Oct 9, 2020
1 parent ed229a0 commit 622ce1e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ Available targets:
| autoscale\_min\_write\_capacity | DynamoDB autoscaling min write capacity | `number` | `5` | no |
| autoscale\_read\_target | The target value (in %) for DynamoDB read autoscaling | `number` | `50` | no |
| autoscale\_write\_target | The target value (in %) for DynamoDB write autoscaling | `number` | `50` | no |
| autoscaler\_attributes | Additional attributes for the autoscaler module | `list(string)` | `[]` | no |
| autoscaler\_tags | Additional resource tags for the autoscaler module | `map(string)` | `{}` | no |
| billing\_mode | DynamoDB Billing mode. Can be PROVISIONED or PAY\_PER\_REQUEST | `string` | `"PROVISIONED"` | no |
| delimiter | Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes` | `string` | `"-"` | no |
| dynamodb\_attributes | Additional DynamoDB attributes in the form of a list of mapped values | <pre>list(object({<br> name = string<br> type = string<br> }))</pre> | `[]` | no |
Expand Down
2 changes: 2 additions & 0 deletions docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
| autoscale\_min\_write\_capacity | DynamoDB autoscaling min write capacity | `number` | `5` | no |
| autoscale\_read\_target | The target value (in %) for DynamoDB read autoscaling | `number` | `50` | no |
| autoscale\_write\_target | The target value (in %) for DynamoDB write autoscaling | `number` | `50` | no |
| autoscaler\_attributes | Additional attributes for the autoscaler module | `list(string)` | `[]` | no |
| autoscaler\_tags | Additional resource tags for the autoscaler module | `map(string)` | `{}` | no |
| billing\_mode | DynamoDB Billing mode. Can be PROVISIONED or PAY\_PER\_REQUEST | `string` | `"PROVISIONED"` | no |
| delimiter | Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes` | `string` | `"-"` | no |
| dynamodb\_attributes | Additional DynamoDB attributes in the form of a list of mapped values | <pre>list(object({<br> name = string<br> type = string<br> }))</pre> | `[]` | no |
Expand Down
4 changes: 2 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ module "dynamodb_autoscaler" {
environment = var.environment
name = var.name
delimiter = var.delimiter
attributes = var.attributes
tags = module.dynamodb_label.tags
attributes = concat(var.attributes, var.autoscaler_attributes)
tags = merge(module.dynamodb_label.tags, var.autoscaler_tags)
dynamodb_table_name = join("", aws_dynamodb_table.default.*.id)
dynamodb_table_arn = join("", aws_dynamodb_table.default.*.arn)
dynamodb_indexes = null_resource.global_secondary_index_names.*.triggers.name
Expand Down
12 changes: 12 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,18 @@ variable "enable_autoscaler" {
description = "Flag to enable/disable DynamoDB autoscaling"
}

variable "autoscaler_attributes" {
type = list(string)
default = []
description = "Additional attributes for the autoscaler module"
}

variable "autoscaler_tags" {
type = map(string)
default = {}
description = "Additional resource tags for the autoscaler module"
}

variable "dynamodb_attributes" {
type = list(object({
name = string
Expand Down

0 comments on commit 622ce1e

Please sign in to comment.