/terraform-digitalocean-dns-records

A module used to update DNS records on digitalocean 💧

Primary LanguagePowerShellMIT LicenseMIT

data "digitalocean_domain" "domain" {
  for_each = { for k, v in var.records : k => v if v.create_domain == false }
  name     = each.value.domain_name
}

resource "digitalocean_domain" "domain" {
  for_each   = { for k, v in var.records : k => v if v.create_domain == true }
  name       = each.value.domain_name
  ip_address = each.value.domain_ip_address
}

resource "digitalocean_record" "records" {
  for_each = { for k, v in var.records : k => v }
  domain   = each.value.create_domain == true ? digitalocean_domain.domain[each.key].id : data.digitalocean_domain.domain[each.key].id
  type     = each.value.record_type
  name     = each.value.record_name
  value    = each.value.record_value
  port     = each.value.port
  priority = each.value.priority
  weight   = each.value.weight
  ttl      = each.value.ttl
  flags    = each.value.flags
  tag      = each.value.tag
}

Requirements

No requirements.

Providers

Name Version
digitalocean n/a

Modules

No modules.

Resources

Name Type
digitalocean_domain.domain resource
digitalocean_record.records resource
digitalocean_domain.domain data source

Inputs

Name Description Type Default Required
records The records to be created for digital ocean
list(object({
create_domain = optional(bool, false)
record_type = string
record_name = string
record_value = string
domain_name = string
domain_ip_address = optional(string)
port = optional(number)
priority = optional(number)
weight = optional(number)
ttl = optional(number)
flags = optional(number)
tag = optional(string)
}))
n/a yes

Outputs

Name Description
domain_id The domain id if created
domain_ttl The domain ttl if created
domain_urn The domain urn if created
record_fqdn FQDN of each record
record_id Id of each record