Is it possible to tag the embedded NIC in AWS with cloudformation? If not, is it possible to disable the embedded NIC and create a new resource and attach the NIC to the instance as ID 0 or the only network interface?

It is possible to tag network interfaces in CloudFormation:

This is an example from the documentation with the key/value pair foo/bar:

AWSTemplateFormatVersion: '2010-09-09'
Description: Simple Standalone ENI
Resources:
  myENI:
    Type: AWS::EC2::NetworkInterface
    Properties:
      Tags:
      - Key: foo
        Value: bar
      Description: A nice description.
      SourceDestCheck: 'false'
      GroupSet:
      - sg-75zzz219
      SubnetId: subnet-3z648z53
      PrivateIpAddress: 10.0.0.16

However, it is not possible to tag the embedded network interface, as per documentation. However, you should be able to use the Property DeviceIndex to achieve your ordering. This is an adapted example from the documentation:

AWSTemplateFormatVersion: '2010-09-09'
Description: Simple Standalone ENI
Resources:
  Ec2Instance: 
    Type: "AWS::EC2::Instance"
    Properties: 
      ImageId: 
        Fn::FindInMap: 
          - "RegionMap"
          - Ref: "AWS::Region"
          - "AMI"
      KeyName: 
        Ref: "KeyName"
      NetworkInterfaces: 
        - AssociatePublicIpAddress: "true"
          DeviceIndex: "0"
          GroupSet: 
            - Ref: "myVPCEC2SecurityGroup"
          SubnetId: 
            Ref: "PublicSubnet"

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.