Skip to content

Commit b0b52ea

Browse files
committed
feat: add support for module_tags
1 parent 27b9a78 commit b0b52ea

File tree

4 files changed

+52
-18
lines changed

4 files changed

+52
-18
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Add support for `module_tags`
13+
1014
## [0.9.0]
1115

1216
### BREAKING

README.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,35 @@ for details and use-cases.
8989

9090
#### Module Configuration
9191

92-
- **`module_enabled`**: *(Optional `bool`)*
92+
- **`module_enabled`**: _(Optional `bool`)_
9393

9494
Specifies whether resources in the module will be created.
9595
Default is `true`.
9696

97-
- **`module_depends_on`**: *(Optional `list(any)`)*
97+
- **`module_tags`**: _(Optional `map(string)`)_
9898

99-
A list of dependencies. Any object can be _assigned_ to this list to define a
100-
hidden external dependency. Default is `[]`.
99+
A map of tags that will be applied to all created resources that accept tags. Tags defined with 'module_tags' can be
100+
overwritten by resource-specific tags.
101+
Default is `{}`.
102+
103+
Example:
104+
```hcl
105+
module_tags = {
106+
environment = "staging"
107+
team = "platform"
108+
}
109+
```
110+
111+
- **`module_depends_on`**: _(Optional `list(dependencies)`)_
112+
113+
A list of dependencies. Any object can be _assigned_ to this list to define a hidden external dependency.
114+
115+
Example:
116+
```hcl
117+
module_depends_on = [
118+
aws_vpc.vpc
119+
]
120+
```
101121

102122
#### Cognito User Pool
103123

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ resource "aws_cognito_user_pool" "user_pool" {
182182
sms_message = var.sms_message
183183
}
184184

185-
tags = var.tags
185+
tags = merge(var.module_tags, var.tags)
186186
depends_on = [var.module_depends_on]
187187
}
188188

variables.tf

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -174,17 +174,22 @@ variable "default_client_id_token_validity" {
174174

175175
variable "default_client_token_validity_units" {
176176
description = "(Optional) Configuration block for units in which the validity times are represented in."
177-
type = any
178-
default = null
179-
}
177+
# type = object({
178+
# refresh_token = optional(string)
179+
# access_token = optional(string)
180+
# id_token = optional(string)
181+
# })
182+
type = any
183+
default = null
180184

181-
# Example:
182-
#
183-
# default_client_token_validity_units = {
184-
# refresh_token = "days"
185-
# access_token = "minutes"
186-
# id_token = "minutes"
187-
# }
185+
# Example:
186+
#
187+
# default_client_token_validity_units = {
188+
# refresh_token = "days"
189+
# access_token = "minutes"
190+
# id_token = "minutes"
191+
# }
192+
}
188193

189194
variable "default_client_enable_token_revocation" {
190195
description = "(Optional) Enables or disables token revocation."
@@ -500,17 +505,22 @@ variable "tags" {
500505
# ------------------------------------------------------------------------------
501506
# OPTIONAL MODULE CONFIGURATION PARAMETERS
502507
# These variables are used to configure the module.
503-
# See https://medium.com/mineiros/the-ultimate-guide-on-how-to-write-terraform-modules-part-1-81f86d31f024
504508
# ------------------------------------------------------------------------------
505509

506510
variable "module_enabled" {
507511
type = bool
508-
description = "(Optional) Whether to create resources within the module or not. Default is true."
512+
description = "(Optional) Whether to create resources within the module or not."
509513
default = true
510514
}
511515

516+
variable "module_tags" {
517+
type = map(string)
518+
description = "(Optional) A map of tags that will be applied to all created resources that accept tags. Tags defined with 'module_tags' can be overwritten by resource-specific tags."
519+
default = {}
520+
}
521+
512522
variable "module_depends_on" {
513523
type = any
514-
description = "(Optional) A list of external resources the module depends_on. Default is []."
524+
description = "(Optional) A list of external resources the module depends_on."
515525
default = []
516526
}

0 commit comments

Comments
 (0)