Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I solve "Incompatible launch template: The network interface's device index must be zero" when updating a CloudFormation template?

I have an existing stack that created an auto-scale group that uses a Launch Configuration. I am now trying to switch this stack so the auto-scale group will use a Launch Template instead of Launch Configuration, but the update is giving this error:

Incompatible launch template: The network interface's device index must be zero. (Service: AmazonAutoScaling; Status Code: 400; Error Code: InvalidQueryParameter; Request ID: 97bdf4cf-5c90-4035-v234-806367461438; Proxy: null)'

The launch configuration defined in the current CloudFormation template sets AssociatePublicIpAddress: true and the instance created by this template has a public IP. The launch template in the CloudFormation template I am trying to use for the update specifies AssociatePublicIpAddress: true under NetworkNetworkInterfaces.

What does this error mean and how do I fix it?


Relevant parts of template:

  LaunchTemplate:
    Type: AWS::EC2::LaunchTemplate
    Properties:
      LaunchTemplateName: my-launch-template
      LaunchTemplateData:
        EbsOptimized: false
        IamInstanceProfile:
          Arn: !GetAtt MyInstanceProfile.Arn
        ImageId: !FindInMap [RegionMap, !Ref "AWS::Region", AMI]
        InstanceType: !Ref InstanceType
        KeyName: !Ref KeyName
        NetworkInterfaces:
          - AssociatePublicIpAddress: true
like image 491
Shawn Avatar asked Oct 27 '25 08:10

Shawn


1 Answers

If you want to explicitly set NetworkInterfaces, then it should be:

  LaunchTemplate:
    Type: AWS::EC2::LaunchTemplate
    Properties:
      LaunchTemplateName: my-launch-template
      LaunchTemplateData:
        EbsOptimized: false
        IamInstanceProfile:
          Arn: !GetAtt MyInstanceProfile.Arn
        ImageId: !FindInMap [RegionMap, !Ref "AWS::Region", AMI]
        InstanceType: !Ref InstanceType
        KeyName: !Ref KeyName
        NetworkInterfaces:
          - DeviceIndex: 0 
            AssociatePublicIpAddress: true
            Groups: [<security-group-id>]
like image 101
Marcin Avatar answered Oct 29 '25 23:10

Marcin