Open LevinDmytro2 opened 3 years ago
Hey, I'm hitting the same issue described above, but the versions are different:
Terraform version:1.2.1
Kubernetes provider version:2.10.0
Kubernetes version:1.22.0
resource "kubernetes_ingress_v1" "ingress_controller" {
metadata {
annotations = {
"alb.ingress.kubernetes.io/certificate-arn": module.acm_certificate.certificate_arn
"kubernetes.io/ingress.class" = "alb"
}
name = local.name
namespace = local.k8s_namespace
}
spec {
rule {
http {
path {
backend {
service {
name = var.service_name
port {
number = 80
}
}
}
path = "/path*"
}
path {
backend {
service {
name = var.service_name
port {
number = 80
}
}
}
path = "/path1*"
}
path {
backend {
service {
name = var.service_name
port {
number = 80
}
}
}
path = "/path3*"
}
}
}
}
}
resource "aws_route53_record" "ingress_controller" {
zone_id = data.aws_route53_zone.ic.zone_id
name = local.domain-name
type = "CNAME"
ttl = "300"
records = [kubernetes_ingress_v1.ingress_controller.status.0.load_balancer.0.ingress.0.hostname]
}
Expecting successfully found hostname attribute.
Error: Invalid index │ │ on ..\modules\k8s\k8s_ingress_controller.tf line 17, in resource "aws_route53_record" "ingress_controller": │ 17: records = [kubernetes_ingress_v1.ingress_controller.status.0.load_balancer.0.ingress.0.hostname] │ ├──────────────── │ │ kubernetes_ingress_v1.ingress_controller.status[0].load_balancer[0].ingress is empty list of object │ │ The given key does not identify an element in this collection value: the collection has no elements.
Any input will be much appreciated :)
https://stackoverflow.com/questions/53125583/terraform-wait-for-classic-load-balancers-a-record describes similar behavior for the classic load balancer. They suggest a workaround with a dummy dependency to wait until the resource is created.
I'm also running into this issue on the first terraform apply. After waiting a bit and re-applying, it seems to have the ingress attributes (ip, hostname, etc.)
What about wait_for_load_balancer
? Worked for me nicely.
Terraform Version, Provider Version and Kubernetes Version
Affected Resource(s)
Terraform Configuration Files
Debug Output
Panic Output
Steps to Reproduce
provider "aws" { region = "us-west-1" } provider "kubernetes" { config_path = "~/.kube/config" } resource "kubernetes_ingress" "test2" { metadata { name = "upland-test-ingress2" namespace = "test-app2" annotations = { "kubernetes.io/ingress.class" = "nginx" } } spec {
}
} resource "kubernetes_namespace" "example2" { metadata { annotations = { name = "test-app2" }
} } resource "aws_ecr_repository" "foo" { name = kubernetes_ingress.test2.status.0.load_balancer.0.ingress.0.hostname
}
Expected Behavior
Expecting successfully found hostname attribute.
Actual Behavior
│ Error: Invalid index │ │ on ingress.tf line 53, in resource "aws_ecr_repository" "foo": │ 53: name = kubernetes_ingress.test2.status.0.load_balancer.0.ingress.0.hostname │ ├──────────────── │ │ kubernetes_ingress.test2.status[0].load_balancer[0].ingress is empty list of object │ │ The given key does not identify an element in this collection value: the collection has no elements.