-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.tf
68 lines (49 loc) · 1.66 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
resource "aws_s3_bucket" "athena-workspace" {
bucket = var.workgroup_bucket
force_destroy = var.force_destroy
tags = merge(var.default_tags, var.s3_bucket_tags)
}
resource "aws_s3_bucket_lifecycle_configuration" "athena-workspace" {
count = var.workspace_bucket_expiration_days != null ? 1 : 0
bucket = aws_s3_bucket.athena-workspace.bucket
rule {
id = "expire"
status = "Enabled"
# applies to all objects in the bucket:
# omitting `filter` is effectively the same, but it's a bit confusing,
# as it will generate a filter with an empty path prefix.
filter {}
expiration {
days = var.workspace_bucket_expiration_days
}
}
}
resource "aws_s3_bucket_public_access_block" "athena-workspace" {
bucket = aws_s3_bucket.athena-workspace.bucket
block_public_acls = true
ignore_public_acls = true
block_public_policy = true
restrict_public_buckets = true # forbids setting cross-account access policies as well
}
resource "aws_s3_bucket_ownership_controls" "athena-workspace" {
bucket = aws_s3_bucket.athena-workspace.bucket
rule {
object_ownership = "BucketOwnerEnforced"
}
}
resource "aws_athena_workgroup" "this" {
name = var.name
force_destroy = var.force_destroy
configuration {
enforce_workgroup_configuration = true
publish_cloudwatch_metrics_enabled = false
engine_version {
selected_engine_version = var.selected_engine_version
}
bytes_scanned_cutoff_per_query = var.workspace_bytes_scanned_cutoff
result_configuration {
output_location = "s3://${aws_s3_bucket.athena-workspace.bucket}/"
}
}
tags = merge(var.default_tags, var.athena_workgroup_tags)
}