Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for path in iam-group-with-assumable-roles-policy #345

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/iam-group-with-assumable-roles-policy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ No modules.
| <a name="input_assumable_roles"></a> [assumable\_roles](#input\_assumable\_roles) | List of IAM roles ARNs which can be assumed by the group | `list(string)` | `[]` | no |
| <a name="input_group_users"></a> [group\_users](#input\_group\_users) | List of IAM users to have in an IAM group which can assume the role | `list(string)` | `[]` | no |
| <a name="input_name"></a> [name](#input\_name) | Name of IAM policy and IAM group | `string` | n/a | yes |
| <a name="input_path"></a> [path](#input\_path) | Path of IAM policy and IAM group | `string` | `"/"` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |

## Outputs
Expand Down
2 changes: 2 additions & 0 deletions modules/iam-group-with-assumable-roles-policy/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ data "aws_iam_policy_document" "assume_role" {

resource "aws_iam_policy" "this" {
name = var.name
path = var.path
description = "Allows to assume role in another AWS account"
policy = data.aws_iam_policy_document.assume_role.json

Expand All @@ -16,6 +17,7 @@ resource "aws_iam_policy" "this" {

resource "aws_iam_group" "this" {
name = var.name
path = var.path
}

resource "aws_iam_group_policy_attachment" "this" {
Expand Down
13 changes: 13 additions & 0 deletions modules/iam-group-with-assumable-roles-policy/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@ variable "name" {
type = string
}

variable "path" {
description = "Path of IAM policy and IAM group"
type = string
default = "/"
validation {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can remove this - its redundant

condition = alltrue([
startswith(var.path, "/"),
endswith(var.path, "/"),
])
error_message = "IAM path must include leading and trailing slashes"
}
}

variable "assumable_roles" {
description = "List of IAM roles ARNs which can be assumed by the group"
type = list(string)
Expand Down