Terraform-provider-aws: tag an EC2 network interface

Created on 14 Aug 2017  ยท  5Comments  ยท  Source: hashicorp/terraform-provider-aws

_This issue was originally opened by @gchek as hashicorp/terraform#15799. It was migrated here as a result of the provider split. The original body of the issue is below._


Hello

I am trying to figure out how I can tag an EC2 interface (in my case Eth0) with a specific value.
I am not talking about instance tag - that's easy.

screen shot 2017-08-14 at 10 23 44

question

Most helpful comment

@Ninir what do you think about extending aws_instance with something akin to volume_tags, think network_interface_tags, to make the above workaround unnecessary?

All 5 comments

Solved by the author using:

/*================
EC2 Instance for App VM
This is a mix between "aws_network_interface" and "aws_instance" 
to be able to tag the Eth0 interface
=================*/

resource "aws_network_interface" "appEth0" {
     subnet_id       = "${var.subnet_id}"
     security_groups = ["${var.SG_id}"]
     tags {
       "TAG" = "default"  #This will be the **Eth0** tag !!
     }  
}

resource "aws_instance" "app" {
    ami                         = "ami-b2527ad2" #Ubuntu Server 14.04 LTS (HVM), SSD Volume Type - ami-b2527ad2 N.California
    instance_type               = "t2.micro"
    network_interface {
     network_interface_id       = "${aws_network_interface.appEth0.id}"
     device_index               = 0
    } 
    key_name                    = "${var.key_pair}"    
    tags = {
        Name = "App VM" #This will be the **EC2 Instance** tag !!
    }
}

Closing!

@Ninir what do you think about extending aws_instance with something akin to volume_tags, think network_interface_tags, to make the above workaround unnecessary?

@Ninir @xmj
Agreed. I was just browsing the github issues to find an issue asking this question.

Is it possible to extend aws_instance to tag network_interfaces?
Similar to how volume_tags are currently supported.

It's worth noting that the workaround cannot be used if the instance requires a public IP address.

Error: "network_interface": conflicts with associate_public_ip_address

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

Was this page helpful?
0 / 5 - 0 ratings