Terraform aws provider: Attaching a network interface before creating an instance

1,071 views
Skip to first unread message

Kanhaiya Choudhary

unread,
Aug 30, 2016, 11:48:19 PM8/30/16
to Terraform
Hi all,

Is there a way to attach a network interface to an instance before creating it.
This option is available from AWS console.
Please help here.

Thank you.

Andrew Langhorn

unread,
Aug 31, 2016, 5:02:22 PM8/31/16
to terrafo...@googlegroups.com
Hi Kanhaiya,

How do you mean? An ENI can only be attached to an EC2 instance after it's been created, as far as I'm aware.

You can attach an ENI to an instance in different states (running, stopped, maybe a few others), but I don't think it's possible to attach one before the instance hits the created state.

(If it's the Launch Wizard you're referring to, that's basically just getting hold of all of the values for the arguments to pass to the relevant EC2 APIs, so whilst it's on multiple pages, it's not actually doing anything with the information you provide until click Launch at the end.)

In Terraform, you need to use the aws_network_interface resource's attachment block (https://www.terraform.io/docs/providers/aws/r/network_interface.html#attachment) which associates the ENI with an instance, although you can provide a computed variable at that time (say, "${aws_instance.foo.id}") to ease things along.

Does that help out?

Andrew

Kanhaiya Choudhary

unread,
Aug 31, 2016, 11:20:03 PM8/31/16
to Terraform, andrew....@thoughtworks.com
Thank you very much Andrew. That really helps :)

Regards,
Kanhaiya

Lowe Schmidt

unread,
Sep 1, 2016, 11:41:57 PM9/1/16
to terrafo...@googlegroups.com
All things regarding the resource aws_instance is right here => https://www.terraform.io/docs/providers/aws/r/instance.html 
All things regarding the resource aws_network_interface is here => https://www.terraform.io/docs/providers/aws/r/network_interface.html

But attaching an interface before the instance exists sounds hard to do, not sure if I understand how you would do that.


--
Lowe Schmidt | +46 723 867 157

--
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-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/f09f1848-c435-41e3-bfb6-3d5c3fe38dd8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages