Track new linode instance in terraform

The definition is pretty verbose. Apparently it does that if you create it through the UI
This commit is contained in:
Jake Howard 2020-12-05 13:25:50 +00:00
parent 6d75272d34
commit 48e23e8c00
Signed by: jake
GPG key ID: 57AFB45680EDD477
6 changed files with 50 additions and 2 deletions

1
.gitignore vendored
View file

@ -152,3 +152,4 @@ override.tf.json
terraform/secrets.auto.tfvars terraform/secrets.auto.tfvars
terraform/secrets.sh terraform/secrets.sh
terraform/.terraform.lock.hcl

View file

@ -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 {}
}

View file

@ -12,3 +12,7 @@ provider "cloudflare" {
provider "aws" { provider "aws" {
region = "eu-west-2" region = "eu-west-2"
} }
provider "linode" {
token = var.linode_api_token
}

View file

@ -12,5 +12,9 @@ terraform {
source = "hashicorp/aws" source = "hashicorp/aws"
version = "3.8.0" version = "3.8.0"
} }
linode = {
source = "linode/linode"
version = "1.13.4"
}
} }
} }

View file

@ -136,7 +136,7 @@ resource "cloudflare_record" "theorangeonenet_upload" {
resource "cloudflare_record" "theorangeonenet_plausible" { resource "cloudflare_record" "theorangeonenet_plausible" {
zone_id = cloudflare_zone.theorangeonenet.id zone_id = cloudflare_zone.theorangeonenet.id
name = "plausible" name = "plausible"
value = vultr_server.casey.main_ip value = linode_instance.grimes.ip_address
type = "A" type = "A"
ttl = 1 ttl = 1
} }
@ -144,7 +144,7 @@ resource "cloudflare_record" "theorangeonenet_plausible" {
resource "cloudflare_record" "theorangeonenet_plausible_bare" { resource "cloudflare_record" "theorangeonenet_plausible_bare" {
zone_id = cloudflare_zone.theorangeonenet.id zone_id = cloudflare_zone.theorangeonenet.id
name = "elbisualp" name = "elbisualp"
value = vultr_server.casey.main_ip value = linode_instance.grimes.ip_address
type = "A" type = "A"
ttl = 1 ttl = 1
} }

View file

@ -1,5 +1,6 @@
variable "vultr_api_key" {} variable "vultr_api_key" {}
variable "cloudflare_api_key" {} variable "cloudflare_api_key" {}
variable "linode_api_token" {}
variable "walker_ip" { variable "walker_ip" {
default = "5.39.79.153" default = "5.39.79.153"