diff --git a/terraform/platform/main.tf b/terraform/platform/main.tf new file mode 100644 index 0000000..de2925e --- /dev/null +++ b/terraform/platform/main.tf @@ -0,0 +1,27 @@ +provider "local" { + version = "~> 1.4" +} + +provider "null" { + version = "~> 2.1" +} + +locals { + filename = pathexpand("/tmp/convox.platform") +} + +resource "null_resource" "platform" { + triggers = { + hash = fileexists(local.filename) ? filebase64(local.filename) : "none" + } + + provisioner "local-exec" { + command = "mkdir -p ${dirname(local.filename)} && uname -s > ${local.filename}" + } +} + +data "local_file" "platform" { + depends_on = [null_resource.platform] + + filename = local.filename +} diff --git a/terraform/platform/outputs.tf b/terraform/platform/outputs.tf new file mode 100644 index 0000000..c88303f --- /dev/null +++ b/terraform/platform/outputs.tf @@ -0,0 +1,3 @@ +output "name" { + value = data.local_file.platform.content +} diff --git a/terraform/system/local/main.tf b/terraform/system/local/main.tf index a6e81a7..ba9cbc0 100644 --- a/terraform/system/local/main.tf +++ b/terraform/system/local/main.tf @@ -10,10 +10,6 @@ provider "kubernetes" { version = "~> 1.10" } -locals { - platform_filename = "/tmp/convox.platform" -} - data "http" "releases" { url = "https://api.github.com/repos/convox/convox/releases" } @@ -23,16 +19,8 @@ locals { release = coalesce(var.release, local.current) } -resource "null_resource" "platform" { - provisioner "local-exec" { - command = "uname -s > ${local.platform_filename}" - } -} - -data "local_file" "platform" { - depends_on = [null_resource.platform] - - filename = local.platform_filename +module "platform" { + source = "../../platform" } module "rack" { @@ -43,6 +31,6 @@ module "rack" { } name = var.name - platform = trimspace(data.local_file.platform.content) + platform = module.platform.name release = local.release }