Terraform challenge 3. Public ip association doesnt work

Hi, I don’t understand why public ip association doesn’t work. Can somebody help me to find mistakes in the configuration?

resource "aws_key_pair" "citadel-key" {
  key_name   = "citadel"
  public_key = file("/root/terraform-challenges/project-citadel/.ssh/ec2-connect-key.pub")

}

resource "local_file" "private" {
  source = "/root/terraform-challenges/project-citadel/.ssh/ec2-connect-key"
  filename = "ec2-connect-key"
}

resource "aws_instance" "citadel" {
  ami                         = var.ami
  instance_type               = var.instance_type
  key_name                    = aws_key_pair.citadel-key.key_name
  connection {
    user        = "ec2-user"
    private_key = local_file.private.content
  }
}

resource "aws_eip" "lb" {
  vpc      = true

  provisioner "local-exec" {
    command = "echo ${aws_eip.lb.public_dns} > /root/citadel_public_dns.txt"
  }
}

resource "aws_eip_association" "eip_assoc" {
  instance_id   = aws_instance.citadel.id
  allocation_id = aws_eip.lb.id
}

Hi @tschaefer.extern

There’s no issue with the association as you’ve posted. We will check the lab.

Thank you.
Regards Tanja