This is an updated version of the previous [GCP terraform](https://github.com/fleetdm/fleet/tree/main/infrastructure/dogfood/terraform/gcp) with more options and updated usage of modules and Cloud Run (v1 -> v2) which means we were able to ditch the manged VPC connectors (extra cost) and go with the VPC direct access. I think now that I have cloud run jobs figured out we'll be able to add a proper migration addon or module.
33 lines
843 B
Terraform
33 lines
843 B
Terraform
resource "random_pet" "suffix" {
|
|
length = 1
|
|
}
|
|
|
|
resource "random_password" "private_key" {
|
|
length = 32
|
|
}
|
|
|
|
resource "google_secret_manager_secret" "database_password" {
|
|
project = var.project_id
|
|
secret_id = "fleet-db-password-${random_pet.suffix.id}"
|
|
replication {
|
|
auto {}
|
|
}
|
|
}
|
|
|
|
resource "google_secret_manager_secret_version" "database_password" {
|
|
secret = google_secret_manager_secret.database_password.name
|
|
secret_data = module.mysql.generated_user_password
|
|
}
|
|
|
|
resource "google_secret_manager_secret" "private_key" {
|
|
project = var.project_id
|
|
secret_id = "fleet-private-key-${random_pet.suffix.id}"
|
|
replication {
|
|
auto {}
|
|
}
|
|
}
|
|
|
|
resource "google_secret_manager_secret_version" "private_key" {
|
|
secret = google_secret_manager_secret.private_key.name
|
|
secret_data = random_password.private_key.result
|
|
} |