-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy paths3.tf
More file actions
108 lines (95 loc) · 2.77 KB
/
s3.tf
File metadata and controls
108 lines (95 loc) · 2.77 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# S3 bucket for Unison Cloud native services
resource "aws_s3_bucket" "unison_cloud_byoc_native_services" {
bucket_prefix = "unison-cloud-byoc-services"
force_destroy = true
tags = {
Name = "${var.cluster_name}-services"
Environment = "byoc"
Project = "unison-cloud"
}
}
resource "aws_s3_bucket_public_access_block" "unison_cloud_byoc_native_services" {
bucket = aws_s3_bucket.unison_cloud_byoc_native_services.id
block_public_acls = true
block_public_policy = true
ignore_public_acls = true
restrict_public_buckets = true
}
# S3 bucket for Unison Cloud user blobs
resource "aws_s3_bucket" "unison_cloud_byoc_blobs" {
bucket_prefix = "unison-cloud-byoc-blobs"
force_destroy = true
tags = {
Name = "${var.cluster_name}-blobs"
Environment = "byoc"
Project = "unison-cloud"
}
}
resource "aws_s3_bucket_public_access_block" "unison_cloud_byoc_blobs" {
bucket = aws_s3_bucket.unison_cloud_byoc_blobs.id
block_public_acls = true
block_public_policy = true
ignore_public_acls = true
restrict_public_buckets = true
}
# IAM policy for EC2 instances to access S3 buckets
resource "aws_iam_policy" "byoc_container_s3_policy" {
name_prefix = "byoc-container-s3-"
path = "/"
description = "IAM policy for BYOC containers to access S3 buckets"
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}/*"
]
}
]
})
tags = {
Environment = "byoc"
Project = "unison-cloud"
}
}
# IAM policy for EC2 instances to access DynamoDB
resource "aws_iam_policy" "byoc_container_dynamo_policy" {
name_prefix = "byoc-container-dynamo-"
path = "/"
description = "IAM policy for BYOC containers to access DynamoDB"
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Effect = "Allow"
Action = [
"dynamodb:BatchGetItem",
"dynamodb:BatchWriteItem",
"dynamodb:ConditionCheckItem",
"dynamodb:PutItem",
"dynamodb:DescribeTable",
"dynamodb:DeleteItem",
"dynamodb:GetItem",
"dynamodb:Scan",
"dynamodb:Query",
"dynamodb:UpdateItem"
]
Resource = aws_dynamodb_table.unison_cloud_byoc_state.arn
}
]
})
tags = {
Environment = "byoc"
Project = "unison-cloud"
}
}