From 48e23e8c00e36515889fc783ac61ff609a60d6ae Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sat, 5 Dec 2020 13:25:50 +0000 Subject: [PATCH] Track new linode instance in terraform The definition is pretty verbose. Apparently it does that if you create it through the UI --- .gitignore | 1 + terraform/grimes_vps.tf | 38 +++++++++++++++++++++++++++++++++++ terraform/providers.tf | 4 ++++ terraform/terraform.tf | 4 ++++ terraform/theorangeone.net.tf | 4 ++-- terraform/variables.tf | 1 + 6 files changed, 50 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 6cceb00..ae81d7b 100644 --- a/.gitignore +++ b/.gitignore @@ -152,3 +152,4 @@ override.tf.json terraform/secrets.auto.tfvars terraform/secrets.sh +terraform/.terraform.lock.hcl diff --git a/terraform/grimes_vps.tf b/terraform/grimes_vps.tf index e69de29..a2e5ca3 100644 --- a/terraform/grimes_vps.tf +++ b/terraform/grimes_vps.tf @@ -0,0 +1,38 @@ +resource "linode_instance" "grimes" { + label = "grimes" + region = "eu-central" + type = "g6-nanode-1" + + private_ip = true + + config { + kernel = "linode/grub2" + label = "My Ubuntu 20.04 LTS Disk Profile" + + devices { + sda { + disk_label = "Ubuntu 20.04 LTS Disk" + } + + sdb { + disk_label = "512 MB Swap Image" + } + } + } + + disk { + filesystem = "ext4" + label = "Ubuntu 20.04 LTS Disk" + read_only = false + size = 25088 + } + disk { + filesystem = "swap" + label = "512 MB Swap Image" + read_only = false + size = 512 + } + + timeouts {} + +} diff --git a/terraform/providers.tf b/terraform/providers.tf index f32ee89..3181671 100644 --- a/terraform/providers.tf +++ b/terraform/providers.tf @@ -12,3 +12,7 @@ provider "cloudflare" { provider "aws" { region = "eu-west-2" } + +provider "linode" { + token = var.linode_api_token +} diff --git a/terraform/terraform.tf b/terraform/terraform.tf index 5ad45a7..4f7aa89 100644 --- a/terraform/terraform.tf +++ b/terraform/terraform.tf @@ -12,5 +12,9 @@ terraform { source = "hashicorp/aws" version = "3.8.0" } + linode = { + source = "linode/linode" + version = "1.13.4" + } } } diff --git a/terraform/theorangeone.net.tf b/terraform/theorangeone.net.tf index 7094391..d2ed904 100644 --- a/terraform/theorangeone.net.tf +++ b/terraform/theorangeone.net.tf @@ -136,7 +136,7 @@ resource "cloudflare_record" "theorangeonenet_upload" { resource "cloudflare_record" "theorangeonenet_plausible" { zone_id = cloudflare_zone.theorangeonenet.id name = "plausible" - value = vultr_server.casey.main_ip + value = linode_instance.grimes.ip_address type = "A" ttl = 1 } @@ -144,7 +144,7 @@ resource "cloudflare_record" "theorangeonenet_plausible" { resource "cloudflare_record" "theorangeonenet_plausible_bare" { zone_id = cloudflare_zone.theorangeonenet.id name = "elbisualp" - value = vultr_server.casey.main_ip + value = linode_instance.grimes.ip_address type = "A" ttl = 1 } diff --git a/terraform/variables.tf b/terraform/variables.tf index cf98340..984cdf9 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -1,5 +1,6 @@ variable "vultr_api_key" {} variable "cloudflare_api_key" {} +variable "linode_api_token" {} variable "walker_ip" { default = "5.39.79.153"