Skip to content

Commit

Permalink
Merge pull request #13 from remerge/add-redis-auth-secret
Browse files Browse the repository at this point in the history
Add Redis auth string as Google Cloud Secret
  • Loading branch information
hollow committed Aug 14, 2023
2 parents e1b641d + 6ae6930 commit e0818ae
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions google/redis/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,25 @@ module "netbox-vm" {
interface = "internal"
ip_address = google_redis_instance.main.host
}

resource "google_secret_manager_secret" "auth" {
secret_id = "redis-auth-${var.name}"
replication {
automatic = true
}
}

resource "google_secret_manager_secret_version" "auth" {
secret = google_secret_manager_secret.auth.name
secret_data = google_redis_instance.main.auth_string
}

resource "google_secret_manager_secret_iam_member" "auth" {
secret_id = google_secret_manager_secret.auth.id
role = "roles/secretmanager.secretAccessor"
member = "serviceAccount:${data.google_compute_default_service_account.default.email}"
}

data "google_compute_default_service_account" "default" {
project = var.project
}

0 comments on commit e0818ae

Please sign in to comment.