-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathIAM_User_Policy.tf
More file actions
45 lines (41 loc) · 789 Bytes
/
IAM_User_Policy.tf
File metadata and controls
45 lines (41 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
provider "aws" {
region = "us-east-2"
}
resource "aws_iam_user" "lb" {
count = length(var.username)
name = element(var.username,count.index)
path = "/system/"
tags = {
tag-key = "tag-value"
}
}
resource "aws_iam_policy" "policy" {
name = "random-policy"
description = "My test policy"
policy = <<EOT
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"s3:ListAllMyBuckets"
],
"Effect": "Allow",
"Resource": "*"
},
{
"Action": [
"s3:*"
],
"Effect": "Allow",
"Resource": "*"
}
]
}
EOT
}
resource "aws_iam_user_policy_attachment" "attachment" {
count = length(var.username)
user = aws_iam_user.lb[count.index].name
policy_arn = aws_iam_policy.policy.arn
}