Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use private ip when the public is empty string #268

Merged
merged 12 commits into from
Sep 18, 2023
4 changes: 2 additions & 2 deletions examples/installation/dsf_single_account_deployment/dam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module "agent_gw" {
instance_profile_name = var.agent_gw_instance_profile_name

management_server_host_for_registration = module.mx[0].private_ip
management_server_host_for_api_access = module.mx[0].public_ip
management_server_host_for_api_access = module.mx[0].public_ip == null || module.mx[0].public_ip == "" ? module.mx[0].private_ip : module.mx[0].public_ip
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'module.mx[0].public_ip == ""' - this can't happen since you have disabled this option. Right?

If so, this reduces the readability of this fie. Please remove.

I think it is best to use coalesce function. Please consider -
https://developer.hashicorp.com/terraform/language/functions/coalesce

large_scale_mode = var.large_scale_mode.agent_gw
gateway_group_name = local.gateway_group_name
tags = local.tags
Expand All @@ -72,7 +72,7 @@ module "agent_gw_cluster_setup" {
cluster_name = var.cluster_name != null ? var.cluster_name : join("-", [local.deployment_name_salted, "agent", "gw", "cluster"])
gateway_group_name = local.gateway_group_name
mx_details = {
address = module.mx[0].public_ip
address = module.mx[0].public_ip != null ? module.mx[0].public_ip : module.mx[0].private_ip
port = 8083
user = module.mx[0].web_console_user
password = local.password
Expand Down
4 changes: 2 additions & 2 deletions modules/aws/dam-base-instance/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
locals {
public_ip = var.attach_persistent_public_ip ? aws_eip.dsf_instance_eip[0].public_ip : aws_instance.dsf_base_instance.public_ip
public_dns = var.attach_persistent_public_ip ? aws_eip.dsf_instance_eip[0].public_dns : aws_instance.dsf_base_instance.public_dns
public_ip = var.attach_persistent_public_ip ? aws_eip.dsf_instance_eip[0].public_ip : (aws_instance.dsf_base_instance.public_ip == "" ? null : aws_instance.dsf_base_instance.public_ip)
public_dns = var.attach_persistent_public_ip ? aws_eip.dsf_instance_eip[0].public_dns : (aws_instance.dsf_base_instance.public_dns == "" ? null : aws_instance.dsf_base_instance.public_dns)
private_ip = length(aws_network_interface.eni.private_ips) > 0 ? tolist(aws_network_interface.eni.private_ips)[0] : null

security_group_ids = concat(
Expand Down