From f7860cd44015877dd079c9f16da7c8fd67f6c0ce Mon Sep 17 00:00:00 2001 From: Soren Martius Date: Thu, 26 Aug 2021 10:39:20 +0300 Subject: [PATCH 1/2] feat: add module_tags and instance_profile_tags --- CHANGELOG.md | 5 +++++ README.md | 12 ++++++++++++ main.tf | 3 ++- outputs.tf | 5 +++++ variables.tf | 15 ++++++++++++++- 5 files changed, 38 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd22aeb..4835d80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Add `module_tags` from template +- Add `instance_profile_tags` for setting specific tags for the IAM instance profile + ## [0.6.0] ### Added diff --git a/README.md b/README.md index 533170c..4b72e0a 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,12 @@ See [variables.tf] and [examples/] for details and use-cases. Specifies whether resources in the module will be created. Default is `true`. +- **`module_tags`**: _(Optional `map(string)`)_ + + 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. + Default is `{}`. + - **`module_depends_on`**: *(Optional `list(any)`)* A list of dependencies. @@ -196,6 +202,7 @@ See [variables.tf] and [examples/] for details and use-cases. - **`tags`**: *(Optional `map(string)`)* Key-value map of tags for the IAM role. + Default is `{}`. #### Extended Resource configuration @@ -274,6 +281,11 @@ See [variables.tf] and [examples/] for details and use-cases. Path in which to create the profile. Default is `/`. +- **`instance_profile_tags`**: *(Optional `map(string)`)* + + Key-value map of tags for the IAM instance profile. + Default is `{}`. + ## Module Attributes Reference The following attributes are exported by the module: diff --git a/main.tf b/main.tf index e8dd6a8..a1d034c 100644 --- a/main.tf +++ b/main.tf @@ -51,8 +51,8 @@ resource "aws_iam_role" "role" { description = var.description max_session_duration = var.max_session_duration permissions_boundary = var.permissions_boundary - tags = var.tags + tags = merge(var.module_tags, var.tags) depends_on = [var.module_depends_on] } @@ -166,5 +166,6 @@ resource "aws_iam_instance_profile" "instance_profile" { role = aws_iam_role.role[0].name + tags = merge(var.module_tags, var.instance_profile_tags) depends_on = [var.module_depends_on] } diff --git a/outputs.tf b/outputs.tf index 120430e..832d5c6 100644 --- a/outputs.tf +++ b/outputs.tf @@ -38,3 +38,8 @@ output "module_enabled" { description = "Whether the module is enabled" value = var.module_enabled } + +output "module_tags" { + description = "A map of tags that will be applied to all created resources that accept tags." + value = var.module_tags +} diff --git a/variables.tf b/variables.tf index e63b554..ace24ed 100644 --- a/variables.tf +++ b/variables.tf @@ -104,7 +104,7 @@ variable "permissions_boundary" { variable "tags" { type = map(string) - description = "Key-value map of tags for the IAM role" + description = "(Optional) Key-value map of tags for the IAM role" default = {} } @@ -168,17 +168,30 @@ variable "instance_profile_path" { default = "/" } +variable "instance_profile_tags" { + type = map(string) + description = "(Optional) Key-value map of tags for the IAM instance profile" + default = {} +} + # ------------------------------------------------------------------------------ # MODULE CONFIGURATION PARAMETERS # These variables are used to configure the module. # See https://medium.com/mineiros/the-ultimate-guide-on-how-to-write-terraform-modules-part-1-81f86d31f024 # ------------------------------------------------------------------------------ + variable "module_enabled" { type = bool description = "(Optional) Whether to create resources within the module or not. Default is true." default = true } +variable "module_tags" { + type = map(string) + 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." + default = {} +} + variable "module_depends_on" { type = any description = "(Optional) A list of external resources the module depends_on. Default is []." From 204cc6bec2452fd19f75d467f8276277317c00d8 Mon Sep 17 00:00:00 2001 From: Soren Martius Date: Thu, 26 Aug 2021 19:06:24 +0300 Subject: [PATCH 2/2] chore: prepare v0.6.1 release --- CHANGELOG.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4835d80..4082697 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.6.1] + ### Added - Add `module_tags` from template @@ -94,11 +96,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 -[unreleased]: https://github.com/mineiros-io/terraform-aws-iam-role/compare/v0.6.0...HEAD -[0.6.0]: https://github.com/mineiros-io/terraform-aws-iam-role/compare/v0.5.0...v0.6.0 +[unreleased]: https://github.com/mineiros-io/terraform-aws-iam-role/compare/v0.6.1...HEAD +[0.6.1]: https://github.com/mineiros-io/terraform-aws-iam-role/compare/v0.6.0...v0.6.1 +[0.6.0]: https://github.com/mineiros-io/terraform-aws-iam-role/compare/v0.5.0...v0.6.0 [0.5.0]: https://github.com/mineiros-io/terraform-aws-iam-role/compare/v0.4.2...v0.5.0 [0.4.2]: https://github.com/mineiros-io/terraform-aws-iam-role/compare/v0.4.1...v0.4.2 [0.4.1]: https://github.com/mineiros-io/terraform-aws-iam-role/compare/v0.4.0...v0.4.1