Skip to content

Commit

Permalink
Add var.tags_enabled to support dynamodb-local (#91)
Browse files Browse the repository at this point in the history
* Add var.enable_tags to support dynamodb-local

Closes #90

* Auto Format

* Trigger validate-codeowners

* rename var to tags_enabled

* Auto Format

* Auto Format

Co-authored-by: cloudpossebot <[email protected]>
Co-authored-by: Cody Moore <[email protected]>
Co-authored-by: nitrocode <[email protected]>
  • Loading branch information
4 people authored Oct 26, 2021
1 parent 06c9659 commit 64073b0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ Available targets:
| <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 |
| <a name="input_stream_view_type"></a> [stream\_view\_type](#input\_stream\_view\_type) | When an item in the table is modified, what information is written to the stream | `string` | `""` | no |
| <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 |
| <a name="input_tags_enabled"></a> [tags\_enabled](#input\_tags\_enabled) | Set to `false` to disable tagging. This can be helpful if you're managing tables on dynamodb-local with terraform as it doesn't support tagging. | `bool` | `true` | no |
| <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 |
| <a name="input_ttl_attribute"></a> [ttl\_attribute](#input\_ttl\_attribute) | DynamoDB table TTL attribute | `string` | `"Expires"` | no |
| <a name="input_ttl_enabled"></a> [ttl\_enabled](#input\_ttl\_enabled) | Set to false to disable DynamoDB table TTL | `bool` | `true` | no |
Expand Down
1 change: 1 addition & 0 deletions docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
| <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 |
| <a name="input_stream_view_type"></a> [stream\_view\_type](#input\_stream\_view\_type) | When an item in the table is modified, what information is written to the stream | `string` | `""` | no |
| <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 |
| <a name="input_tags_enabled"></a> [tags\_enabled](#input\_tags\_enabled) | Set to `false` to disable tagging. This can be helpful if you're managing tables on dynamodb-local with terraform as it doesn't support tagging. | `bool` | `true` | no |
| <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 |
| <a name="input_ttl_attribute"></a> [ttl\_attribute](#input\_ttl\_attribute) | DynamoDB table TTL attribute | `string` | `"Expires"` | no |
| <a name="input_ttl_enabled"></a> [ttl\_enabled](#input\_ttl\_enabled) | Set to false to disable DynamoDB table TTL | `bool` | `true` | no |
Expand Down
4 changes: 2 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ resource "aws_dynamodb_table" "default" {
}
}

tags = module.this.tags
tags = var.tags_enabled ? module.this.tags : null
}

module "dynamodb_autoscaler" {
Expand All @@ -126,7 +126,7 @@ module "dynamodb_autoscaler" {
enabled = local.enabled && var.enable_autoscaler && var.billing_mode == "PROVISIONED"

attributes = concat(module.this.attributes, var.autoscaler_attributes)
tags = merge(module.this.tags, var.autoscaler_tags)
tags = var.tags_enabled ? merge(module.this.tags, var.autoscaler_tags) : null
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
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,9 @@ variable "replicas" {
default = []
description = "List of regions to create replica"
}

variable "tags_enabled" {
type = bool
default = true
description = "Set to `false` to disable tagging. This can be helpful if you're managing tables on dynamodb-local with terraform as it doesn't support tagging."
}

0 comments on commit 64073b0

Please sign in to comment.