Skip to content

Commit

Permalink
Fix: always specify Terraform project (#384)
Browse files Browse the repository at this point in the history
* fix: always specify project
* fix: use supplied project ID explicitly

---------

Co-authored-by: henrybell <henrybell@users.noreply.github.com>
  • Loading branch information
alexlo03 and henrybell authored Oct 10, 2024
1 parent e1a0011 commit de5adb0
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
5 changes: 4 additions & 1 deletion terraform/modules/autoscaler-base/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ resource "google_project_iam_member" "poller_sa_spanner" {
// Downstream topic

resource "google_pubsub_topic" "downstream_topic" {
name = "downstream-topic"
project = var.project_id
name = "downstream-topic"

depends_on = [google_pubsub_schema.scaler_downstream_pubsub_schema]

Expand All @@ -46,6 +47,7 @@ resource "google_pubsub_topic_iam_member" "scaler_downstream_pub_iam" {
}

resource "google_pubsub_schema" "scaler_downstream_pubsub_schema" {
project = var.project_id
name = "downstream-schema"
type = "PROTOCOL_BUFFER"
definition = file("${path.module}/../../../src/scaler/scaler-core/downstream.schema.proto")
Expand All @@ -64,6 +66,7 @@ resource "google_project_iam_member" "metrics_publisher_iam_scaler" {
}

resource "google_service_account" "build_sa" {
project = var.project_id
account_id = "build-sa"
display_name = "Autoscaler - Cloud Build Builder Service Account"
}
Expand Down
5 changes: 5 additions & 0 deletions terraform/modules/autoscaler-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,27 @@ resource "google_project_iam_member" "cluster_iam_artifactregistryreader" {
// Other resources

resource "google_compute_network" "network" {
project = var.project_id
name = "spanner-autoscaler-network"
auto_create_subnetworks = false
}

resource "google_compute_subnetwork" "subnetwork" {
project = var.project_id
name = "spanner-autoscaler-subnetwork"
network = google_compute_network.network.id
ip_cidr_range = "10.0.0.0/16"
private_ip_google_access = true
}

resource "google_compute_router" "router" {
project = var.project_id
name = "app-router"
network = google_compute_network.network.id
}

resource "google_compute_router_nat" "nat" {
project = var.project_id
name = "autoscaler-nat"
router = google_compute_router.router.name
region = google_compute_router.router.region
Expand All @@ -110,6 +114,7 @@ resource "google_compute_router_nat" "nat" {
}

resource "google_artifact_registry_repository" "autoscaler_artifact_repo" {
project = var.project_id
location = var.region
repository_id = "spanner-autoscaler"
description = "Image registry for Spanner Autoscaler"
Expand Down
7 changes: 5 additions & 2 deletions terraform/modules/autoscaler-functions/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ terraform {
// PubSub

resource "google_pubsub_topic" "poller_topic" {
name = "poller-topic"
project = var.project_id
name = "poller-topic"
}

resource "google_pubsub_topic_iam_member" "poller_pubsub_sub_iam" {
Expand All @@ -43,7 +44,8 @@ resource "google_pubsub_topic_iam_member" "forwarder_pubsub_pub_iam" {
}

resource "google_pubsub_topic" "scaler_topic" {
name = "scaler-topic"
project = var.project_id
name = "scaler-topic"
}

resource "google_pubsub_topic_iam_member" "poller_pubsub_pub_iam" {
Expand All @@ -63,6 +65,7 @@ resource "google_pubsub_topic_iam_member" "scaler_pubsub_sub_iam" {
// Cloud Functions

resource "google_storage_bucket" "bucket_gcf_source" {
project = var.project_id
name = "${var.project_id}-gcf-source"
storage_class = "REGIONAL"
location = var.region
Expand Down
6 changes: 5 additions & 1 deletion terraform/modules/forwarder/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
// Service Accounts

resource "google_service_account" "build_sa" {
project = var.project_id
account_id = "build-sa"
display_name = "Autoscaler - Cloud Build Builder Service Account"
}
Expand All @@ -39,14 +40,16 @@ resource "time_sleep" "wait_for_iam" {
}

resource "google_service_account" "forwarder_sa" {
project = var.project_id
account_id = "forwarder-sa"
display_name = "Autoscaler - PubSub Forwarder Service Account"
}

// PubSub

resource "google_pubsub_topic" "forwarder_topic" {
name = "forwarder-topic"
project = var.project_id
name = "forwarder-topic"
}

resource "google_pubsub_topic_iam_member" "forwader_pubsub_sub_binding" {
Expand All @@ -59,6 +62,7 @@ resource "google_pubsub_topic_iam_member" "forwader_pubsub_sub_binding" {
// Cloud Functions

resource "google_storage_bucket" "bucket_gcf_source" {
project = var.project_id
name = "${var.project_id}-gcf-source"
storage_class = "REGIONAL"
location = var.region
Expand Down
1 change: 1 addition & 0 deletions terraform/modules/scheduler/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ resource "google_app_engine_application" "app" {
}

resource "google_cloud_scheduler_job" "poller_job" {
project = var.project_id
name = "poll-main-instance-metrics"
description = "Poll metrics for main-instance"
schedule = var.schedule
Expand Down

0 comments on commit de5adb0

Please sign in to comment.