forked from turbot/steampipe-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevent_planning.sp
58 lines (56 loc) · 1.28 KB
/
event_planning.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
variable "valid_sessions" {
type = list(string)
default = ["101","102","103","104","105","201","202","203","204","205"]
}
control "sessions_valid_in_session_table" {
title = "Sessions in the sessions table are valid"
sql = <<EOT
select
'event planner' as resource,
case
when (
session = any( $1 )
) then 'ok'
else 'alarm'
end as status,
'Session ' || session as reason
from
csv.sessions
EOT
param "valid_sessions" {
default = var.valid_sessions
}
}
control "sessions_valid_in_people_table" {
title = "Sessions in the people table are valid"
sql = <<EOT
with person_session as (
select
person,
string_to_array(
regexp_replace(sessions, '\s', '', 'g'),
','
) as sessions
from csv.people
),
unnested as (
select
unnest(sessions) as session
from
person_session
)
select distinct
'event planner' as resource,
case
when (
session = any( $1 )
) then 'ok'
else 'alarm'
end as status,
'Session ' || session as reason
from unnested
EOT
param "valid_sessions" {
default = var.valid_sessions
}
}