Skip to content

Instantly share code, notes, and snippets.

@Bharathkumarraju
Forked from canatella/main.tf
Created September 9, 2022 23:38
Show Gist options
  • Save Bharathkumarraju/4ea676924dc91f81fdd67fa3d65d995c to your computer and use it in GitHub Desktop.
Save Bharathkumarraju/4ea676924dc91f81fdd67fa3d65d995c 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