-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vm,cloud-scan): enables organizational use-case (#23)
- Loading branch information
iru
authored
Mar 18, 2024
1 parent
3ee5fc4
commit 66e6f78
Showing
20 changed files
with
241 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
resource "google_organization_iam_custom_role" "controller" { | ||
count = local.is_organizational ? 1 : 0 | ||
|
||
org_id = data.google_organization.org[0].org_id | ||
role_id = "${var.role_name}Discovery${title(local.suffix)}" | ||
title = "${var.role_name}, for Host Discovery" | ||
permissions = local.host_discovery_permissions | ||
} | ||
|
||
resource "google_organization_iam_binding" "controller_custom" { | ||
count = local.is_organizational ? 1 : 0 | ||
|
||
org_id = data.google_organization.org[0].org_id | ||
role = google_organization_iam_custom_role.controller[0].id | ||
members = [ | ||
"serviceAccount:${google_service_account.controller.email}", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
resource "google_project_iam_custom_role" "controller" { | ||
count = local.is_organizational ? 0 : 1 | ||
|
||
project = var.project_id | ||
role_id = "${var.role_name}Discovery${title(local.suffix)}" | ||
title = "${var.role_name}, for Host Discovery" | ||
permissions = local.host_discovery_permissions | ||
} | ||
|
||
resource "google_project_iam_binding" "controller_custom" { | ||
count = local.is_organizational ? 0 : 1 | ||
|
||
project = var.project_id | ||
role = google_project_iam_custom_role.controller[0].id | ||
members = [ | ||
"serviceAccount:${google_service_account.controller.email}", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
data "google_project" "project" { | ||
project_id = var.project_id | ||
} | ||
|
||
data "google_organization" "org" { | ||
count = local.is_organizational ? 1 : 0 | ||
domain = var.organization_domain | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
resource "google_organization_iam_custom_role" "worker_role" { | ||
count = local.is_organizational ? 1 : 0 | ||
|
||
org_id = data.google_organization.org[0].org_id | ||
role_id = "${var.role_name}Scan${title(local.suffix)}" | ||
title = "${var.role_name}, for Host Scan" | ||
permissions = local.host_scan_permissions | ||
} | ||
|
||
resource "google_organization_iam_binding" "admin_account_iam" { | ||
count = local.is_organizational ? 1 : 0 | ||
|
||
org_id = data.google_organization.org[0].org_id | ||
role = google_organization_iam_custom_role.worker_role[0].id | ||
members = [ | ||
"serviceAccount:${var.worker_identity}", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
resource "google_project_iam_custom_role" "worker_role" { | ||
count = local.is_organizational ? 0 : 1 | ||
|
||
project = var.project_id | ||
role_id = "${var.role_name}Scan${title(local.suffix)}" | ||
title = "${var.role_name}, for Host Scan" | ||
permissions = local.host_scan_permissions | ||
} | ||
|
||
resource "google_project_iam_binding" "admin_account_iam" { | ||
count = local.is_organizational ? 0 : 1 | ||
|
||
project = var.project_id | ||
role = google_project_iam_custom_role.worker_role[0].id | ||
members = [ | ||
"serviceAccount:${var.worker_identity}", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
note; | ||
|
||
- we test the cloud-scan module together with its dependencies on the minimal use-case | ||
- cspm; for discovery + organizational setup (`secure-onboarding` component) | ||
- sysdig provider `sysdig_secure_cloud_auth_account`; for authentication |
9 changes: 9 additions & 0 deletions
9
test/examples/agentless-scan/organization/deps_scanning_org.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# this is required for organizational setup (+cloud-host vm) | ||
|
||
module "organization-posture" { | ||
source = "sysdiglabs/secure/google//modules/services/service-principal" | ||
project_id = "org-child-project-1" | ||
service_account_name = "sysdig-secure-igm6" | ||
is_organizational = true | ||
organization_domain = "draios.com" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
provider "google"{ | ||
project="mytestproject" | ||
} | ||
|
||
|
||
module "cloud_host" { | ||
source = "../../../..//modules/services/agentless-scan" | ||
project_id = "mytestproject" | ||
sysdig_account_id = "012345678" | ||
worker_identity = "[email protected]" | ||
|
||
is_organizational = true | ||
organization_domain = "myorg.com" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
terraform { | ||
required_version = ">=1.0" | ||
|
||
required_providers { | ||
google = { | ||
source = "hashicorp/google" | ||
version = ">= 4.1, < 5.0" | ||
} | ||
random = { | ||
source = "hashicorp/random" | ||
version = ">= 3.1, < 4.0" | ||
} | ||
sysdig = { | ||
source = "sysdiglabs/sysdig" | ||
version = ">= 1.23.1" | ||
} | ||
} | ||
} |
Oops, something went wrong.