Created
September 5, 2022 07:52
-
-
Save canatella/121eab76622679b477bfdb0e19fd99b2 to your computer and use it in GitHub Desktop.
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
variable "firebase_admin_token" { | |
description = "The token to use to deploy firebase resources." | |
type = string | |
} | |
variable "project" { | |
description = "The project id to create the app for." | |
type = string | |
} | |
variable "platform" { | |
description = "The platform to create the app for, android or ios." | |
type = string | |
validation { | |
condition = var.platform == "android" || var.platform == "ios" || var.platform == "desktop" | |
error_message = "The platform value must be one of android, ios, desktop." | |
} | |
} | |
variable "name" { | |
description = "The application name." | |
type = string | |
} | |
variable "bundle" { | |
description = "The application bundle id for iOS or the package name for Android." | |
type = string | |
} | |
locals { | |
options = "--token ${var.firebase_admin_token} --project ${var.project} --non-interactive" | |
platform_options = { | |
ios = "ios '${var.name}' --bundle-id '${var.bundle}'" | |
android = "android '${var.name}' --package-name '${var.bundle}'" | |
desktop = "android '${var.name}' --package-name '${var.bundle}'" | |
} | |
} | |
resource "null_resource" "firebase_app" { | |
provisioner "local-exec" { | |
command = "firebase ${local.options} apps:create ${local.platform_options[var.platform]} || true" | |
working_dir = "${path.root}/.." | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment