This repository was archived by the owner on Jul 11, 2023. It is now read-only.
File tree 2 files changed +47
-0
lines changed
2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ variable "group_name" {
2
+ description = " The name of the group"
3
+ type = string
4
+ }
5
+
6
+ variable "members" {
7
+ description = " List of strings, where each entry is the username for a user in IAM that should be a member of the group"
8
+ type = list (string )
9
+ }
10
+
11
+ variable "path" {
12
+ default = " /"
13
+ description = " string path in IAM, for the users created (all get the same path)"
14
+ type = string
15
+ }
16
+
17
+ variable "policy_arns" {
18
+ default = []
19
+ description = " List of strings, where each entry is the name of an IAM policy to attach to the group"
20
+ type = list (string )
21
+ }
22
+
23
+ resource "aws_iam_group" "g" {
24
+ name = var. group_name
25
+ }
26
+
27
+ # ## The list of users are each members of this group
28
+ resource "aws_iam_group_membership" "main" {
29
+ group = aws_iam_group. g . name
30
+ name = var. group_name
31
+ users = var. members
32
+ }
33
+
34
+ resource "aws_iam_group_policy_attachment" "main" {
35
+ count = length (var. policy_arns )
36
+ group = aws_iam_group. g . name
37
+ policy_arn = var. policy_arns [count . index ]
38
+ }
39
+
40
+ output "group" {
41
+ description = " The IAM group object"
42
+ value = aws_iam_group. g
43
+ }
Original file line number Diff line number Diff line change
1
+
2
+ terraform {
3
+ required_version = " >= 0.12"
4
+ }
You can’t perform that action at this time.
0 commit comments