-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.tf
64 lines (56 loc) · 1.16 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
terraform {
required_version = "~> 1.0.9"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
}
}
}
provider "aws" {
region = "us-west-2"
}
resource "aws_s3_bucket" "joplin" {
acl = "private"
bucket_prefix = "joplin"
versioning {
enabled = false
}
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
}
resource "aws_iam_user" "joplin" {
name = "joplin-s3-bucket-user"
}
resource "aws_iam_access_key" "joplin" {
user = aws_iam_user.joplin.name
}
resource "aws_iam_user_policy" "joplin" {
name = "joplin-s3-bucket-user-policy"
user = aws_iam_user.joplin.name
policy = jsonencode({
"Version" : "2012-10-17",
"Statement" : [
{
Effect : "Allow",
Action : [
"s3:ListBucket",
"s3:GetBucketLocation",
"s3:GetObject",
"s3:DeleteObject",
"s3:DeleteObjectVersion",
"s3:PutObject"
]
Resource = [
aws_s3_bucket.joplin.arn,
"${aws_s3_bucket.joplin.arn}/*",
]
}
]
})
}