forked from cloudposse/terraform-aws-iam-role
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
81 lines (65 loc) · 1.63 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
provider "aws" {
region = var.region
}
module "kms_key" {
source = "cloudposse/kms-key/aws"
version = "0.7.0"
description = "Test KMS key"
deletion_window_in_days = 7
enable_key_rotation = false
context = module.this.context
}
module "bucket" {
source = "cloudposse/s3-bucket/aws"
version = "0.22.0"
user_enabled = false
versioning_enabled = false
force_destroy = true
allow_encrypted_uploads_only = true
sse_algorithm = "aws:kms"
kms_master_key_arn = module.kms_key.key_arn
context = module.this.context
}
data "aws_iam_policy_document" "resource_full_access" {
statement {
sid = "FullAccess"
effect = "Allow"
resources = ["${module.bucket.bucket_arn}/*"]
actions = [
"s3:PutObject",
"s3:PutObjectAcl",
"s3:GetObject",
"s3:DeleteObject",
"s3:ListBucket",
"s3:ListBucketMultipartUploads",
"s3:GetBucketLocation",
"s3:AbortMultipartUpload"
]
}
}
data "aws_iam_policy_document" "base" {
statement {
sid = "BaseAccess"
effect = "Allow"
actions = [
"s3:ListBucket",
"s3:ListBucketVersions"
]
resources = [
module.bucket.bucket_arn
]
}
}
module "role" {
source = "../.."
principals = var.principals
use_fullname = var.use_fullname
policy_documents = [
data.aws_iam_policy_document.resource_full_access.json,
data.aws_iam_policy_document.base.json
]
policy_document_count = 2
policy_description = "Test IAM policy"
role_description = "Test IAM role"
context = module.this.context
}