cloudflare dns
This commit is contained in:
parent
bad78681c6
commit
fe38bebbd5
3
.gitignore
vendored
3
.gitignore
vendored
@ -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
|
||||
|
42
terraform/cloudflare/main.tf
Normal file
42
terraform/cloudflare/main.tf
Normal 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"
|
||||
}
|
3
terraform/cloudflare/secrets.auto.example
Normal file
3
terraform/cloudflare/secrets.auto.example
Normal file
@ -0,0 +1,3 @@
|
||||
# Rename this file to "secrets.auto.tfvars"
|
||||
|
||||
api_token = "CHANGE ME"
|
21
terraform/cloudflare/variable_definitions.tf
Normal file
21
terraform/cloudflare/variable_definitions.tf
Normal 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 = []
|
||||
}
|
6
terraform/cloudflare/variables.auto.tfvars
Normal file
6
terraform/cloudflare/variables.auto.tfvars
Normal file
@ -0,0 +1,6 @@
|
||||
account_name = "balsillie"
|
||||
|
||||
a_records = [
|
||||
{name = "@", content = ""},
|
||||
{name = "www", content = ""}
|
||||
]
|
Loading…
Reference in New Issue
Block a user