1
0

cloudflare dns

This commit is contained in:
michael 2024-10-23 00:22:32 -04:00
parent bad78681c6
commit fe38bebbd5
5 changed files with 75 additions and 0 deletions

3
.gitignore vendored
View File

@ -11,6 +11,9 @@ ansible/collections/**
# Terraform lock file
**/.terraform.lock.hcl
# Terraform secrets file
**/secrets.auto.tfvars
# Crash log files
crash.log
crash.*.log

View File

@ -0,0 +1,42 @@
# terraform file to create dns resource in cloudflare
terraform {
required_version = ">= 1.8.0"
required_providers {
cloudflare = {
source = "cloudflare/cloudflare"
version = "~> 4.44"
}
}
backend "local" {
path = "/home/michael/Nextcloud/Backups/tfstate/cloudflare.tfstate"
}
}
provider "cloudflare" {
api_token = var.api_token
}
data "cloudflare_accounts" "default" {
name = var.account_name
}
resource "cloudflare_zone" "balsillie_net" {
account_id = data.cloudflare_accounts.default[0].id
zone = "balsillie.net"
paused = false
plan = "free"
type = "full"
}
resource "cloudflare_dns_zone_dnssec" "balsillie_net" {
zone_id = cloudflare_zone.balsillie_net.id
}
resource "cloudflare_dns_record" "example_record" {
zone_id = cloudflare_zone.balsillie_net.id
proxied = false
type = "A"
ttl = 60
name = "@"
content = "5.161.254.39"
}

View File

@ -0,0 +1,3 @@
# Rename this file to "secrets.auto.tfvars"
api_token = "CHANGE ME"

View File

@ -0,0 +1,21 @@
variable "api_token" {
description = "Cloudflare account API token"
type = string
default = ""
sensitive = true
}
variable "account_name" {
description = "Cloudflare account name"
type = string
default = ""
}
variable "a_records" {
description = "DNS A records to create"
type = list(object({
name = string
content = string
}))
default = []
}

View File

@ -0,0 +1,6 @@
account_name = "balsillie"
a_records = [
{name = "@", content = ""},
{name = "www", content = ""}
]