output "aws_elasticsearch_domain_arn" {
  description = "Amazon Resource Name (ARN) of the domain"
  value       = local.es_arn_output
}

output "aws_elasticsearch_domain_name_output" {
  description = "Name of the domain"
  value       = local.es_domain_name_output
}

output "aws_elasticsearch_domain_id_output" {
  description = "ID of the domain"
  value       = var.use_opensearch_engine ? aws_opensearch_domain.default[0].domain_id : aws_elasticsearch_domain.default[0].domain_id
}

output "aws_elasticsearch_endpoint_output" {
  description = "Endpoint for the domain"
  value       = local.es_endpoint_output
}

output "aws_elasticsearch_kibana_endpoint_output" {
  description = "Kibana endpoint for the domain, only available for ElasticSearch engines."
  value       = var.use_opensearch_engine ? null : aws_elasticsearch_domain.default[0].kibana_endpoint
}

output "aws_elasticsearch_dashboard_endpoint_output" {
  description = "Dashboard endpoint for the domain, only available for OpenSearch engines."
  value       = var.use_opensearch_engine ? aws_opensearch_domain.default[0].dashboard_endpoint : null
}

output "aws_elasticsearch_route53_fqdn" {
  description = "Unique identifier for the domain"
  value       = var.route53_record_creation_enabled ? aws_route53_record.networking_route53-record[0].fqdn : null
}

output "aws_elasticsearch_cloudwatch_log_group_arn" {
  description = "ARN of cloudwatch log group used by Elasticsearch domain"
  value       = aws_cloudwatch_log_group.elasticsearch_log_group.arn
}

output "aws_elasticsearch_security_group_arn" {
  description = "ARN of elasticsearch security group"
  value       = element(concat(aws_security_group.elasticsearch_security_group[*].arn, [""]), 0)
}

output "aws_elasticsearch_security_group_id" {
  description = "ID of elassticsearch security group"
  value       = element(concat(aws_security_group.elasticsearch_security_group[*].id, [""]), 0)
}

output "aws_elasticsearch_kms_key_arn" {
  description = "ARN of elasticsearch KMS key"
  value       = element(concat(aws_kms_key.kms_key[*].arn, [""]), 0)
}

output "aws_iam_default_ro_access_policy" {
  description = "ARN of the policy that allows RO access to ES cluster"
  value       = aws_iam_policy.elasticsearch_default_ro_policy.arn
}

output "aws_iam_default_rw_access_policy" {
  description = "ARN of the policy that allows RW access to ES cluster"
  value       = aws_iam_policy.elasticsearch_default_rw_policy.arn
}
