Cloudformation错误:属性值NetworkInterfaces必须是对象列表

时间:2017-12-05 00:09:13

标签: amazon-cloudformation

在CloudFormation模板中引用NetworkInterface时,我收到错误Value of property NetworkInterfaces must be a list of objects

以下是相关部分:

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

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

2 个答案:

答案 0 :(得分:3)

您实际上可以直接从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

答案 1 :(得分:2)

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

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