Skip to content

Commit 2c3040f

Browse files
welderpbPavel Bukhatkincloudpossebot
authored
Allow to set listener tags (#122)
* allow set tags for listeners * fix issue with variable * Auto Format Co-authored-by: Pavel Bukhatkin <pavel.bukhatkin@libertexgroup.com> Co-authored-by: cloudpossebot <11232728+cloudpossebot@users.noreply.github.com>
1 parent bce6ca2 commit 2c3040f

File tree

5 files changed

+14
-3
lines changed

5 files changed

+14
-3
lines changed

.github/auto-release.yml

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ version-resolver:
1717
- 'bugfix'
1818
- 'bug'
1919
- 'hotfix'
20-
- 'no-release'
2120
default: 'minor'
2221

2322
categories:

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ Available targets:
291291
| <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 |
292292
| <a name="input_lifecycle_configuration_rules"></a> [lifecycle\_configuration\_rules](#input\_lifecycle\_configuration\_rules) | A list of S3 bucket v2 lifecycle rules, as specified in [terraform-aws-s3-bucket](https://github.com/cloudposse/terraform-aws-s3-bucket)"<br>These rules are not affected by the deprecated `lifecycle_rule_enabled` flag.<br>**NOTE:** Unless you also set `lifecycle_rule_enabled = false` you will also get the default deprecated rules set on your bucket. | <pre>list(object({<br> enabled = bool<br> id = string<br><br> abort_incomplete_multipart_upload_days = number<br><br> # `filter_and` is the `and` configuration block inside the `filter` configuration.<br> # This is the only place you should specify a prefix.<br> filter_and = any<br> expiration = any<br> transition = list(any)<br><br> noncurrent_version_expiration = any<br> noncurrent_version_transition = list(any)<br> }))</pre> | `[]` | no |
293293
| <a name="input_lifecycle_rule_enabled"></a> [lifecycle\_rule\_enabled](#input\_lifecycle\_rule\_enabled) | DEPRECATED: Defaults to `false`, use `lifecycle_configuration_rules` instead.<br>When `true`, configures lifecycle events on this bucket using individual (now deprecated) variables." | `bool` | `false` | no |
294+
| <a name="input_listener_additional_tags"></a> [listener\_additional\_tags](#input\_listener\_additional\_tags) | The additional tags to apply to all listeners | `map(string)` | `{}` | no |
294295
| <a name="input_listener_http_fixed_response"></a> [listener\_http\_fixed\_response](#input\_listener\_http\_fixed\_response) | Have the HTTP listener return a fixed response for the default action. | <pre>object({<br> content_type = string<br> message_body = string<br> status_code = string<br> })</pre> | `null` | no |
295296
| <a name="input_listener_https_fixed_response"></a> [listener\_https\_fixed\_response](#input\_listener\_https\_fixed\_response) | Have the HTTPS listener return a fixed response for the default action. | <pre>object({<br> content_type = string<br> message_body = string<br> status_code = string<br> })</pre> | `null` | no |
296297
| <a name="input_load_balancer_name"></a> [load\_balancer\_name](#input\_load\_balancer\_name) | The name for the default load balancer, uses a module label name if left empty | `string` | `""` | no |
@@ -501,7 +502,7 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
501502

502503
[![README Footer][readme_footer_img]][readme_footer_link]
503504
[![Beacon][beacon]][website]
504-
505+
<!-- markdownlint-disable -->
505506
[logo]: https://cloudposse.com/logo-300x69.svg
506507
[docs]: https://cpco.io/docs?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-alb&utm_content=docs
507508
[website]: https://cpco.io/homepage?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-alb&utm_content=website
@@ -532,3 +533,4 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
532533
[share_googleplus]: https://plus.google.com/share?url=https://github.com/cloudposse/terraform-aws-alb
533534
[share_email]: mailto:?subject=terraform-aws-alb&body=https://github.com/cloudposse/terraform-aws-alb
534535
[beacon]: https://ga-beacon.cloudposse.com/UA-76589703-4/cloudposse/terraform-aws-alb?pixel&cs=github&cm=readme&an=terraform-aws-alb
536+
<!-- markdownlint-restore -->

docs/terraform.md

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
| <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 |
9292
| <a name="input_lifecycle_configuration_rules"></a> [lifecycle\_configuration\_rules](#input\_lifecycle\_configuration\_rules) | A list of S3 bucket v2 lifecycle rules, as specified in [terraform-aws-s3-bucket](https://github.com/cloudposse/terraform-aws-s3-bucket)"<br>These rules are not affected by the deprecated `lifecycle_rule_enabled` flag.<br>**NOTE:** Unless you also set `lifecycle_rule_enabled = false` you will also get the default deprecated rules set on your bucket. | <pre>list(object({<br> enabled = bool<br> id = string<br><br> abort_incomplete_multipart_upload_days = number<br><br> # `filter_and` is the `and` configuration block inside the `filter` configuration.<br> # This is the only place you should specify a prefix.<br> filter_and = any<br> expiration = any<br> transition = list(any)<br><br> noncurrent_version_expiration = any<br> noncurrent_version_transition = list(any)<br> }))</pre> | `[]` | no |
9393
| <a name="input_lifecycle_rule_enabled"></a> [lifecycle\_rule\_enabled](#input\_lifecycle\_rule\_enabled) | DEPRECATED: Defaults to `false`, use `lifecycle_configuration_rules` instead.<br>When `true`, configures lifecycle events on this bucket using individual (now deprecated) variables." | `bool` | `false` | no |
94+
| <a name="input_listener_additional_tags"></a> [listener\_additional\_tags](#input\_listener\_additional\_tags) | The additional tags to apply to all listeners | `map(string)` | `{}` | no |
9495
| <a name="input_listener_http_fixed_response"></a> [listener\_http\_fixed\_response](#input\_listener\_http\_fixed\_response) | Have the HTTP listener return a fixed response for the default action. | <pre>object({<br> content_type = string<br> message_body = string<br> status_code = string<br> })</pre> | `null` | no |
9596
| <a name="input_listener_https_fixed_response"></a> [listener\_https\_fixed\_response](#input\_listener\_https\_fixed\_response) | Have the HTTPS listener return a fixed response for the default action. | <pre>object({<br> content_type = string<br> message_body = string<br> status_code = string<br> })</pre> | `null` | no |
9697
| <a name="input_load_balancer_name"></a> [load\_balancer\_name](#input\_load\_balancer\_name) | The name for the default load balancer, uses a module label name if left empty | `string` | `""` | no |

main.tf

+4-1
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ resource "aws_lb_listener" "http_forward" {
153153
load_balancer_arn = join("", aws_lb.default.*.arn)
154154
port = var.http_port
155155
protocol = "HTTP"
156+
tags = merge(module.this.tags, var.listener_additional_tags)
156157

157158
default_action {
158159
target_group_arn = var.listener_http_fixed_response != null ? null : join("", aws_lb_target_group.default.*.arn)
@@ -174,6 +175,7 @@ resource "aws_lb_listener" "http_redirect" {
174175
load_balancer_arn = join("", aws_lb.default.*.arn)
175176
port = var.http_port
176177
protocol = "HTTP"
178+
tags = merge(module.this.tags, var.listener_additional_tags)
177179

178180
default_action {
179181
target_group_arn = join("", aws_lb_target_group.default.*.arn)
@@ -196,6 +198,7 @@ resource "aws_lb_listener" "https" {
196198
protocol = "HTTPS"
197199
ssl_policy = var.https_ssl_policy
198200
certificate_arn = var.certificate_arn
201+
tags = merge(module.this.tags, var.listener_additional_tags)
199202

200203
default_action {
201204
target_group_arn = var.listener_https_fixed_response != null ? null : join("", aws_lb_target_group.default.*.arn)
@@ -216,4 +219,4 @@ resource "aws_lb_listener_certificate" "https_sni" {
216219
count = module.this.enabled && var.https_enabled && var.additional_certs != [] ? length(var.additional_certs) : 0
217220
listener_arn = join("", aws_lb_listener.https.*.arn)
218221
certificate_arn = var.additional_certs[count.index]
219-
}
222+
}

variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -344,3 +344,9 @@ variable "default_target_group_enabled" {
344344
description = "Whether the default target group should be created or not."
345345
default = true
346346
}
347+
348+
variable "listener_additional_tags" {
349+
type = map(string)
350+
default = {}
351+
description = "The additional tags to apply to all listeners"
352+
}

0 commit comments

Comments
 (0)