move to vpc
This commit is contained in:
parent
8e45bd11bb
commit
010acc6d85
|
@ -32,6 +32,22 @@ resource "google_project_service" "artifact_api" {
|
|||
disable_on_destroy = true
|
||||
}
|
||||
|
||||
resource "google_project_service" "serverless_vpc_api" {
|
||||
service = "vpcaccess.googleapis.com"
|
||||
|
||||
disable_on_destroy = true
|
||||
}
|
||||
|
||||
resource "google_vpc_access_connector" "vpc_connector" {
|
||||
name = "capstone-connector"
|
||||
subnet {
|
||||
name = "cloud-run-capstone"
|
||||
}
|
||||
region = var.project_region
|
||||
machine_type = "f1-micro"
|
||||
min_instances = 2
|
||||
max_instances = 3
|
||||
}
|
||||
|
||||
resource "google_artifact_registry_repository" "capstone_repo" {
|
||||
location = var.project_region
|
||||
|
@ -46,55 +62,52 @@ resource "google_artifact_registry_repository" "capstone_repo" {
|
|||
depends_on = [ google_project_service.artifact_api ]
|
||||
}
|
||||
|
||||
resource "google_cloud_run_service" "webhook_service_cr" {
|
||||
resource "google_cloud_run_v2_service" "webhook_service_cr" {
|
||||
name = "webhook-service-cr"
|
||||
location = var.project_region
|
||||
|
||||
template {
|
||||
spec {
|
||||
containers {
|
||||
image = "${var.project_region}-docker.pkg.dev/${var.project_id}/${google_artifact_registry_repository.capstone_repo.name}/webhook-service:latest"
|
||||
}
|
||||
}
|
||||
vpc_access {
|
||||
connector = google_vpc_access_connector.vpc_connector.id
|
||||
egress = "ALL_TRAFFIC"
|
||||
}
|
||||
}
|
||||
|
||||
traffic {
|
||||
percent = 100
|
||||
latest_revision = true
|
||||
}
|
||||
|
||||
depends_on = [ google_project_service.run_api, google_artifact_registry_repository.capstone_repo ]
|
||||
depends_on = [ google_project_service.run_api, google_artifact_registry_repository.capstone_repo, google_vpc_access_connector.vpc_connector ]
|
||||
}
|
||||
|
||||
resource "google_cloud_run_service_iam_member" "webhook_service_run_all_users" {
|
||||
service = google_cloud_run_service.webhook_service_cr.name
|
||||
|
||||
resource "google_cloud_run_v2_service_iam_member" "webhook_service_run_all_users" {
|
||||
project = var.project_id
|
||||
name = google_cloud_run_v2_service.webhook_service_cr.name
|
||||
location = var.project_region
|
||||
role = "roles/run.invoker"
|
||||
member = "allUsers"
|
||||
}
|
||||
|
||||
resource "google_cloud_run_service" "frontend_service_cr" {
|
||||
resource "google_cloud_run_v2_service" "frontend_service_cr" {
|
||||
name = "frontend-service-cr"
|
||||
location = var.project_region
|
||||
|
||||
template {
|
||||
spec {
|
||||
containers {
|
||||
image = "${var.project_region}-docker.pkg.dev/${var.project_id}/${google_artifact_registry_repository.capstone_repo.name}/frontend-service:latest"
|
||||
}
|
||||
containers {
|
||||
image = "${var.project_region}-docker.pkg.dev/${var.project_id}/${google_artifact_registry_repository.capstone_repo.name}/frontend-service:latest"
|
||||
}
|
||||
vpc_access {
|
||||
connector = google_vpc_access_connector.vpc_connector.id
|
||||
egress = "ALL_TRAFFIC"
|
||||
}
|
||||
}
|
||||
|
||||
traffic {
|
||||
percent = 100
|
||||
latest_revision = true
|
||||
}
|
||||
|
||||
depends_on = [ google_project_service.run_api, google_artifact_registry_repository.capstone_repo ]
|
||||
depends_on = [ google_project_service.run_api, google_artifact_registry_repository.capstone_repo, google_vpc_access_connector.vpc_connector ]
|
||||
}
|
||||
|
||||
resource "google_cloud_run_service_iam_member" "frontend_service_run_all_users" {
|
||||
service = google_cloud_run_service.frontend_service_cr.name
|
||||
|
||||
resource "google_cloud_run_v2_service_iam_member" "frontend_service_run_all_users" {
|
||||
project = var.project_id
|
||||
name = google_cloud_run_v2_service.frontend_service_cr.name
|
||||
location = var.project_region
|
||||
role = "roles/run.invoker"
|
||||
member = "allUsers"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
BASE_URL="us-south1-docker.pkg.dev/pbaxter-infra/capstone-repo"
|
||||
BASE_URL="us-central1-docker.pkg.dev/pbaxter-infra/capstone-repo"
|
||||
|
||||
|
||||
build:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
BASE_URL="us-south1-docker.pkg.dev/pbaxter-infra/capstone-repo"
|
||||
BASE_URL="us-central1-docker.pkg.dev/pbaxter-infra/capstone-repo"
|
||||
|
||||
|
||||
build:
|
||||
|
|
Loading…
Reference in New Issue