From b2d42511e5259f289f32fa2ff921bb3402369e48 Mon Sep 17 00:00:00 2001 From: lcaggio Date: Wed, 1 Sep 2021 11:17:06 +0200 Subject: [PATCH 1/5] Fix example --- .../scheduled-asset-inventory-export-bq/main.tf | 11 +++++++++-- .../scheduled-asset-inventory-export-bq/variables.tf | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cloud-operations/scheduled-asset-inventory-export-bq/main.tf b/cloud-operations/scheduled-asset-inventory-export-bq/main.tf index c11b2c1b..b79d8c4f 100644 --- a/cloud-operations/scheduled-asset-inventory-export-bq/main.tf +++ b/cloud-operations/scheduled-asset-inventory-export-bq/main.tf @@ -22,7 +22,7 @@ module "project" { source = "../../modules/project" name = var.project_id parent = var.root_node - billing_account = var.billing_account + billing_account = try(var.billing_account, null) project_create = var.project_create services = [ "bigquery.googleapis.com", @@ -33,6 +33,11 @@ module "project" { "cloudscheduler.googleapis.com", "pubsub.googleapis.com" ] + iam = { + "roles/resourcemanager.projectIamAdmin" = [ "serviceAccount:${module.project.service_accounts.robots.cloudasset}" ] + "roles/bigquery.dataEditor" = [ "serviceAccount:${module.project.service_accounts.robots.cloudasset}" ] + "roles/bigquery.user" = [ "serviceAccount:${module.project.service_accounts.robots.cloudasset}" ] + } } module "service-account" { @@ -40,7 +45,9 @@ module "service-account" { project_id = module.project.project_id name = "${var.name}-cf" iam_project_roles = { - (var.project_id) = ["roles/cloudasset.viewer"] + (var.project_id) = [ + "roles/cloudasset.owner", + ] } } diff --git a/cloud-operations/scheduled-asset-inventory-export-bq/variables.tf b/cloud-operations/scheduled-asset-inventory-export-bq/variables.tf index ab89f77e..6f8217d3 100644 --- a/cloud-operations/scheduled-asset-inventory-export-bq/variables.tf +++ b/cloud-operations/scheduled-asset-inventory-export-bq/variables.tf @@ -17,6 +17,7 @@ variable "billing_account" { description = "Billing account id used as default for new projects." type = string + default = null } variable "bundle_path" { From 8a177b395fdd312351545848a56e278075eac47e Mon Sep 17 00:00:00 2001 From: lcaggio Date: Wed, 1 Sep 2021 11:25:45 +0200 Subject: [PATCH 2/5] Update changelog and fix tests. --- .../scheduled_asset_inventory_export_bq/test_plan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cloud_operations/scheduled_asset_inventory_export_bq/test_plan.py b/tests/cloud_operations/scheduled_asset_inventory_export_bq/test_plan.py index a80a3ac8..de94c82d 100644 --- a/tests/cloud_operations/scheduled_asset_inventory_export_bq/test_plan.py +++ b/tests/cloud_operations/scheduled_asset_inventory_export_bq/test_plan.py @@ -24,4 +24,4 @@ def test_resources(e2e_plan_runner): "Test that plan works and the numbers of resources is as expected." modules, resources = e2e_plan_runner(FIXTURES_DIR) assert len(modules) == 5 - assert len(resources) == 20 + assert len(resources) == 23 From abe602934a6ce375efe91d5376420c11feae8862 Mon Sep 17 00:00:00 2001 From: lcaggio Date: Wed, 1 Sep 2021 11:26:39 +0200 Subject: [PATCH 3/5] Update changelog. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0283331f..eb976dff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file. - new `apigee-organization` and `apigee-x-instance` - generate `email` and `iam_email` statically in the `iam-service-account` module - new `billing-budget` module +- fix `scheduled-asset-inventory-export-bq` module ## [5.1.0] - 2021-08-30 From 2fb8decab3ecb235ca0a8b2a28480cfd0999e716 Mon Sep 17 00:00:00 2001 From: lcaggio Date: Thu, 2 Sep 2021 09:38:33 +0200 Subject: [PATCH 4/5] Fix lint --- .../scheduled-asset-inventory-export-bq/main.tf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cloud-operations/scheduled-asset-inventory-export-bq/main.tf b/cloud-operations/scheduled-asset-inventory-export-bq/main.tf index b79d8c4f..005c0fe3 100644 --- a/cloud-operations/scheduled-asset-inventory-export-bq/main.tf +++ b/cloud-operations/scheduled-asset-inventory-export-bq/main.tf @@ -34,9 +34,9 @@ module "project" { "pubsub.googleapis.com" ] iam = { - "roles/resourcemanager.projectIamAdmin" = [ "serviceAccount:${module.project.service_accounts.robots.cloudasset}" ] - "roles/bigquery.dataEditor" = [ "serviceAccount:${module.project.service_accounts.robots.cloudasset}" ] - "roles/bigquery.user" = [ "serviceAccount:${module.project.service_accounts.robots.cloudasset}" ] + "roles/resourcemanager.projectIamAdmin" = ["serviceAccount:${module.project.service_accounts.robots.cloudasset}"] + "roles/bigquery.dataEditor" = ["serviceAccount:${module.project.service_accounts.robots.cloudasset}"] + "roles/bigquery.user" = ["serviceAccount:${module.project.service_accounts.robots.cloudasset}"] } } From 7327b0214a9613be3f14559114a682a33b13ddae Mon Sep 17 00:00:00 2001 From: lcaggio Date: Thu, 2 Sep 2021 09:45:51 +0200 Subject: [PATCH 5/5] Fix documentation. --- cloud-operations/scheduled-asset-inventory-export-bq/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud-operations/scheduled-asset-inventory-export-bq/README.md b/cloud-operations/scheduled-asset-inventory-export-bq/README.md index 44c6ecbb..1abecdd9 100644 --- a/cloud-operations/scheduled-asset-inventory-export-bq/README.md +++ b/cloud-operations/scheduled-asset-inventory-export-bq/README.md @@ -43,9 +43,9 @@ You can also create a dashboard connecting [Datalab](https://datastudio.google.c | name | description | type | required | default | |---|---|:---: |:---:|:---:| -| billing_account | Billing account id used as default for new projects. | string | ✓ | | | cai_config | Cloud Asset inventory export config. | object({...}) | ✓ | | | project_id | Project id that references existing project. | string | ✓ | | +| *billing_account* | Billing account id used as default for new projects. | string | | null | | *bundle_path* | Path used to write the intermediate Cloud Function code bundle. | string | | ./bundle.zip | | *location* | Appe Engine location used in the example. | string | | europe-west | | *name* | Arbitrary string used to name created resources. | string | | asset-inventory |