Skip to content

cloudformation for EC2 instance with multiple interfaces

1

I have the following working one Enter image description here Enter image description here

but I did the same way in my cloudformation Enter image description here Enter image description here

I got the following Enter image description here

Anyone can shed some lights ?

thanks !!!

asked 2 years ago291 views

2 Answers
2

The issue you're encountering with your CloudFormation template for creating an EC2 instance with multiple network interfaces is likely related to how you've structured the NetworkInterfaces property.

In CloudFormation, when defining multiple network interfaces for an EC2 instance, you need to use a list format for the NetworkInterfaces property. Each network interface should be defined as a separate item in this list.

Based on the error message you've shared, it appears that CloudFormation is interpreting your NetworkInterfaces property as a single interface rather than a list of interfaces. This is why it's complaining about unexpected additional properties.

To fix this, you should structure your NetworkInterfaces property as a list, even if you're only defining one interface. Here's an example of how it should look:

NetworkInterfaces: 
  - AssociatePublicIpAddress: "true"
    DeviceIndex: "0"
    GroupSet: 
      - !Ref SecurityGroup
    SubnetId: !Ref Subnet

If you want to add a second network interface, you would add another item to this list:

NetworkInterfaces: 
  - AssociatePublicIpAddress: "true"
    DeviceIndex: "0"
    GroupSet: 
      - !Ref SecurityGroup
    SubnetId: !Ref Subnet
  - AssociatePublicIpAddress: "false"
    DeviceIndex: "1"
    GroupSet: 
      - !Ref AnotherSecurityGroup
    SubnetId: !Ref AnotherSubnet

Make sure each network interface has a unique DeviceIndex. The primary network interface should have a DeviceIndex of 0.

By structuring your NetworkInterfaces property as a list, you should be able to resolve the error and successfully create your EC2 instance with multiple network interfaces using CloudFormation.
Sources
AWS::CloudFormation::Interface - AWS CloudFormation
Creating your first stack - AWS CloudFormation
How CloudFormation works - AWS CloudFormation

answered 2 years ago

EXPERT

reviewed 2 years ago

0
Accepted Answer

WOW, figured it out. "SourceDestCheck" : false, should be under individual interface.

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.