Skip to content

Instantly share code, notes, and snippets.

@canatella
Created September 5, 2022 07:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save canatella/121eab76622679b477bfdb0e19fd99b2 to your computer and use it in GitHub Desktop.
Save canatella/121eab76622679b477bfdb0e19fd99b2 to your computer and use it in GitHub Desktop.
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