forked from rancherfederal/rke2-aws-tf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
49 lines (42 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
44
45
46
47
48
49
resource "aws_s3_bucket" "bucket" {
bucket = lower("${var.name}-rke2")
force_destroy = true
tags = merge({}, var.tags)
}
resource "aws_s3_bucket_acl" "acl" {
bucket = aws_s3_bucket.bucket.id
acl = "private"
}
resource "aws_s3_bucket_server_side_encryption_configuration" "ssec" {
bucket = aws_s3_bucket.bucket.id
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "aws:kms"
}
}
}
resource "aws_s3_object" "token" {
bucket = aws_s3_bucket.bucket.id
key = "token"
content_type = "text/plain"
content = var.token
server_side_encryption = "aws:kms"
}
data "aws_iam_policy_document" "getter" {
statement {
effect = "Allow"
actions = ["s3:GetObject"]
resources = [
"${aws_s3_bucket.bucket.arn}/${aws_s3_object.token.id}",
]
}
}
data "aws_iam_policy_document" "setter" {
statement {
effect = "Allow"
actions = ["s3:PutObject"]
resources = [
"${aws_s3_bucket.bucket.arn}/rke2.yaml",
]
}
}