-
-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pudl usage metrics gcp infrastructure #3841
Changes from all commits
63f524d
1aaac08
fe095b9
64234ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -228,7 +228,7 @@ resource "google_cloud_run_v2_service" "pudl-superset" { | |
volumes { | ||
name = "cloudsql" | ||
cloud_sql_instance { | ||
instances = ["catalyst-cooperative-pudl:us-central1:superset-database"] | ||
instances = ["catalyst-cooperative-pudl:us-central1:superset-database", "catalyst-cooperative-pudl:us-central1:pudl-usage-metrics-db"] | ||
} | ||
} | ||
} | ||
|
@@ -396,3 +396,47 @@ resource "google_service_account_iam_member" "gce-default-account-iam" { | |
role = "roles/iam.serviceAccountUser" | ||
member = "serviceAccount:[email protected]" | ||
} | ||
|
||
resource "google_secret_manager_secret" "pudl_usage_metrics_db_connection_string" { | ||
secret_id = "pudl-usage-metrics-db-connection-string" | ||
replication { | ||
auto {} | ||
} | ||
} | ||
|
||
resource "google_storage_bucket" "pudl_usage_metrics_archive_bucket" { | ||
name = "pudl-usage-metrics-archives.catalyst.coop" | ||
location = "US" | ||
storage_class = "STANDARD" | ||
|
||
uniform_bucket_level_access = true | ||
} | ||
|
||
resource "google_service_account" "usage_metrics_archiver" { | ||
account_id = "usage-metrics-archiver" | ||
display_name = "PUDL usage metrics archiver github action service account" | ||
} | ||
Comment on lines
+415
to
+418
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did create a service account key for the GitHub action in the business repo. @jdangerx would love a WIF tutorial soon! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've forgotten everything I know about WIF but could re-learn it! |
||
|
||
resource "google_storage_bucket_iam_member" "usage_metrics_archiver_gcs_iam" { | ||
for_each = toset(["roles/storage.objectCreator", "roles/storage.objectViewer"]) | ||
|
||
bucket = google_storage_bucket.pudl_usage_metrics_archive_bucket.name | ||
role = each.key | ||
member = "serviceAccount:${google_service_account.usage_metrics_archiver.email}" | ||
} | ||
|
||
resource "google_storage_bucket_iam_member" "usage_metrics_etl_gcs_iam" { | ||
for_each = toset(["roles/storage.legacyBucketReader", "roles/storage.objectViewer"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I couldn't find a non legacy role that gives a principle the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is probably fine. If we want to switch to non-legacy roles, it looks like we could give |
||
|
||
bucket = google_storage_bucket.pudl_usage_metrics_archive_bucket.name | ||
role = each.key | ||
member = "serviceAccount:pudl-usage-metrics-etl@catalyst-cooperative-pudl.iam.gserviceaccount.com" | ||
} | ||
|
||
resource "google_storage_bucket_iam_member" "usage_metrics_etl_s3_logs_gcs_iam" { | ||
for_each = toset(["roles/storage.legacyBucketReader", "roles/storage.objectViewer"]) | ||
|
||
bucket = "pudl-s3-logs.catalyst.coop" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we manage this bucket via TF too? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably! How can we manage a resource in terraform that has already been created in the UI? Also, we should probably move the contents of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here's the documentation about handling "resource drift"! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need 4 different name components on that bucket? Is there a non-archives bucket that we need to differentiate it from? Do we foresee having non-PUDL usage metrics that would need to be stored somewhere else? Or could we put all usage metrics data under There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we probably don't need the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bendnorman Would love to coordinate a name change with the flight of PRs in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we'll keep it as is for now but I created an issue to rename it down the line. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also created an issue for moving the |
||
role = each.key | ||
member = "serviceAccount:pudl-usage-metrics-etl@catalyst-cooperative-pudl.iam.gserviceaccount.com" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured I'd save the connection string in case we need to reconnect the db to superset.