forked from cloudposse/terraform-aws-iam-s3-user
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
44 lines (37 loc) · 1.04 KB
/
main.tf
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
data "aws_iam_policy_document" "default" {
count = var.enabled == "true" ? 1 : 0
statement {
actions = var.s3_actions
resources = var.s3_resources
effect = "Allow"
}
dynamic "statement" {
for_each = (var.name == "zapier") ? [1] : []
content {
sid = "AllBucketPermissions"
actions = [
"s3:ListAllMyBuckets",
"s3:GetBucketLocation"
]
resources = ["arn:aws:s3:::*"]
effect = "Allow"
}
}
}
module "s3_user" {
source = "git::https://github.com/betterworks/terraform-aws-iam-system-user.git?ref=tags/0.6.0"
namespace = var.namespace
stage = var.stage
name = var.name
attributes = var.attributes
tags = var.tags
enabled = var.enabled
force_destroy = var.force_destroy
path = var.path
}
resource "aws_iam_user_policy" "default" {
count = var.enabled == "true" ? 1 : 0
name = module.s3_user.user_name
user = module.s3_user.user_name
policy = join("", data.aws_iam_policy_document.default.*.json)
}