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

Support AWS Elastic Network Interfaces (ENI) #1149

Merged
merged 14 commits into from
Mar 19, 2015
Merged

Conversation

peterbeams
Copy link
Contributor

Adding a new resource called aws_network_interface to create network interfaces and attach them to instances.

Mentioned in these issues ...
Add support for ENI's to aws_instance resource #84
AWS Provider Coverage #28

Sample:

resource "aws_vpc" "foo" {
    cidr_block = "172.16.0.0/16"    
}

resource "aws_subnet" "foo" {
    vpc_id = "${aws_vpc.foo.id}"
    cidr_block = "172.16.10.0/24"
    availability_zone = "us-west-2a"
}

resource "aws_subnet" "bar" {
    vpc_id = "${aws_vpc.foo.id}"
    cidr_block = "172.16.11.0/24"
    availability_zone = "us-west-2a"
}

resource "aws_security_group" "foo" {
  vpc_id = "${aws_vpc.foo.id}"
  description = "foo"
  name = "foo"  
}

resource "aws_instance" "foo" {
    ami = "ami-c5eabbf5"
    instance_type = "t2.micro"
    subnet_id = "${aws_subnet.bar.id}"
    associate_public_ip_address = false
    private_ip = "172.16.11.50"
}

resource "aws_network_interface" "bar" {
    subnet_id = "${aws_subnet.foo.id}"   
    private_ips = ["172.16.10.100"]
    security_groups = ["${aws_security_group.foo.id}"]    
    attachment {
        instance = "${aws_instance.foo.id}"
        device_index = 1
    }
    tags {
        Name = "bar_interface"
    }
}

}

new_interface_id := *resp.NetworkInterface.NetworkInterfaceID
d.SetId(new_interface_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small nitpick in that new_interface_id is never used beyond setting here, so d.SetId(*resp.NetworkInterface.NetworkInterfaceID) works just as well. Don't feel you need to change this though 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorted this one with new commit

@catsby
Copy link
Contributor

catsby commented Mar 9, 2015

This looks very promising, thanks!
I had some nitpicks, questions, and requests, but other than that it looks solid so far.
Could you please take a look at my feedback, and also run go fmt on the files?

@catsby catsby added enhancement waiting-response An issue/pull request is waiting for a response from the community labels Mar 9, 2015
@peterbeams
Copy link
Contributor Author

Thanks for the feedback, will take a look through and make some changes.

@jwestboston
Copy link

Very excited to have this feature.

@catsby
Copy link
Contributor

catsby commented Mar 16, 2015

Hey @peterbeams do you think you'll be able to complete the work here?
I can try and complete it if not.
Thanks again!

@peterbeams
Copy link
Contributor Author

Hi @catsby - I'm working on the tweaks now - should have it pushed in couple of hours. Sorry for delay - got carried away with using TF to build my environment!

@peterbeams
Copy link
Contributor Author

Done with the updates, hopefully up to scratch now. Feel free to made any further tweaks you like though. Thanks!

@catsby catsby removed the waiting-response An issue/pull request is waiting for a response from the community label Mar 19, 2015
@catsby
Copy link
Contributor

catsby commented Mar 19, 2015

LGTM!
Tags aren't fully supported though, but I can add those 😄

catsby added a commit that referenced this pull request Mar 19, 2015
Support AWS Elastic Network Interfaces (ENI)
@catsby catsby merged commit df514c9 into hashicorp:master Mar 19, 2015
@catsby
Copy link
Contributor

catsby commented Mar 19, 2015

Finished tag support in a063ebe , thanks again!

@radeksimko radeksimko mentioned this pull request Mar 25, 2015
7 tasks
@peterbeams
Copy link
Contributor Author

Great, thanks @catsby.

@mdallman2570
Copy link

I was looking through the code, but I did not see the ability to add existing ENIs to the instance. Is there an easy way to attach a newly generated instance to an existing ENI? Support under the aws_instance block would be huge. I didn't see it present, but that doesn't mean it isn't there @peterbeams

@ajmath
Copy link
Contributor

ajmath commented Aug 26, 2015

I'm with @mdallman2570. We can attach the ENI to the instance after it's been created but I don't see a way to associate the ENI to the instance when it's creating the instance.

This is useful for me to be able to have the ENI be assigned to eth0 on the instance and avoid any headache of updating the networking on the instance to use the ENI.

@catsby
Copy link
Contributor

catsby commented Aug 26, 2015

@ajmath I believe #2998 is requesting the same thing, yeah?

@ajmath
Copy link
Contributor

ajmath commented Aug 26, 2015

@catsby yes it is. Thanks

@catsby
Copy link
Contributor

catsby commented Aug 26, 2015

Great, just making sure I understood. I can't promise when I'll get to it, but at least it's being tracked separately

@automaticgiant
Copy link
Contributor

automaticgiant commented Dec 3, 2016

There is code in resource_aws_instance.go to do this, is there not?
Though you have to have a an identifier for the eni that aws_instance will take.
I guess you can get it, according to resource_aws_network_interface.go.
I'll test it. This is important.

@ghost
Copy link

ghost commented Apr 19, 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 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants