From 1951f4fdf389b31d24e8ffd5324b4d871ec4b9d9 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Tue, 19 Mar 2024 12:03:45 +0100 Subject: [PATCH] Add a CNAME to the prod socialservice. --- .../d4s-production/socialservice/main.tf | 27 +++++++++- .../socialservice/terraform.tfstate | 49 ++++++++++++++++--- 2 files changed, 68 insertions(+), 8 deletions(-) diff --git a/openstack-tf/d4s-production/socialservice/main.tf b/openstack-tf/d4s-production/socialservice/main.tf index d50ce98..fece0b5 100644 --- a/openstack-tf/d4s-production/socialservice/main.tf +++ b/openstack-tf/d4s-production/socialservice/main.tf @@ -40,8 +40,8 @@ module "instance_without_data_volume" { flavor = module.common_variables.flavor_list.m1_medium, networks = [data.terraform_remote_state.privnet_dns_router.outputs.main_private_network.name, module.common_variables.networks_list.cassandra], security_groups = [data.terraform_remote_state.privnet_dns_router.outputs.default_security_group_name, data.terraform_remote_state.privnet_dns_router.outputs.security_group_list.http_and_https_from_the_load_balancers, data.terraform_remote_state.privnet_dns_router.outputs.security_group_list.debugging_from_jump_node], - server_groups_ids = [openstack_compute_servergroup_v2.socialservice_server_group.id], - image_ref = module.common_variables.ubuntu_1804 + server_groups_ids = [openstack_compute_servergroup_v2.socialservice_server_group.id], + image_ref = module.common_variables.ubuntu_1804 }, accounting_service_2 = { name = "socialservice-02", @@ -54,3 +54,26 @@ module "instance_without_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 = { + socialservice_prod = { + zone_id = data.terraform_remote_state.privnet_dns_router.outputs.dns_zone_id + name = join(".", ["socialnetworking", data.terraform_remote_state.privnet_dns_router.outputs.dns_zone.zone_name]) + description = "Social Service public endpoint. For testing purposes" + ttl = 8600 + type = "CNAME" + records = [local.cname_target] + } + } +} + diff --git a/openstack-tf/d4s-production/socialservice/terraform.tfstate b/openstack-tf/d4s-production/socialservice/terraform.tfstate index e75febd..18e46a0 100644 --- a/openstack-tf/d4s-production/socialservice/terraform.tfstate +++ b/openstack-tf/d4s-production/socialservice/terraform.tfstate @@ -1,7 +1,7 @@ { "version": 4, "terraform_version": "1.6.6", - "serial": 4, + "serial": 9, "lineage": "c019bdfb-6443-074d-dcde-d33ae7453cc9", "outputs": {}, "resources": [ @@ -404,7 +404,10 @@ "schema_version": 0, "attributes": { "id": "e90c0bed-7b13-41b7-b9be-b4ab61ca3318", - "members": [], + "members": [ + "a19b4f16-318b-4526-9fc3-85c36f9566da", + "4e155fcc-2e76-45f7-80d3-d6972487278f" + ], "name": "social-service", "policies": [ "anti-affinity" @@ -422,6 +425,40 @@ } ] }, + { + "module": "module.dns_records_create", + "mode": "managed", + "type": "openstack_dns_recordset_v2", + "name": "add_dns_recordset", + "provider": "provider[\"registry.terraform.io/terraform-provider-openstack/openstack\"]", + "instances": [ + { + "index_key": "socialservice_prod", + "schema_version": 0, + "attributes": { + "description": "Social Service public endpoint. For testing purposes", + "disable_status_check": false, + "id": "74135b34-1a9c-4c01-8cf0-22450a5660c4/0575ca2f-088f-491b-91c8-c8f25346b270", + "name": "socialnetworking.cloud.d4science.org.", + "project_id": "1b45adf388934758b56d0dfdb4bfacf3", + "records": [ + "main-lb.cloud.d4science.org." + ], + "region": "isti_area_pi_1", + "timeouts": null, + "ttl": 8600, + "type": "CNAME", + "value_specs": null, + "zone_id": "74135b34-1a9c-4c01-8cf0-22450a5660c4" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6NjAwMDAwMDAwMDAwLCJ1cGRhdGUiOjYwMDAwMDAwMDAwMH19", + "dependencies": [ + "data.terraform_remote_state.privnet_dns_router" + ] + } + ] + }, { "module": "module.instance_without_data_volume", "mode": "managed", @@ -495,7 +532,7 @@ "region": "isti_area_pi_1", "scheduler_hints": [ { - "additional_properties": null, + "additional_properties": {}, "build_near_host_ip": "", "different_cell": [], "different_host": [], @@ -511,7 +548,7 @@ "traffic_from_the_main_load_balancers" ], "stop_before_destroy": false, - "tags": null, + "tags": [], "timeouts": null, "updated": "2024-03-12 10:59:44 +0000 UTC", "user_data": "47d4769e61324c305c4b70ed6673de4fad84150d", @@ -591,7 +628,7 @@ "region": "isti_area_pi_1", "scheduler_hints": [ { - "additional_properties": null, + "additional_properties": {}, "build_near_host_ip": "", "different_cell": [], "different_host": [], @@ -607,7 +644,7 @@ "traffic_from_the_main_load_balancers" ], "stop_before_destroy": false, - "tags": null, + "tags": [], "timeouts": null, "updated": "2024-03-12 10:59:40 +0000 UTC", "user_data": "47d4769e61324c305c4b70ed6673de4fad84150d",