/
athena.sp
63 lines (61 loc) · 1.92 KB
/
athena.sp
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
query "athena_database_encryption_at_rest_enabled" {
sql = <<-EOQ
select
address as resource,
case
when (attributes_std -> 'encryption_configuration') is not null then 'ok'
else 'alarm'
end status,
split_part(address, '.', 2) || case
when (attributes_std -> 'encryption_configuration') is not null then ' encrypted at rest'
else ' not encrypted at rest'
end || '.' reason
${local.common_dimensions_sql}
from
terraform_resource
where
type = 'aws_athena_database';
EOQ
}
query "athena_workgroup_encryption_at_rest_enabled" {
sql = <<-EOQ
select
address as resource,
case
when (attributes_std -> 'configuration' -> 'result_configuration' -> 'encryption_configuration') is not null
then 'ok'
else 'alarm'
end status,
split_part(address, '.', 2) || case
when (attributes_std -> 'configuration' -> 'result_configuration' -> 'encryption_configuration') is not null
then ' encrypted at rest'
else ' not encrypted at rest'
end || '.' reason
${local.tag_dimensions_sql}
${local.common_dimensions_sql}
from
terraform_resource
where
type = 'aws_athena_workgroup';
EOQ
}
query "athena_workgroup_enforce_workgroup_configuration" {
sql = <<-EOQ
select
address as resource,
case
when (attributes_std -> 'configuration' -> 'enforce_workgroup_configuration')::boolean then 'ok'
else 'alarm'
end status,
split_part(address, '.', 2) || case
when (attributes_std -> 'configuration' -> 'enforce_workgroup_configuration')::boolean then ' enforce workgroup configuration set'
else ' enforce workgroup configuration not set'
end || '.' reason
${local.tag_dimensions_sql}
${local.common_dimensions_sql}
from
terraform_resource
where
type = 'aws_athena_workgroup';
EOQ
}