Created
December 12, 2022 22:28
-
-
Save Azuka/c1d543569f3c6f594ae9ebcf2bd93bb4 to your computer and use it in GitHub Desktop.
Terraform: setup service account for firebase hosting deploy
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
resource "github_actions_secret" "ci" { | |
repository = "your/repository" | |
secret_name = "FIREBASE_SERVICE_ACCOUNT_${SUFFIX}" | |
plaintext_value = base64decode(google_service_account_key.ci.private_key) | |
} |
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
data "google_project" "default" { | |
provider = google-beta | |
} | |
resource "google_service_account" "ci" { | |
account_id = "deployer" | |
display_name = "Deployer Service Account for CI" | |
} | |
resource "google_service_account_key" "ci" { | |
service_account_id = google_service_account.ci.id | |
} | |
resource "google_project_iam_member" "ci" { | |
project = data.google_project.default.id | |
for_each = toset([ | |
"serviceusage.apiKeysViewer", // API Keys Viewer | |
"run.viewer", // Cloud run viewer | |
"firebaseauth.admin", // Firebase auth admin | |
"firebasehosting.admin", // Firebase hosting admin | |
]) | |
role = "roles/${each.key}" | |
member = "serviceAccount:${google_service_account.ci.email}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment