unknown key: network_interface when attaching elastic IP to network interface

335 views
Skip to first unread message

Jaime Soriano Pastor

unread,
Oct 9, 2015, 11:33:00 AM10/9/15
to Terraform
Hi,

I'm trying to create an AWS EC2 instance with a network interface associated to an elastic IP, but it seems like the aws_eip resource doesn't accept a network_interface, when running terraform plan I get:

Errors:

  * aws_eip.java: : invalid or unknown key: network_interface

The code is like this:

resource "aws_instance" "java" {
    ami = "${lookup(var.java_amis, var.region)}"
    key_name = "${var.key_name}"
    instance_type = "t2.micro"
    subnet_id = "${lookup(var.subnet_ids, var.region)}"
}

resource "aws_network_interface" "java" {
    subnet_id = "${lookup(var.subnet_ids, var.region)}"
    attachment {
        instance = "${aws_instance.java.id}"
        device_index = 1
    }
}

resource "aws_eip" "java" {
    network_interface = "${aws_network_interface.java.id}"
}

output "ip" {
    value = "${aws_eip.java.public_ip}"
}

What am I doing wrong?

Thanks!

Andrew Langhorn

unread,
Oct 9, 2015, 11:36:37 AM10/9/15
to <terraform-tool@googlegroups.com>
The aws_eip resource takes instance as an ID, not network_interface as an ID. https://terraform.io/docs/providers/aws/r/eip.html

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/4aefa9a5-cbaa-47f9-963c-feaee9147a4d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Andrew Langhorn
Web Operations
Government Digital Service

a: 6th Floor, Aviation House, 125 Kingsway, London, WC2B 6NH

Jaime Soriano Pastor

unread,
Oct 9, 2015, 11:44:04 AM10/9/15
to Terraform
According to documentation network interface is also supported:

The following arguments are supported:
  • vpc - (Optional) Boolean if the EIP is in a VPC or not.
  • instance - (Optional) EC2 instance ID.
  • network_interface - (Optional) Network interface ID to associate with.

Jaime Soriano Pastor

unread,
Oct 9, 2015, 12:11:21 PM10/9/15
to Terraform
It was a problem with my terraform installation, latest official version works fine.
Reply all
Reply to author
Forward
0 new messages