Skip to content

Commit

Permalink
test terraform
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanvuong2021 committed Jul 22, 2024
1 parent 3cd83cb commit 777de09
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,30 @@ class OperationalMetricsJob(
error("Query job failed with $queryError")
}

val lastMeasurementRead: FieldValueList = resultJob.getQueryResults().iterateAll().first()
val results = resultJob.getQueryResults().iterateAll()
val lastMeasurementRead: FieldValueList? =
if (results.toList().isNotEmpty()) {
results.first()
} else {
null
}
var filter =
StreamMeasurementsRequestKt.filter {
states += Measurement.State.SUCCEEDED
states += Measurement.State.FAILED
states += Measurement.State.CANCELLED
after =
StreamMeasurementsRequestKt.FilterKt.after {
updateTime = lastMeasurementRead.get("update_time").timestampInstant.toProtoTime()
measurement = measurementKey {
externalMeasurementConsumerId =
lastMeasurementRead.get("external_measurement_consumer_id").longValue
externalMeasurementId = lastMeasurementRead.get("external_measurement_id").longValue
if (lastMeasurementRead != null) {
after =
StreamMeasurementsRequestKt.FilterKt.after {
updateTime = lastMeasurementRead.get("update_time").timestampInstant.toProtoTime()
measurement = measurementKey {
externalMeasurementConsumerId =
lastMeasurementRead.get("external_measurement_consumer_id").longValue
externalMeasurementId =
lastMeasurementRead.get("external_measurement_id").longValue
}
}
}
}
}

do {
Expand Down
16 changes: 6 additions & 10 deletions src/main/terraform/gcloud/cmms/kingdom.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,19 @@ module "kingdom_operational_metrics" {
iam_service_account_description = "Operational Metrics Cron Job"
}

resource "google_project_iam_custom_role" "spanner-to-bigquery-role" {
role_id = "spanner_to_bigquery"
title = "Spanner to BigQuery"
description = "Grants reading from Spanner and writing to BigQuery"
resource "google_project_iam_custom_role" "bigquery_row_writer" {
role_id = "bigqueryRowWriter"
title = "BigQuery Row Writer"
description = "Grants reading rows from BigQuery and writing rows to BigQuery"
permissions = [
"spanner.databases.select",
"spanner.sessions.create",
"spanner.sessions.delete",
"bigquery.jobs.create",
"bigquery.tables.get",
"bigquery.tables.getData",
"bigquery.tables.updateData"
]
}

resource "google_project_iam_member" "spanner_to_bigquery_member" {
resource "google_project_iam_member" "bigquery_writer" {
project = "halo-cmm-dev"
role = "roles/spanner_to_bigquery"
role = "roles/bigquery_row_writer"
member = module.kingdom_operational_metrics.iam_service_account.member
}

0 comments on commit 777de09

Please sign in to comment.