Skip to content

Commit

Permalink
feat: data_warehouse add labels to objects (#253)
Browse files Browse the repository at this point in the history
  • Loading branch information
davenportjw authored Sep 20, 2023
1 parent d2c1256 commit 70962af
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion modules/data_warehouse/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Functional examples are included in the
| deletion\_protection | Whether or not to protect GCS resources from deletion when solution is modified or changed. | `string` | `true` | no |
| enable\_apis | Whether or not to enable underlying apis in this solution. | `string` | `true` | no |
| force\_destroy | Whether or not to protect BigQuery resources from deletion when solution is modified or changed. | `string` | `false` | no |
| labels | A map of labels to apply to contained resources. | `map(string)` | <pre>{<br> "edw-bigquery": true<br>}</pre> | no |
| labels | A map of labels to apply to contained resources. | `map(string)` | <pre>{<br> "data-warehouse": true<br>}</pre> | no |
| project\_id | Google Cloud Project ID | `string` | n/a | yes |
| region | Google Cloud Region | `string` | n/a | yes |

Expand Down
2 changes: 2 additions & 0 deletions modules/data_warehouse/bigquery.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ resource "google_bigquery_table" "tbl_edw_taxi" {

schema = file("${path.module}/src/taxi_trips_schema.json")

labels = var.labels

depends_on = [
google_bigquery_connection.ds_connection,
google_storage_bucket.raw_bucket,
Expand Down
8 changes: 8 additions & 0 deletions modules/data_warehouse/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ resource "google_storage_bucket" "raw_bucket" {
force_destroy = var.force_destroy

public_access_prevention = "enforced"

labels = var.labels
}

# # Set up the provisioning bucketstorage bucket
Expand All @@ -86,13 +88,17 @@ resource "google_storage_bucket" "provisioning_bucket" {
force_destroy = var.force_destroy

public_access_prevention = "enforced"

labels = var.labels
}

// Create Eventarc Trigger
# # Create a Pub/Sub topic.
resource "google_pubsub_topic" "topic" {
name = "provisioning-topic"
project = module.project-services.project_id

labels = var.labels
}

resource "google_pubsub_topic_iam_binding" "binding" {
Expand Down Expand Up @@ -138,6 +144,8 @@ resource "google_eventarc_trigger" "trigger_pubsub_tf" {
}
service_account = google_service_account.eventarc_service_account.email

labels = var.labels

depends_on = [
google_workflows_workflow.workflow,
google_project_iam_member.eventarc_service_account_invoke_role,
Expand Down
3 changes: 2 additions & 1 deletion modules/data_warehouse/src/sql/sp_bigqueryml_model.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ select * from ML.PREDICT(MODEL ds_edw.model_taxi_estimate,

--Model Example
CREATE OR REPLACE MODEL
`${project_id}.ds_edw.model_taxi_estimate` OPTIONS ( MODEL_TYPE='LINEAR_REG',
`${project_id}.ds_edw.model_taxi_estimate`
OPTIONS ( MODEL_TYPE='LINEAR_REG',
LS_INIT_LEARN_RATE=0.15,
L1_REG=1,
MAX_ITERATIONS=5 ) AS
Expand Down
3 changes: 3 additions & 0 deletions modules/data_warehouse/src/sql/sp_lookerstudio_report.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
-- limitations under the License.

CREATE OR REPLACE TABLE `${project_id}.ds_edw.lookerstudio_report`
OPTIONS(
labels=[("data-warehouse","true")]
)
AS
WITH TaxiData AS
(
Expand Down
6 changes: 6 additions & 0 deletions modules/data_warehouse/src/sql/sp_provision_lookup_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ CREATE OR REPLACE TABLE `${project_id}.ds_edw.vendor`
Vendor_Id INTEGER,
Vendor_Description STRING
)
OPTIONS(
labels=[("data-warehouse","true")]
)
AS
SELECT 1, 'Creative Mobile Technologies, LLC'
UNION ALL
Expand All @@ -27,6 +30,9 @@ CREATE OR REPLACE TABLE `${project_id}.ds_edw.payment_type`
Payment_Type_Id INTEGER,
Payment_Type_Description STRING
)
OPTIONS(
labels=[("data-warehouse","true")]
)
AS
SELECT 1, 'Credit card'
UNION ALL
Expand Down
2 changes: 1 addition & 1 deletion modules/data_warehouse/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ variable "region" {
variable "labels" {
type = map(string)
description = "A map of labels to apply to contained resources."
default = { "edw-bigquery" = true }
default = { "data-warehouse" = true }
}

variable "enable_apis" {
Expand Down
2 changes: 2 additions & 0 deletions modules/data_warehouse/workflows.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ resource "google_workflows_workflow" "workflow" {
raw_bucket = google_storage_bucket.raw_bucket.name
})

labels = var.labels

depends_on = [
google_project_iam_member.workflow_service_account_roles,
]
Expand Down

0 comments on commit 70962af

Please sign in to comment.