Terraform plans fail while running "Error: Reference to undeclared module"

Hello,
I am facing below error while running Terraform plan

terraform version
Terraform v0.12.29

  • provider.aws v3.26.0

  • provider.external v2.0.0

  • provider.helm v1.3.0

  • provider.kubernetes v1.13.1

  • provider.local v2.0.0

  • provider.null v3.0.0

  • provider.random v3.0.1

  • provider.sops v0.5.1

    Error: Reference to undeclared module

    on ../../modules/ingress/output.tf line 2, in output "id":
     2:   value = module.ingress.helm_release.cert-manager
    

    No module call named “ingress” is declared in ingress.

While doing terraform state this module exist in state

terraform state list
data.helm_repository.stable
module.aws-services.aws_iam_policy.autoscaler
module.aws-services.aws_iam_role.autoscaler_role
module.aws-services.aws_iam_role_policy_attachment.autoscaler_role_attach
module.aws-services.helm_release.cluster_autoscaler
module.aws-services.helm_release.k8s_spot_termination_handler
module.aws-services.helm_release.kube2iam
module.aws-services.kubernetes_namespace.aws
module.cluster.data.external.aws_iam_authenticator
module.cluster.aws_autoscaling_schedule.jenkins-spot-build-schedule-scale-down[0]
module.cluster.aws_autoscaling_schedule.jenkins-spot-build-schedule-scale-up[0]
module.cluster.aws_iam_policy.assume_role
module.cluster.aws_iam_policy.eks_describe_permission
module.cluster.kubernetes_cluster_role.read_only_access
module.cluster.kubernetes_cluster_role_binding.read_only_access
module.ingress.data.helm_repository.jetstack
module.ingress.aws_cognito_user_pool_client.client
module.ingress.aws_iam_policy.route_53_management_policy
module.ingress.aws_iam_role.route_53_management_role
module.ingress.aws_iam_role_policy_attachment.external_dns_role_attach
module.ingress.helm_release.cert_manager
module.ingress.helm_release.external_dns
module.ingress.helm_release.nginx

Kindly suggest what need to be done to fix the issue ?

Thanks,
Snehil

Looking at the output you have posted here, module.ingress. must be defined in the root module itself, however the error you see is coming from a file with a relative path outside of the root module. That path is also contains modules/ingress, so I would wager this is a typo within the module itself.

You probably intended to write something along the lines of

value =  helm_release.cert-manager.id

Hello,
Thanks for input
Actually helm_release does not support these attribute hence I faced the issue ,
I removed output.tf file and it worked

topic can be closed as got it working