Skip to content

Commit

Permalink
Merge pull request #31 from mineiros-io/soerenmartius/add-tags
Browse files Browse the repository at this point in the history
Add module_tags and instance_profile_tags
  • Loading branch information
soerenmartius authored Aug 31, 2021
2 parents e1e8f4e + 204cc6b commit 3dfa489
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 4 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.6.1]

### Added

- Add `module_tags` from template
- Add `instance_profile_tags` for setting specific tags for the IAM instance profile

## [0.6.0]

### Added
Expand Down Expand Up @@ -89,11 +96,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<!-- markdown-link-check-disable -->

[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

<!-- markdown-link-check-disabled -->

[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
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}

Expand Down Expand Up @@ -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]
}
5 changes: 5 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
15 changes: 14 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
}

Expand Down Expand Up @@ -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 []."
Expand Down

0 comments on commit 3dfa489

Please sign in to comment.