Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Terraform output for eip allocation id

I have a simple terraform code to create eip.This works fine.

resource "aws_eip" "envoy" {
  count = length(var.subnet_cidr_public)
  vpc   = true
    tags  = "${merge(map("Name","envoyadmin-${count.index}"),var.tags)}"
}

output "envoy_eip" {
  description = "Elastic ip address for Envoy nlb services"
  value       = aws_eip.envoy.*.allocation_id
}

The problem I have is with the terraform output.Eventhough the eips are created in AWS account, the allocation_ids are shown as null in terraform output. What could be the issue with this and how to fix it?

terraform output
envoy_eip = [
  null,
  null,
  null,
]
like image 529
Rad4 Avatar asked Nov 05 '25 13:11

Rad4


1 Answers

The allocation_id is actually now provided through id as explained in the github issue. Thus, you should have:

output "envoy_eip" {
  description = "Elastic ip address for Envoy nlb services"
  value       = aws_eip.envoy.*.id
}

Also this is only id, not "Elastic ip address" as you wrote in description. For public IP you need to use:

output "envoy_eip" {
  description = "Elastic ip address for Envoy nlb services"
  value       = aws_eip.envoy.*.public_ip
}
like image 143
Marcin Avatar answered Nov 08 '25 09:11

Marcin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!