Skip to content

Commit 89c8873

Browse files
jacklearyaxelkrastek1-nhs
authored andcommitted
NRL-1188 athena set up
1 parent 58815a5 commit 89c8873

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
resource "aws_athena_database" "reporting-db" {
2+
name = var.database
3+
4+
bucket = aws_s3_bucket.target-data-bucket.bucket
5+
6+
# encryption_configuration {
7+
# encryption_option = var.encryption_option
8+
# kms_key = var.kms_key_arn
9+
# }
10+
11+
force_destroy = true
12+
}
13+
14+
resource "aws_athena_workgroup" "athena" {
15+
name = var.name_prefix
16+
17+
configuration {
18+
enforce_workgroup_configuration = true
19+
publish_cloudwatch_metrics_enabled = true
20+
21+
result_configuration {
22+
output_location = "s3://{aws_s3_bucket.example.bucket}/output/"
23+
24+
encryption_configuration {
25+
encryption_option = "SSE_KMS"
26+
kms_key_arn = var.kms_key_arn
27+
}
28+
}
29+
}
30+
31+
tags = var.common_tags
32+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
output "workgroup" {
2+
value = aws_athena_workgroup.athena
3+
}
4+
5+
output "bucket" {
6+
value = aws_s3_bucket.athena
7+
}
8+
9+
output "database" {
10+
value = aws_athena_database.reporting-db
11+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
resource "aws_s3_bucket" "athena" {
2+
bucket = "athena"
3+
}
4+
5+
6+
resource "aws_s3_bucket_server_side_encryption_configuration" "athena" {
7+
bucket = aws_s3_bucket.athena.bucket
8+
rule {
9+
apply_server_side_encryption_by_default {
10+
sse_algorithm = "aws:kms"
11+
kms_master_key_id = var.kms_key_arn
12+
}
13+
}
14+
15+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
variable "database" {
2+
description = "What the db will be called"
3+
default = "NRL-Reporting"
4+
}
5+
6+
variable "name_prefix" {
7+
type = string
8+
description = "The prefix to apply to all resources in the module."
9+
}

0 commit comments

Comments
 (0)