-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move to secret dumper, cloud run v2 and improve logging init (#302)
* Improve response pattern, runs behind the scenes. * will this work then ? * increase attempt deadline to make sure gh clients are created * Moved to using harpocrates and added loglevel to app config * provider fix * fix resource to v2 * more fix * One step closer to a correct config * Maybe this fixes it :) * string fix * fixes to v2 * explicit tell about google-beta providers * needs more cow bell * docs * a better log check
- Loading branch information
Showing
7 changed files
with
143 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,137 @@ | ||
resource "google_cloud_run_service" "main" { | ||
resource "google_cloud_run_v2_service" "main" { | ||
provider = google-beta | ||
name = var.name | ||
location = var.location | ||
project = var.project_id | ||
metadata { | ||
labels = { | ||
env = var.env | ||
service = var.service | ||
team = var.team | ||
version = replace(var.tag, ".", "_") | ||
} | ||
template { | ||
service_account = "${var.service}-v3@${var.project_id}.iam.gserviceaccount.com" | ||
timeout = "1800s" | ||
max_instance_request_concurrency = var.container_concurrency | ||
labels = { | ||
env = var.env | ||
service = var.service | ||
team = var.team | ||
version = replace(var.tag, ".", "_") | ||
} | ||
} | ||
template { | ||
metadata { | ||
labels = { | ||
env = var.env | ||
service = var.service | ||
team = var.team | ||
version = replace(var.tag, ".", "_") | ||
} | ||
annotations = { | ||
"autoscaling.knative.dev/maxScale" = var.scaling["max"] | ||
"autoscaling.knative.dev/minScale" = var.scaling["min"] | ||
"run.googleapis.com/cloudsql-instances" = var.db_instance | ||
annotations = { | ||
"autoscaling.knative.dev/maxScale" = var.scaling["max"] | ||
"autoscaling.knative.dev/minScale" = var.scaling["min"] | ||
"run.googleapis.com/cloudsql-instances" = var.db_instance | ||
|
||
} | ||
containers { | ||
name = var.name | ||
image = "europe-docker.pkg.dev/artifacts-pub-prod-b57f/public-docker/${var.service}:${var.tag}" | ||
args = var.args | ||
depends_on = ["secret-dumper"] | ||
env { | ||
name = "DEPENDABOT_WORKERURL" | ||
value = var.worker_url | ||
} | ||
env { | ||
name = "DEPENDABOT_CONFIG" | ||
value = "/secrets/app-secrets" | ||
} | ||
env { | ||
name = "DEPENDABOT_DBCONFIG" | ||
value = "/secrets/db-secrets" | ||
} | ||
ports { | ||
name = "http1" | ||
container_port = 3000 | ||
} | ||
volume_mounts { | ||
name = "secrets" | ||
mount_path = "/secrets" | ||
} | ||
} | ||
spec { | ||
containers { | ||
image = "europe-docker.pkg.dev/artifacts-pub-prod-b57f/public-docker/${var.service}:${var.tag}" | ||
args = var.args | ||
env { | ||
name = "DEPENDABOT_WORKERURL" | ||
value = var.worker_url | ||
} | ||
env { | ||
name = "VAULT_ADDR" | ||
value = "https://vault.bestsellerit.com" | ||
} | ||
env { | ||
name = "VAULT_ROLE" | ||
value = "dependabot-circleci-v3" | ||
} | ||
env { | ||
name = "APP_SECRET" | ||
value = "ES/data/${var.service}/prod" | ||
} | ||
env { | ||
name = "DB_SECRET" | ||
value = "ES/data/${var.service}/db" | ||
} | ||
ports { | ||
name = "http1" | ||
container_port = 3000 | ||
containers { | ||
name = "secret-dumper" | ||
image = "europe-docker.pkg.dev/artifacts-pub-prod-b57f/public-docker/harpocrates:2.4.0" | ||
args = [ | ||
jsonencode({ | ||
"format" : "json", | ||
"output" : "/secrets", | ||
"secrets" : [ | ||
{ | ||
"ES/data/${var.service}/prod" : { | ||
"filename" : "app-secrets" | ||
} | ||
}, | ||
{ | ||
"ES/data/${var.service}/db" : { | ||
"filename" : "db-secrets" | ||
} | ||
} | ||
] | ||
}) | ||
] | ||
env { | ||
name = "VAULT_ADDR" | ||
value = "https://vault.bestsellerit.com" | ||
} | ||
env { | ||
name = "AUTH_NAME" | ||
value = "dependabot-circleci-v3" | ||
} | ||
env { | ||
name = "ROLE_NAME" | ||
value = "dependabot-circleci-v3" | ||
} | ||
env { | ||
name = "GCP_WORKLOAD_ID" | ||
value = "true" | ||
} | ||
env { | ||
name = "CONTINUOUS" | ||
value = "true" | ||
} | ||
env { | ||
name = "INTERVAL" | ||
value = "60s" | ||
} | ||
env { | ||
name = "LOG_LEVEL" | ||
value = "warn" | ||
} | ||
ports { | ||
name = "http1" | ||
container_port = 8080 | ||
} | ||
volume_mounts { | ||
name = "secrets" | ||
mount_path = "/secrets" | ||
} | ||
startup_probe { | ||
http_get { | ||
path = "/status" | ||
port = 8000 | ||
} | ||
initial_delay_seconds = 2 | ||
} | ||
service_account_name = "${var.service}-v3@${var.project_id}.iam.gserviceaccount.com" | ||
timeout_seconds = 1800 | ||
container_concurrency = var.container_concurrency | ||
} | ||
volumes { | ||
name = "secrets" | ||
empty_dir {} | ||
} | ||
} | ||
|
||
traffic { | ||
percent = 100 | ||
latest_revision = true | ||
percent = 100 | ||
} | ||
} | ||
|
||
resource "google_cloud_run_service_iam_member" "allow_unauthenticated" { | ||
resource "google_cloud_run_v2_service_iam_member" "allow_unauthenticated" { | ||
count = var.allow_unauthenticated ? 1 : 0 | ||
location = google_cloud_run_service.main.location | ||
project = google_cloud_run_service.main.project | ||
service = google_cloud_run_service.main.name | ||
location = google_cloud_run_v2_service.main.location | ||
project = google_cloud_run_v2_service.main.project | ||
name = google_cloud_run_v2_service.main.name | ||
role = "roles/run.invoker" | ||
member = "allUsers" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
output "url" { | ||
value = google_cloud_run_service.main.status.0.url | ||
value = google_cloud_run_v2_service.main.uri | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters