Skip to content

Commit d085323

Browse files
authored
Merge pull request #1 from wiseelf/dynamic-parameter
Dynamic parameter
2 parents a577bd2 + b7b75ac commit d085323

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,10 @@ Available targets:
257257
| <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 |
258258
| <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 |
259259
| <a name="input_maintenance_window"></a> [maintenance\_window](#input\_maintenance\_window) | Maintenance window | `string` | `"wed:03:00-wed:04:00"` | no |
260-
| <a name="input_max_item_size"></a> [max\_item\_size](#input\_max\_item\_size) | Max item size | `number` | `10485760` | no |
261260
| <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 |
262261
| <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 |
263262
| <a name="input_notification_topic_arn"></a> [notification\_topic\_arn](#input\_notification\_topic\_arn) | Notification topic arn | `string` | `""` | no |
263+
| <a name="input_parameter"></a> [parameter](#input\_parameter) | A list of Memcached parameters to apply. Note that parameters may differ from one Memcached family to another | <pre>list(object({<br> name = string<br> value = string<br> }))</pre> | <pre>[<br> {<br> "name": "max_item_size",<br> "value": 10485760<br> }<br>]</pre> | no |
264264
| <a name="input_port"></a> [port](#input\_port) | Memcached port | `number` | `11211` | no |
265265
| <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 |
266266
| <a name="input_security_group_create_before_destroy"></a> [security\_group\_create\_before\_destroy](#input\_security\_group\_create\_before\_destroy) | Set `true` to enable Terraform `create_before_destroy` behavior on the created security group.<br>We only recommend setting this `false` if you are upgrading this module and need to keep<br>the existing security group from being replaced.<br>Note that changing this value will always cause the security group to be replaced. | `bool` | `true` | no |

docs/terraform.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@
7474
| <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 |
7575
| <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 |
7676
| <a name="input_maintenance_window"></a> [maintenance\_window](#input\_maintenance\_window) | Maintenance window | `string` | `"wed:03:00-wed:04:00"` | no |
77-
| <a name="input_max_item_size"></a> [max\_item\_size](#input\_max\_item\_size) | Max item size | `number` | `10485760` | no |
7877
| <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 |
7978
| <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 |
8079
| <a name="input_notification_topic_arn"></a> [notification\_topic\_arn](#input\_notification\_topic\_arn) | Notification topic arn | `string` | `""` | no |
80+
| <a name="input_parameter"></a> [parameter](#input\_parameter) | A list of Memcached parameters to apply. Note that parameters may differ from one Memcached family to another | <pre>list(object({<br> name = string<br> value = string<br> }))</pre> | <pre>[<br> {<br> "name": "max_item_size",<br> "value": 10485760<br> }<br>]</pre> | no |
8181
| <a name="input_port"></a> [port](#input\_port) | Memcached port | `number` | `11211` | no |
8282
| <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 |
8383
| <a name="input_security_group_create_before_destroy"></a> [security\_group\_create\_before\_destroy](#input\_security\_group\_create\_before\_destroy) | Set `true` to enable Terraform `create_before_destroy` behavior on the created security group.<br>We only recommend setting this `false` if you are upgrading this module and need to keep<br>the existing security group from being replaced.<br>Note that changing this value will always cause the security group to be replaced. | `bool` | `true` | no |

main.tf

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,12 @@ resource "aws_elasticache_parameter_group" "default" {
9292
name = module.this.id
9393
family = var.elasticache_parameter_group_family
9494

95-
parameter {
96-
name = "max_item_size"
97-
value = var.max_item_size
95+
dynamic "parameter" {
96+
for_each = var.parameter
97+
content {
98+
name = parameter.value.name
99+
value = tostring(parameter.value.value)
100+
}
98101
}
99102
}
100103

variables.tf

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,18 @@ variable "vpc_id" {
44
description = "VPC ID"
55
}
66

7-
variable "max_item_size" {
8-
type = number
9-
default = 10485760
10-
description = "Max item size"
7+
variable "parameter" {
8+
type = list(object({
9+
name = string
10+
value = string
11+
}))
12+
default = [
13+
{
14+
name = "max_item_size"
15+
value = 10485760
16+
},
17+
]
18+
description = "A list of Memcached parameters to apply. Note that parameters may differ from one Memcached family to another"
1119
}
1220

1321
variable "subnets" {

0 commit comments

Comments
 (0)