diff --git a/cloud-operations/scheduled-asset-inventory-export-bq/README.md b/cloud-operations/scheduled-asset-inventory-export-bq/README.md
index 3aed52508..710aa6727 100644
--- a/cloud-operations/scheduled-asset-inventory-export-bq/README.md
+++ b/cloud-operations/scheduled-asset-inventory-export-bq/README.md
@@ -59,6 +59,7 @@ This is an optional part, and if it is expressed with correct variables, the hig
| *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 |
| *bundle_path_cffile* | Path used to write the intermediate Cloud Function code bundle. | string | | ./bundle_cffile.zip |
+| *cai_gcs_export* | Enable optional part to export tables to GCS | bool | | false |
| *file_config* | Optional BQ table as a file export function config. | object({...}) | | ... |
| *location* | Appe Engine location used in the example. | string | | europe-west |
| *name* | Arbitrary string used to name created resources. | string | | asset-inventory |
diff --git a/cloud-operations/scheduled-asset-inventory-export-bq/main.tf b/cloud-operations/scheduled-asset-inventory-export-bq/main.tf
index ef27264fb..39c1e37df 100644
--- a/cloud-operations/scheduled-asset-inventory-export-bq/main.tf
+++ b/cloud-operations/scheduled-asset-inventory-export-bq/main.tf
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+
+
###############################################################################
# Projects #
###############################################################################
@@ -106,6 +108,7 @@ module "cf" {
}
module "cffile" {
+ count = var.cai_gcs_export ? 1 : 0
source = "../../modules/cloud-function"
project_id = module.project.project_id
region = var.region
@@ -164,6 +167,7 @@ resource "google_cloud_scheduler_job" "job" {
}
resource "google_cloud_scheduler_job" "job_file" {
+ count = var.cai_gcs_export ? 1 : 0
project = google_app_engine_application.app.project
region = var.region
name = "file-export-job"
diff --git a/cloud-operations/scheduled-asset-inventory-export-bq/variables.tf b/cloud-operations/scheduled-asset-inventory-export-bq/variables.tf
index c2137d892..de9aca0d5 100644
--- a/cloud-operations/scheduled-asset-inventory-export-bq/variables.tf
+++ b/cloud-operations/scheduled-asset-inventory-export-bq/variables.tf
@@ -26,12 +26,6 @@ variable "bundle_path" {
default = "./bundle.zip"
}
-variable "bundle_path_cffile" {
- description = "Path used to write the intermediate Cloud Function code bundle."
- type = string
- default = "./bundle_cffile.zip"
-}
-
variable "cai_config" {
description = "Cloud Asset Inventory export config."
type = object({
@@ -42,24 +36,6 @@ variable "cai_config" {
})
}
-variable "file_config" {
- description = "Optional BQ table as a file export function config."
- type = object({
- bucket = string
- filename = string
- format = string
- bq_dataset = string
- bq_table = string
- })
- default = {
- bucket = null
- filename = null
- format = null
- bq_dataset = null
- bq_table = null
- }
-}
-
variable "location" {
description = "Appe Engine location used in the example."
type = string
@@ -73,13 +49,6 @@ variable "name" {
default = "asset-inventory"
}
-
-variable "name_cffile" {
- description = "Arbitrary string used to name created resources."
- type = string
- default = "cffile-exporter"
-}
-
variable "project_create" {
description = "Create project instead ofusing an existing one."
type = bool
@@ -102,3 +71,40 @@ variable "root_node" {
type = string
default = null
}
+
+variable "cai_gcs_export" {
+ description = "Enable optional part to export tables to GCS"
+ type = bool
+ default = false
+}
+
+
+variable "name_cffile" {
+ description = "Arbitrary string used to name created resources."
+ type = string
+ default = "cffile-exporter"
+}
+
+variable "file_config" {
+ description = "Optional BQ table as a file export function config."
+ type = object({
+ bucket = string
+ filename = string
+ format = string
+ bq_dataset = string
+ bq_table = string
+ })
+ default = {
+ bucket = null
+ filename = null
+ format = null
+ bq_dataset = null
+ bq_table = null
+ }
+}
+
+variable "bundle_path_cffile" {
+ description = "Path used to write the intermediate Cloud Function code bundle."
+ type = string
+ default = "./bundle_cffile.zip"
+}
\ No newline at end of file
diff --git a/tests/cloud_operations/scheduled_asset_inventory_export_bq/fixture/main.tf b/tests/cloud_operations/scheduled_asset_inventory_export_bq/fixture/main.tf
index fd5e22d2e..f7bd01af0 100644
--- a/tests/cloud_operations/scheduled_asset_inventory_export_bq/fixture/main.tf
+++ b/tests/cloud_operations/scheduled_asset_inventory_export_bq/fixture/main.tf
@@ -18,6 +18,7 @@ module "test" {
source = "../../../../cloud-operations/scheduled-asset-inventory-export-bq"
billing_account = var.billing_account
cai_config = var.cai_config
+ cai_gcs_export = var.cai_gcs_export
file_config = var.file_config
project_create = var.project_create
project_id = var.project_id
diff --git a/tests/cloud_operations/scheduled_asset_inventory_export_bq/fixture/variables.tf b/tests/cloud_operations/scheduled_asset_inventory_export_bq/fixture/variables.tf
index 8b5212f7c..d80431e33 100644
--- a/tests/cloud_operations/scheduled_asset_inventory_export_bq/fixture/variables.tf
+++ b/tests/cloud_operations/scheduled_asset_inventory_export_bq/fixture/variables.tf
@@ -32,6 +32,11 @@ variable "cai_config" {
}
}
+variable "cai_gcs_export" {
+ type = bool
+ default = true
+}
+
variable "file_config" {
type = object({
bucket = string