Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws_network_interface attachment should be handled in aws_instance #3105

Closed
inkblot opened this issue Aug 28, 2015 · 15 comments
Closed

aws_network_interface attachment should be handled in aws_instance #3105

inkblot opened this issue Aug 28, 2015 · 15 comments

Comments

@inkblot
Copy link

inkblot commented Aug 28, 2015

Currently, attachment of a aws_network_interface resource is handled by an object property of the interface itself. This forces the network interface to be created after the aws_instance to which it is attached, and in the case where an instance will have multiple interfaces, it distributes the device indexing information across the several interface resources. The attachment-after-startup also eliminates the possibility of booting an instance into its final network context, not just the interfaces, but also any follow-up initialization such as route53 naming.

Here is a sample of what I would like to be able to do with terraform:

resource "aws_eip" "server" {
  vpc_id = "${var.vpc_id}"
}

resource "aws_network_interface" "server" {
  ...
  public_ips = [ "${aws_eip.server.public_ip}" ]
}

resource "aws_route53_resource_record" "server-private" {
  ...
  records = [ "${aws_network_interface.server.private_ip}" ]
}

resource "aws_instance" "server" {
  depends_on = [ "aws_route53_record_set.server-private" ]
  ...
  network_interfaces {
    0 = "${aws_network_interface.server.id}"
  }
}

In the above sample, the instance is the last resource created. At the point where the instance boots, everything about its network context has already been established and can be guaranteed invariant through use of depends_on. This means that at bootup, the instance 1) has its final eth0, 2) has its final public_ip and private_ip, and 3) that those IPs can be used in terraform prior to creating the instance for example to establish DNS records.

@wilsaj
Copy link

wilsaj commented Sep 16, 2015

+1 for this. Being able to assign elastic IP or network interface on instance creation would make it easier to adjust instances without much disruption (for example, changing instance_type or ami). Without this, DNS records need to be updated if the instance is recreated, and this introduces a delay as the records propagate. Setting a very short TTL on the DNS records sort of mitigates the problem, but isn't a great solution since it introduces a lot of undue DNS traffic.

@rgabo
Copy link

rgabo commented Sep 29, 2015

We're using cloud-init to boot instances into their final state and keep instance immutable otherwise. Our use case is to bind separate public and private interfaces to the same instance and would love to configure SSH/ProFTPD to bind to the correct interfaces.

This requires the interfaces to be already attached at bootcmd/runcmd time so it would be great if this was possible.

@joelmoss
Copy link
Contributor

joelmoss commented Oct 9, 2015

👍 definately need this, as it has flummoxed me several times, and requires manual intervention

@P13612
Copy link

P13612 commented Apr 2, 2016

@Shaiou
Copy link

Shaiou commented May 23, 2016

Another good reason to have the attachment in the aws_instance declaration is regarding the security group. For instance I'm booting an instance with a security group "sg_prv" and I want to add an interface with sg "sg_pub". When doing this with the "aws_network_interface" method, the new interface finds itself in 2 SGs "sg_prv" and "sg_pub"

@zzzuzik
Copy link

zzzuzik commented May 30, 2016

+1

@freimer
Copy link

freimer commented Jun 1, 2016

This is standard functionality that is already part of the AWS API, so this should not be overly difficult to implement. 👍

@alexintel
Copy link

+1

Another factor in creating a network interface before the instance is assignment of eth0. If, for some reason, we want to keep eth0 fixed then creating an ENI and assigning it to aws_instance would be possible. Otherwise, aws_network_interface has to be created with device_index>0

@mdolian
Copy link

mdolian commented Nov 17, 2016

This is needed to reproduce the CloudFormation for the Cisco Cloud Services Router:

https://aws.amazon.com/marketplace/pp/B00EV8VXG2

@lisfo4ka
Copy link

+1

2 similar comments
@vitalii-ielakov
Copy link

+1

@dmytro-rusakov
Copy link

+1

@apparentlymart
Copy link
Contributor

Hi @inkblot! Thanks for opening this and sorry it's sat here unattended for so long.

This request is similar to #2998, so I'm going to close this to consolidate the discussion over there. Furthermore, there's some work to address this going on in #12933 so hopefully it won't be long before the other issue is closed as well.

@inkblot
Copy link
Author

inkblot commented Apr 30, 2017

The new functionality in 0.9.4 is working beautifully! Thank you!

@ghost
Copy link

ghost commented Apr 13, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests