From 0ec17ed5853361d1124b61c12b1f92e8ea8fde3d Mon Sep 17 00:00:00 2001 From: Marius Pana Date: Tue, 1 Mar 2022 12:58:33 +0200 Subject: [PATCH] update examples --- README | 3 +++ triton/main.tf.tpl | 46 +++++++++++++++++++++++++++++++++++++++++ triton/variables.tf.tpl | 11 ++++++++++ 3 files changed, 60 insertions(+) create mode 100644 triton/main.tf.tpl create mode 100644 triton/variables.tf.tpl diff --git a/README b/README index db8be9a..845d121 100644 --- a/README +++ b/README @@ -1 +1,4 @@ # coming soon +Terraform templates and examples for use with spearhead.coud or other triton providers. + +In the root directory you will find some templates to help get you started. diff --git a/triton/main.tf.tpl b/triton/main.tf.tpl new file mode 100644 index 0000000..8235860 --- /dev/null +++ b/triton/main.tf.tpl @@ -0,0 +1,46 @@ +terraform { + required_providers { + triton = { + source = "joyent/triton" + version = "0.8.2" + } + } +} + +provider "triton" { + account = "username" + key_id = "key:id" + url = "https://eu-ro-1.api.spearhead.cloud" + key_material = "/path/to/id_rsa" + insecure_skip_tls_verify = false +} + +resource "triton_machine" "internal_resource_name" { + count = var.instance_count + name = "linux-${count.index + 1}" + package = "standard-2cpu-4ram-100disk" + image = "b70d5484-5168-4ecb-8127-0a0c59c1d906" + + provisioner "file" { + source = "scripts/setup.sh" + destination = "/var/tmp/setup.sh" + } + + provisioner "remote-exec" { + inline = [ + "bash /var/tmp/setup.sh", + ] + } + + connection { + type = "ssh" + host = self.primaryip + user = "ubuntu" + } + + cns { + services = ["${var.service_name}"] + } + +} + diff --git a/triton/variables.tf.tpl b/triton/variables.tf.tpl new file mode 100644 index 0000000..36ca005 --- /dev/null +++ b/triton/variables.tf.tpl @@ -0,0 +1,11 @@ +variable "instance_count" { + description = "Number of triton instances to create" + type = number + default = 8 +} + +variable "service_name" { + type = string + description = "The name of the service in CNS." + default = "somename" +}