diff --git a/README.md b/README.md index ed8dc4d..5881ca5 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,8 @@ You can check the [test/fixtures](test/fixtures/) directory for example configur Required APIs (managed with the [terraform-google-project](https://github.com/osinfra-io/terraform-google-project) child module): +- `bigquerydatatransfer.googleapis.com` (If `enable_cloud_cost_management` is `true`) +- `bigquery.googleapis.com` (If `enable_cloud_cost_management` is `true`) - `cloudasset.googleapis.com` - `cloudbilling.googleapis.com` - `cloudresourcemanager.googleapis.com` diff --git a/global/README.md b/global/README.md index dfc35a8..5b78df7 100644 --- a/global/README.md +++ b/global/README.md @@ -11,8 +11,8 @@ No requirements. | Name | Version | |------|---------| -| [datadog](#provider\_datadog) | 3.33.0 | -| [google](#provider\_google) | 5.8.0 | +| [datadog](#provider\_datadog) | 3.36.1 | +| [google](#provider\_google) | 5.17.0 | ## Modules @@ -23,6 +23,7 @@ No modules. | Name | Type | |------|------| | [datadog_integration_gcp_sts.this](https://registry.terraform.io/providers/datadog/datadog/latest/docs/resources/integration_gcp_sts) | resource | +| [google_bigquery_dataset.billing_export](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/bigquery_dataset) | resource | | [google_logging_project_sink.this](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/logging_project_sink) | resource | | [google_project_iam_member.this](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/project_iam_member) | resource | | [google_pubsub_subscription.this](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/pubsub_subscription) | resource | @@ -37,6 +38,7 @@ No modules. |------|-------------|------|---------|:--------:| | [api\_key](#input\_api\_key) | Datadog API key | `string` | n/a | yes | | [cost\_center](#input\_cost\_center) | The cost center to use for resource labels | `string` | n/a | yes | +| [enable\_cloud\_cost\_management](#input\_enable\_cloud\_cost\_management) | Whether Datadog collects cloud cost management data from your GCP project, this should only be set to true in a single project | `bool` | `false` | no | | [is\_cspm\_enabled](#input\_is\_cspm\_enabled) | Whether Datadog collects cloud security posture management resources from your GCP project | `bool` | `false` | no | | [labels](#input\_labels) | A map of key/value pairs to assign to the resources being created | `map(string)` |
{| no | | [project](#input\_project) | Google Cloud Project ID being monitored | `string` | n/a | yes | diff --git a/global/main.tf b/global/main.tf index 19a2020..849bb15 100644 --- a/global/main.tf +++ b/global/main.tf @@ -18,6 +18,19 @@ resource "datadog_integration_gcp_sts" "this" { host_filters = ["datadog:monitored"] } +# Google BigQuery Dataset Resource +# https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/bigquery_dataset + +resource "google_bigquery_dataset" "billing_export" { + count = var.enable_cloud_cost_management ? 1 : 0 + + dataset_id = "billing_export" + description = "Cloud Billing data to export to BigQuery" + friendly_name = "Billing Export" + labels = local.labels + project = var.project +} + # Google Service Account Resource # https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/google_service_account diff --git a/global/variables.tf b/global/variables.tf index 6eac2a2..0467040 100644 --- a/global/variables.tf +++ b/global/variables.tf @@ -9,6 +9,12 @@ variable "cost_center" { type = string } +variable "enable_cloud_cost_management" { + description = "Whether Datadog collects cloud cost management data from your GCP project, this should only be set to true in a single project" + type = bool + default = false +} + variable "is_cspm_enabled" { description = "Whether Datadog collects cloud security posture management resources from your GCP project" type = bool diff --git a/test/fixtures/default_integration/infracost-usage.yml b/test/fixtures/default_integration/infracost-usage.yml index 3d67561..70574cf 100644 --- a/test/fixtures/default_integration/infracost-usage.yml +++ b/test/fixtures/default_integration/infracost-usage.yml @@ -12,11 +12,19 @@ resource_type_default_usage: # snapshot_storage_gb: 0.0 # Snapshot storage for unacknowledged messages in GB. google_pubsub_topic: monthly_message_data_tb: 0.1 # Monthly amount of message data published to the topic in TB. + ## + ## The following usage values apply to each resource of the given type, which is useful when you want to define defaults. + ## All values are commented-out, you can uncomment resource types and customize as needed. + ## + # google_bigquery_dataset: + # monthly_queries_tb: 0.0 # Monthly number of bytes processed (also referred to as bytes read) in TB. # resource_usage: ## ## The following usage values apply to individual resources and override any value defined in the resource_type_default_usage section. ## All values are commented-out, you can uncomment resources and customize as needed. ## + # module.test.google_bigquery_dataset.billing_export[0]: + # monthly_queries_tb: 0.0 # Monthly number of bytes processed (also referred to as bytes read) in TB. # module.test.google_logging_project_sink.this: # monthly_logging_data_gb: 0.0 # Monthly logging data in GB. # module.test.google_pubsub_subscription.this: diff --git a/test/fixtures/default_integration/main.tf b/test/fixtures/default_integration/main.tf index fe698c4..4ad1283 100644 --- a/test/fixtures/default_integration/main.tf +++ b/test/fixtures/default_integration/main.tf @@ -14,9 +14,10 @@ provider "datadog" { module "test" { source = "../../../global" - api_key = var.api_key - cost_center = "x000" - is_cspm_enabled = true + api_key = var.api_key + cost_center = "x000" + enable_cloud_cost_management = true + is_cspm_enabled = true labels = { env = "sb" diff --git a/test/fixtures/default_integration/variables.tf b/test/fixtures/default_integration/variables.tf index 1da4d54..d40b019 100644 --- a/test/fixtures/default_integration/variables.tf +++ b/test/fixtures/default_integration/variables.tf @@ -13,4 +13,4 @@ variable "app_key" { variable "project" { type = string default = "test-vpc-host-tf12-sb" -} \ No newline at end of file +}
"system": "datadog"
}