Skip to content

Commit

Permalink
fix: avoid asking for project_id when is not needed (#79)
Browse files Browse the repository at this point in the history
Avoid error message:
```
Error: no project value set. project_id must be set at the resource level, or a default project value must be specified on the provider
```

Signed-off-by: Salim Afiune Maya <[email protected]>
  • Loading branch information
afiune authored Feb 23, 2023
1 parent 68202f4 commit eb5f4cb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
locals {
resource_level = var.org_integration ? "ORGANIZATION" : "PROJECT"
resource_id = var.org_integration ? var.organization_id : module.lacework_at_svc_account.project_id
project_id = length(var.project_id) > 0 ? var.project_id : data.google_project.selected.project_id
project_id = length(var.project_id) > 0 ? var.project_id : data.google_project.selected[0].project_id

bucket_name = length(var.existing_bucket_name) > 0 ? var.existing_bucket_name : (
length(google_storage_bucket.lacework_bucket) > 0 ? google_storage_bucket.lacework_bucket[0].name : var.existing_bucket_name
Expand Down Expand Up @@ -102,7 +102,9 @@ resource "random_id" "uniq" {
byte_length = 4
}

data "google_project" "selected" {}
data "google_project" "selected" {
count = length(var.project_id) > 0 ? 0 : 1
}

data "google_folders" "my-org-folders" {
count = (var.org_integration && local.exclude_folders) ? 1 : 0
Expand Down

0 comments on commit eb5f4cb

Please sign in to comment.