Skip to content

Commit

Permalink
fix: avoid asking for project_id when is not needed (#22)
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 <afiune@lacework.net>
  • Loading branch information
afiune authored Feb 23, 2023
1 parent 3890684 commit 7bc97b7
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,6 +1,6 @@
locals {
resource_level = "PROJECT"
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
service_account_name = var.use_existing_service_account ? (
var.service_account_name
) : (
Expand All @@ -18,7 +18,9 @@ resource "random_id" "uniq" {
byte_length = 4
}

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

module "lacework_gar_svc_account" {
source = "lacework/service-account/gcp"
Expand Down

0 comments on commit 7bc97b7

Please sign in to comment.