Skip to content

Commit 7bcaa03

Browse files
authored
fix: conditionally set service domain outputs when disabled (#216)
Previously, service domain output locals were always set, even when the module was disabled. This caused issues with downstream references. Now, these locals are set to null when the module is not enabled, preventing unintended values and improving conditional logic handling.
1 parent 60e4bb7 commit 7bcaa03

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

main.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ locals {
44

55
service_linked_role_name = local.elasticsearch_enabled ? "AWSServiceRoleForAmazonElasticsearchService" : "AWSServiceRoleForAmazonOpenSearchService"
66

7-
aws_service_domain_arn = coalesce(join("", aws_elasticsearch_domain.default[*].arn), join("", aws_opensearch_domain.default[*].arn))
8-
aws_service_domain_endpoint = coalesce(join("", aws_elasticsearch_domain.default[*].endpoint), join("", aws_opensearch_domain.default[*].endpoint))
9-
aws_service_domain_id = coalesce(join("", aws_elasticsearch_domain.default[*].domain_id), join("", aws_opensearch_domain.default[*].domain_id))
10-
aws_service_domain_name = coalesce(join("", aws_elasticsearch_domain.default[*].domain_name), join("", aws_opensearch_domain.default[*].domain_name))
11-
aws_service_domain_kibana_endpoint = coalesce(join("", aws_elasticsearch_domain.default[*].kibana_endpoint), join("", aws_opensearch_domain.default[*].dashboard_endpoint))
7+
aws_service_domain_arn = module.this.enabled ? coalesce(join("", aws_elasticsearch_domain.default[*].arn), join("", aws_opensearch_domain.default[*].arn)) : null
8+
aws_service_domain_endpoint = module.this.enabled ? coalesce(join("", aws_elasticsearch_domain.default[*].endpoint), join("", aws_opensearch_domain.default[*].endpoint)) : null
9+
aws_service_domain_id = module.this.enabled ? coalesce(join("", aws_elasticsearch_domain.default[*].domain_id), join("", aws_opensearch_domain.default[*].domain_id)) : null
10+
aws_service_domain_name = module.this.enabled ? coalesce(join("", aws_elasticsearch_domain.default[*].domain_name), join("", aws_opensearch_domain.default[*].domain_name)) : null
11+
aws_service_domain_kibana_endpoint = module.this.enabled ? coalesce(join("", aws_elasticsearch_domain.default[*].kibana_endpoint), join("", aws_opensearch_domain.default[*].dashboard_endpoint)) : null
1212
}
1313

1414
module "user_label" {

0 commit comments

Comments
 (0)