Add count to toggle optional modules

This commit is contained in:
Arseny Chernov
2021-12-23 22:07:14 +08:00
parent 19f6127e8a
commit 6717abf0e1
5 changed files with 48 additions and 31 deletions

View File

@@ -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. | <code title="">string</code> | | <code title="">null</code> |
| *bundle_path* | Path used to write the intermediate Cloud Function code bundle. | <code title="">string</code> | | <code title="">./bundle.zip</code> |
| *bundle_path_cffile* | Path used to write the intermediate Cloud Function code bundle. | <code title="">string</code> | | <code title="">./bundle_cffile.zip</code> |
| *cai_gcs_export* | Enable optional part to export tables to GCS | <code title="">bool</code> | | <code title="">false</code> |
| *file_config* | Optional BQ table as a file export function config. | <code title="object&#40;&#123;&#10;bucket &#61; string&#10;filename &#61; string&#10;format &#61; string&#10;bq_dataset &#61; string&#10;bq_table &#61; string&#10;&#125;&#41;">object({...})</code> | | <code title="&#123;&#10;bucket &#61; null&#10;filename &#61; null&#10;format &#61; null&#10;bq_dataset &#61; null&#10;bq_table &#61; null&#10;&#125;">...</code> |
| *location* | Appe Engine location used in the example. | <code title="">string</code> | | <code title="">europe-west</code> |
| *name* | Arbitrary string used to name created resources. | <code title="">string</code> | | <code title="">asset-inventory</code> |

View File

@@ -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"

View File

@@ -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"
}

View File

@@ -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

View File

@@ -32,6 +32,11 @@ variable "cai_config" {
}
}
variable "cai_gcs_export" {
type = bool
default = true
}
variable "file_config" {
type = object({
bucket = string