♻️ move terraform code start adding dns

This commit is contained in:
James Walker 2024-10-17 11:24:13 -04:00
parent 73a52e35d0
commit ea5496e870
Signed by: walkah
SSH Key Fingerprint: SHA256:f7Gn4jO4BFHZxWfKTTzEAfWz+cLW51IyGFl9MjDyZGI
9 changed files with 70 additions and 47 deletions

6
flake.lock generated
View File

@ -137,11 +137,11 @@
]
},
"locked": {
"lastModified": 1729027341,
"narHash": "sha256-IqWD7bA9iJVifvJlB4vs2KUXVhN+d9lECWdNB4jJ0tE=",
"lastModified": 1729171802,
"narHash": "sha256-Eip3uI+XeyAfBoQXpkm/F7eG3M7AgvzSyhyJdzxVt74=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "2a4fd1cfd8ed5648583dadef86966a8231024221",
"rev": "9c1a1c7df49a9b28539ccb509b36d0b81e41391c",
"type": "github"
},
"original": {

17
main.tf
View File

@ -1,17 +0,0 @@
terraform {
required_version = ">= 1.8.0"
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
version = "~> 2.0"
}
}
}
variable "do_token" {}
module "digitalocean" {
source = "./terraform/digitalocean"
do_token = var.do_token
}

View File

@ -1,6 +1,29 @@
# This file is maintained automatically by "tofu init".
# Manual edits may be lost in future updates.
provider "registry.opentofu.org/cloudflare/cloudflare" {
version = "4.44.0"
constraints = "~> 4.0"
hashes = [
"h1:cRV923M29H/H3NfvlVGsGkvyn8P7ovsMU5BNb9U1d+o=",
"zh:0cae95e8c9d2d979669712745251dcf5720cee2a59bb81d8ad2c2dcf0e6e0c7a",
"zh:1220aee9549e7938648f6a36237929ead0de8244c6a00f8e8cded559f4b65a2f",
"zh:23ae1862e5fe5b583b8ec2c96f80a5ba0e3883be8e1169a0484a45106cc238ce",
"zh:3034654c6f34e419c53dcd6ea558b715e1150fbcc70c93209c5ee88a03025072",
"zh:3b64a66f3ddeb04345511262ad9376eb3c26e0683a78f47a3fd7f5e71f3f7e27",
"zh:4b29435e1e8f970b92bb38eca52820f7a8362c16235334aef9a83be32bd00094",
"zh:4f8fe69db7f54bce0e78a4c671aa5db20515114626035051f387d9833f4a5a91",
"zh:86776bfbdabd2095975be9b3ca999c2f47ca5194ece6c58c69130ccfa2e3c97d",
"zh:890df766e9b839623b1f0437355032a3c006226a6c200cd911e15ee1a9014e9f",
"zh:9d50271a09ee01a7105c06e582c52743a3baaf46f298d52bfc9e64cd7bfaa712",
"zh:a1e12d1c3472d457140de0e8b77a4b09e5cdcd3e2f6c0be0fe0dae0526d368db",
"zh:ad638e2c91490367d55ec6fe46ee34a9f7c151ca6e3cc52e5bad9f358e77f1aa",
"zh:cc4c496f2c594994a9d966f7ebe00a797eca9b924ac1bbe5aef26ec83ec7f833",
"zh:e74d5a3695deb38c2858d1c99c424495900e9b298ca8961c0a2fc1b3714c4c77",
"zh:f4b6efa4c2b4c85c92171dc0824dbf42af9dde5250131494de803e0b9fe1ea3c",
]
}
provider "registry.opentofu.org/digitalocean/digitalocean" {
version = "2.42.0"
constraints = "~> 2.0"
@ -24,26 +47,3 @@ provider "registry.opentofu.org/digitalocean/digitalocean" {
"zh:d2f2f4a93fbad988d11a1af05c31663b9b340ab5f4c427ecf2d04f2915e6524f",
]
}
provider "registry.opentofu.org/hashicorp/digitalocean" {
version = "2.42.0"
hashes = [
"h1:rDnEHw9yf7NjauDAcFl/8y74sEdgdNIJjaJoQebYbbw=",
"zh:0f223dbe5385d57d09fb28cf03e6d7c6aba2ec0e3fe36ec7277036780bac15fe",
"zh:209506531e478e73fb58afe4252edcfe47f4cf070fb5eb4a932e5a4b056dda3e",
"zh:2e2c80d3683f74c49e9a0003b17687c97315be5e6aaf4653d47e82a38444c48d",
"zh:47eb8bdb25a7ed1083912c3a28fe9a99ce28bb10778b6b55e041dccd3d4e060a",
"zh:51e16b659d08b9fd15874c3c37538acfa8cbb4bfd3df764225cfda80bb1bb627",
"zh:555ad2e67deaecce3ec391e7e9e3a2863ec2883e52d5dec1a3ad4372c503f683",
"zh:91c98f4bf25eb04d4b2f26bf5324f90e54fde23cf3ac8e12677ec2e33fc0792c",
"zh:91eb29db6d11f5d4d60399dc2fcc91bcc23650cb5bdc40b6ca2b500acb5ba930",
"zh:969948dc93376535dde32288fa52150dcfdfc898c41929504f5f2d040a27427d",
"zh:9c0fe37850204ec93391e0b609e68b6a2fb06d0a4587550b866ff703e15637ed",
"zh:a33102d7bbe29894c75c3ba44d0952c975e278ba81c492bb956e1ee05be17c2f",
"zh:aae1061f9d62fc943bbe5abd7e0c91bee4e444c7113e24ac2d0706e0a4faee31",
"zh:b239c7d1848b36a2b055a527966a3aec180284346cbf2e9e2d7ed9e82e49b09e",
"zh:b64b9b31d034d9bc9b024ee874405e5ce23d751f539f7963ac05787066eb56ee",
"zh:b7a01f8914d574b6732ae11d48fc841207657647fa1b7f4c55854763e31a0f1f",
"zh:d2f2f4a93fbad988d11a1af05c31663b9b340ab5f4c427ecf2d04f2915e6524f",
]
}

View File

@ -0,0 +1,17 @@
locals {
account_id = "273a4698f673c012fd50161e46ceafdb"
}
resource "cloudflare_zone" "walkah_codes" {
account_id = local.account_id
zone = "walkah.codes"
}
resource "cloudflare_record" "walkah_codes" {
zone_id = cloudflare_zone.walkah_codes.id
name = "walkah.codes"
type = "A"
proxied = true
content = digitalocean_droplet.socrates.ipv4_address
}

View File

@ -1,4 +0,0 @@
variable "do_token" {}
provider "digitalocean" {
token = var.do_token
}

21
terraform/main.tf Normal file
View File

@ -0,0 +1,21 @@
terraform {
required_version = ">= 1.8.0"
required_providers {
cloudflare = {
source = "cloudflare/cloudflare"
version = "~> 4.0"
}
digitalocean = {
source = "digitalocean/digitalocean"
version = "~> 2.0"
}
}
}
provider "cloudflare" {
api_token = var.cloudflare_token
}
provider "digitalocean" {
token = var.do_token
}

6
terraform/variables.tf Normal file
View File

@ -0,0 +1,6 @@
variable "cloudflare_token" {
type = string
}
variable "do_token" {
type = string
}