-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathiam.tf
More file actions
84 lines (76 loc) · 1.91 KB
/
iam.tf
File metadata and controls
84 lines (76 loc) · 1.91 KB
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
82
83
84
# IAM role for Unison Cloud instances
resource "aws_iam_role" "unison" {
name = "${var.cluster_name}-unison-role"
assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = "sts:AssumeRole"
Effect = "Allow"
Principal = {
Service = "ec2.amazonaws.com"
}
}
]
})
tags = {
Name = "${var.cluster_name}-unison-role"
Environment = "byoc"
Project = "unison-cloud"
}
}
# IAM policy for S3 access
resource "aws_iam_role_policy" "unison_s3" {
name = "${var.cluster_name}-unison-s3-policy"
role = aws_iam_role.unison.id
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Effect = "Allow"
Action = [
"s3:GetObject",
"s3:PutObject",
"s3:DeleteObject",
"s3:ListBucket"
]
Resource = [
aws_s3_bucket.unison_cloud_byoc_native_services.arn,
"${aws_s3_bucket.unison_cloud_byoc_native_services.arn}/*",
aws_s3_bucket.unison_cloud_byoc_blobs.arn,
"${aws_s3_bucket.unison_cloud_byoc_blobs.arn}/*"
]
}
]
})
}
# IAM policy for CloudWatch logs
resource "aws_iam_role_policy" "unison_cloudwatch" {
name = "${var.cluster_name}-unison-cloudwatch-policy"
role = aws_iam_role.unison.id
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Effect = "Allow"
Action = [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
"logs:DescribeLogStreams"
]
Resource = "*"
}
]
})
}
# Instance profile for Unison instances
resource "aws_iam_instance_profile" "unison" {
name = "${var.cluster_name}-unison-profile"
role = aws_iam_role.unison.name
tags = {
Name = "${var.cluster_name}-unison-profile"
Environment = "byoc"
Project = "unison-cloud"
}
}