Added module dns_resources. Using it into geonetwork project

This commit is contained in:
Francesco Mangiacrapa 2024-01-16 11:03:06 +01:00
parent 0da976e4c1
commit c9a0c6d6b2
5 changed files with 109 additions and 33 deletions

View File

@ -184,3 +184,26 @@ module "instance_with_data_volume" {
}
}
}
locals {
cname_target = "main-lb.${data.terraform_remote_state.privnet_dns_router.outputs.dns_zone.zone_name}"
}
#
# Add DNS record/s
#
module "dns_records_create" {
source = "../../modules/dns_resources"
dns_resources_map = {
geonetwork-globalfisheriesatlas = {
zone_id = data.terraform_remote_state.privnet_dns_router.outputs.dns_zone_id
name = join(".", ["geonetwork-globalfisheriesatlas", data.terraform_remote_state.privnet_dns_router.outputs.dns_zone.zone_name])
description = "Geonetwork geonetwork-globalfisheriesatlas"
ttl = 8600
type = "CNAME"
records = [local.cname_target]
}
}
}

View File

@ -0,0 +1,15 @@
# Module used
module "ssh_settings" {
source = "../../modules/ssh-key-ref"
}
resource "openstack_dns_recordset_v2" "add_dns_recordset" {
for_each = var.dns_resources_map
zone_id = each.value.zone_id
name = each.value.name
description = each.value.description
ttl = each.value.ttl
type = each.value.type
records = each.value.records
}

View File

@ -0,0 +1,4 @@
output "dns_resources_map" {
value = var.dns_resources_map
}

View File

@ -0,0 +1,11 @@
# Define required providers
terraform {
required_version = ">= 0.14.0"
required_providers {
openstack = {
source = "terraform-provider-openstack/openstack"
version = "~> 1.53.0"
}
}
}

View File

@ -0,0 +1,23 @@
#Default DNS resource is EMPTY. Override it to create a proper plan
variable "dns_resources_map" {
type = map(object({
zone_id = string
name = string
description = string
ttl = number
type = string
records = list(string)
}))
default = {
dns_record = {
zone_id = ""
name = "",
description = "",
ttl = 8600,
type = "CNAME",
records = []
}
}
}