Cloudformation error: Value of property NetworkInterfaces must be a list of objects

Cloudformation error: Value of property NetworkInterfaces must be a list of objects

在 CloudFormation 模板中引用 NetworkInterface 时出现错误 Value of property NetworkInterfaces must be a list of objects

相关部分如下:

我的应用程序网络接口: 类型:AWS::EC2::NetworkInterface 特性: 子网 ID:!Ref SubnetPrivate</p> <p>我的应用程序: 类型:AWS::EC2::Instance 特性: 实例类型:t2.medium 网络接口: - !Ref MyAppNetworkInterface

你不能那样做。相反,独立创建这两个资源,然后连接到网络接口附件资源。

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-network-interface-attachment.html

您实际上可以直接从 EC2 主机引用网络接口。但语法略有不同:

MyAppNetworkInterface:
  Type: AWS::EC2::NetworkInterface
  Properties:
    SubnetId: !Ref SubnetPrivate

MyApp:
  Type: AWS::EC2::Instance
  Properties:
    InstanceType: t2.medium
    NetworkInterfaces:
    - NetworkInterfaceId: !Ref MyAppNetworkInterface
      DeviceIndex: 0

(参见:http://docs.amazonaws.cn/en_us/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-network-interface.html#cfn-awsec2networkinterface-templateexamples