Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

Commit

Permalink
enable use of existing group
Browse files Browse the repository at this point in the history
  • Loading branch information
psellars-hyprnz committed Jun 2, 2020
1 parent 71d02bf commit 01a1973
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions policy-to-group/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This module ill create a IAM policy and group and bind the policy to the group.

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| create\_group | Whether to create the IAM group or not | bool | true | yes |
| group\_name | The name of the group to bind the policy to | string | n/a | yes |
| policy\_actions | A List of policy actions | list | n/a | yes |
| policy\_name | The name of the policy to create | string | n/a | yes |
Expand Down
6 changes: 4 additions & 2 deletions policy-to-group/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ resource "aws_iam_policy" "this" {
}

resource "aws_iam_group" "this" {
name = var.group_name
count = var.create_group ? 1 : 0
name = var.group_name
}

resource "aws_iam_group_policy_attachment" "this" {
group = aws_iam_group.this.name
# group = aws_iam_group.this.name
group = var.group_name
policy_arn = aws_iam_policy.this.arn
}

6 changes: 6 additions & 0 deletions policy-to-group/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ variable "policy_resources" {
default = ["*"]
}

variable "create_group" {
description = "Whether to create the IAM group or not"
type = bool
default = true
}

variable "group_name" {
description = "The name of the group to bind the policy to"
}
Expand Down

0 comments on commit 01a1973

Please sign in to comment.