-
Notifications
You must be signed in to change notification settings - Fork 3
fix: use organization_id smarter #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4595e7a
f4d1ac8
26594d9
1ae3575
6d1b8a2
ec9bc52
7ac1ce4
77b9132
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // ensure that organization_id is not empty, even for project-level integrations | ||
| check "non_empty_organization_id" { | ||
| // There can be multiple reasons for an empty `organization_id`. One example is that the provider project resides | ||
| // in a folder. In this case, google_project.selected[0].org_id will be empty whereas google_project.selected[0].folder_id | ||
| // will be non-empty. We'd need to ask the user to provide the organization_id in such cases. | ||
| assert { | ||
| condition = local.organization_id != "" | ||
| error_message = "No `organization_id` is provided and we failed to derive one. Please provide `organization_id`." | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ locals { | |
| final_project_filter_list = length(var.global_module_reference.project_filter_list) > 0 ? var.global_module_reference.project_filter_list : var.project_filter_list | ||
|
|
||
| scanning_project_id = length(var.scanning_project_id) > 0 ? var.scanning_project_id : data.google_project.selected[0].project_id | ||
| organization_id = length(var.organization_id) > 0 ? var.organization_id : (data.google_project.selected[0].org_id != null ? data.google_project.selected[0].org_id : "") | ||
| organization_id = length(var.organization_id) > 0 ? var.organization_id : (length(data.google_project.selected) > 0 && data.google_project.selected[0].org_id != null ? data.google_project.selected[0].org_id : "") | ||
|
|
||
| agentless_orchestrate_service_account_email = var.global ? google_service_account.agentless_orchestrate[0].email : (length(var.global_module_reference.agentless_orchestrate_service_account_email) > 0 ? var.global_module_reference.agentless_orchestrate_service_account_email : var.agentless_orchestrate_service_account_email) | ||
| agentless_scan_service_account_email = var.global ? google_service_account.agentless_scan[0].email : (length(var.global_module_reference.agentless_scan_service_account_email) > 0 ? var.global_module_reference.agentless_scan_service_account_email : var.agentless_scan_service_account_email) | ||
|
|
@@ -84,8 +84,9 @@ data "lacework_user_profile" "current" {} | |
|
|
||
| data "google_client_config" "default" {} | ||
|
|
||
| // if the scanning project id is not provided, use the project specified in the provider | ||
| data "google_project" "selected" { | ||
| count = length(var.scanning_project_id) > 0 ? (length(var.organization_id) > 0 ? 0 : 1) : 1 | ||
| count = length(var.scanning_project_id) > 0 ? 0 : 1 | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this will make the logic here less convoluted. Previously there's an implicit dependency:
which made things a bit hard to reason about. Hence I'm doing this cleanup, so we'll always try to get the current project regardless whether |
||
| } | ||
|
|
||
| resource "google_project_service" "required_apis" { | ||
|
|
@@ -253,7 +254,7 @@ resource "google_service_account" "agentless_orchestrate" { | |
| resource "google_organization_iam_member" "agentless_orchestrate" { | ||
| count = var.global && (var.integration_type == "ORGANIZATION") ? 1 : 0 | ||
|
|
||
| org_id = var.organization_id | ||
| org_id = local.organization_id | ||
| role = google_organization_iam_custom_role.agentless_orchestrate[0].id | ||
| member = "serviceAccount:${local.agentless_orchestrate_service_account_email}" | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| terraform { | ||
| required_version = ">= 0.12.31" | ||
| required_version = ">= 1.5" | ||
|
|
||
| required_providers { | ||
| google = "~> 4.46" | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.