/
sagemaker.sp
126 lines (121 loc) · 3.74 KB
/
sagemaker.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
query "sagemaker_endpoint_configuration_encryption_at_rest_enabled" {
sql = <<-EOQ
select
address as resource,
case
when (attributes_std -> 'kms_key_arn') is null then 'alarm'
else 'ok'
end as status,
split_part(address, '.', 2) || case
when (attributes_std -> 'kms_key_arn') is null then ' encryption at rest not enabled'
else ' encryption at rest enabled'
end || '.' as reason
${local.tag_dimensions_sql}
${local.common_dimensions_sql}
from
terraform_resource
where
type = 'aws_sagemaker_endpoint_configuration';
EOQ
}
query "sagemaker_notebook_instance_direct_internet_access_disabled" {
sql = <<-EOQ
select
address as resource,
case
when (attributes_std -> 'direct_internet_access') is null or (attributes_std ->> 'direct_internet_access') = 'Disabled' then 'ok'
else 'alarm'
end as status,
split_part(address, '.', 2) || case
when trim(attributes_std ->> 'direct_internet_access') = '' then ' ''direct_internet_access'' is not defined'
when (attributes_std -> 'direct_internet_access') is null or (attributes_std ->> 'direct_internet_access') = 'Disabled' then ' direct internet access disabled'
else ' direct internet access enabled'
end || '.' reason
${local.tag_dimensions_sql}
${local.common_dimensions_sql}
from
terraform_resource
where
type = 'aws_sagemaker_notebook_instance';
EOQ
}
query "sagemaker_notebook_instance_encryption_at_rest_enabled" {
sql = <<-EOQ
select
address as resource,
case
when (attributes_std -> 'kms_key_id') is null then 'alarm'
else 'ok'
end status,
split_part(address, '.', 2) || case
when (attributes_std -> 'kms_key_id') is null then ' encryption at rest disabled'
else ' encryption at rest enabled'
end || '.' reason
${local.tag_dimensions_sql}
${local.common_dimensions_sql}
from
terraform_resource
where
type = 'aws_sagemaker_notebook_instance';
EOQ
}
query "sagemaker_notebook_instance_in_vpc" {
sql = <<-EOQ
select
address as resource,
case
when (attributes_std -> 'subnet_id') is not null then 'ok'
else 'alarm'
end status,
split_part(address, '.', 2) || case
when (attributes_std -> 'subnet_id') is not null then ' in VPC'
else ' not in VPC'
end || '.' reason
${local.tag_dimensions_sql}
${local.common_dimensions_sql}
from
terraform_resource
where
type = 'aws_sagemaker_notebook_instance';
EOQ
}
query "sagemaker_notebook_instance_root_access_disabled" {
sql = <<-EOQ
select
address as resource,
case
when (attributes_std ->> 'root_access') = 'Disabled' then 'ok'
else 'alarm'
end status,
split_part(address, '.', 2) || case
when (attributes_std ->> 'root_access') = 'Disabled' then ' root access disabled'
else ' root access enabled'
end || '.' reason
${local.tag_dimensions_sql}
${local.common_dimensions_sql}
from
terraform_resource
where
type = 'aws_sagemaker_notebook_instance';
EOQ
}
query "sagemaker_domain_encrypted_with_kms_cmk" {
sql = <<-EOQ
select
address as resource,
case
when attributes_std -> 'kms_key_id' is not null then 'ok'
else 'alarm'
end as status,
split_part(address, '.', 2) || case
when attributes_std -> 'kms_key_id' is not null then ' encrypted with KMS'
else ' not encrypted with KMS'
end || '.' as reason
${local.tag_dimensions_sql}
${local.common_dimensions_sql}
from
terraform_resource
where
type = 'aws_sagemaker_domain';
EOQ
}