Skip to content

Commit 8500922

Browse files
authored
Merge pull request hashicorp#1 from hashicorp/master
Repo update 17FEB21
2 parents 20a7e27 + c276b5e commit 8500922

15 files changed

+4800
-4
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This policy uses the Sentinel tfplan/v2 import to require that
2+
# all Sagemaker Notebook instances have root access and direct internet access
3+
# disabled
4+
5+
# Import common-functions/tfplan-functions/tfplan-functions.sentinel
6+
# with alias "plan"
7+
import "tfplan-functions" as plan
8+
9+
# Get all Sagemaker notebooks
10+
allSagemakerNotebooks = plan.find_resources("aws_sagemaker_notebook_instance")
11+
#print("allSagemakerNotebooks:", allSagemakerNotebooks)
12+
13+
# Filter to Sagemaker notebooks that have root_access set to "Enabled"
14+
# or missing.
15+
# Warnings will be printed for all violations since the last parameter is true
16+
sagemakerNotebooksWithRootAccess = plan.filter_attribute_is_not_value(
17+
allSagemakerNotebooks, "root_access", "Disabled", true)
18+
19+
# Filter to Sagemaker notebooks that have direct_internet_access set to "Enabled"
20+
# or missing.
21+
# Warnings will be printed for all violations since the last parameter is true
22+
sagemakerNotebooksWithDirectInternetAccess = plan.filter_attribute_is_not_value(
23+
allSagemakerNotebooks, "direct_internet_access", "Disabled", true)
24+
25+
# Main rule
26+
validated = length(sagemakerNotebooksWithRootAccess["messages"]) is 0 and length(sagemakerNotebooksWithDirectInternetAccess["messages"]) is 0
27+
main = rule {
28+
validated is true
29+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module "tfplan-functions" {
2+
source = "../../../common-functions/tfplan-functions/tfplan-functions.sentinel"
3+
}
4+
5+
mock "tfplan/v2" {
6+
module {
7+
source = "mock-tfplan-fail-direct-internet.sentinel"
8+
}
9+
}
10+
11+
test {
12+
rules = {
13+
main = false
14+
}
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module "tfplan-functions" {
2+
source = "../../../common-functions/tfplan-functions/tfplan-functions.sentinel"
3+
}
4+
5+
mock "tfplan/v2" {
6+
module {
7+
source = "mock-tfplan-fail-missing-values.sentinel"
8+
}
9+
}
10+
11+
test {
12+
rules = {
13+
main = false
14+
}
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module "tfplan-functions" {
2+
source = "../../../common-functions/tfplan-functions/tfplan-functions.sentinel"
3+
}
4+
5+
mock "tfplan/v2" {
6+
module {
7+
source = "mock-tfplan-fail-root-access.sentinel"
8+
}
9+
}
10+
11+
test {
12+
rules = {
13+
main = false
14+
}
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module "tfplan-functions" {
2+
source = "../../../common-functions/tfplan-functions/tfplan-functions.sentinel"
3+
}
4+
5+
mock "tfplan/v2" {
6+
module {
7+
source = "mock-tfplan-fail-root-and-internet-access.sentinel"
8+
}
9+
}
10+
11+
test {
12+
rules = {
13+
main = false
14+
}
15+
}

0 commit comments

Comments
 (0)