Terraform Module output is wrong

We are using the module.nexus.stdout to create the resource aws_route53_record but the module.nexus.stdout gives a different result and when we run the command 'kubectl get services --namespace nexus nexus -o json | jq -r ‘.status.loadBalancer.ingress[0].hostname’ it gives the currently running pod name i.e a86166087f3024a69805fcdfa19f96c8-1108193269.us-east-2.elb.amazonaws.com.

my terraform plan shows ~ triggers = {
~ stderr = → aa8226b3e078a432892a1dc079830779-2139391391.us-east-2.elb.amazonaws.com
~ stdout = a86166087f3024a69805fcdfa19f96c8-1108193269.us-east-2.elb.amazonaws.comaa8226b3e078a432892a1dc079830779-2139391391.us-east-2.elb.amazonaws.com
}

Below are the configs that we are using to create the aws_route53_record.

module “nexus” {
source = “matti/resource/shell”
version = “1.5.0”
command = “kubectl get services --namespace nexus nexus -o json | jq -r ‘.status.loadBalancer.ingress[0].hostname’”
}
output “nexus” {
value = module.nexus.stdout
}

resource “aws_route53_record” “nexus” {
zone_id = aws_route53_zone.monitoring.zone_id
name = “nexus.monitoring.watch.com
type = “CNAME”
ttl = 300
records = [module.nexus.stdout]
}

Hello there,
Instead of using the shell module, you can use Terraform’s kubernetes_service data source to fetch the load balancer hostname directly.

Looking at that module, it seems it was deprecated and archived 3 years ago, so I would not suggest continuing to use it. If the output was incorrect, it means that something in the module is not configured correctly, and I don’t see anything in your module block that would indicate the output could ever update from the initial value.

If the kubernetes provider already has resources designed to solve the problem, that would be the best solution.