Amazon cloudformation Cloudformation错误:属性NetworkInterface的值必须是对象列表

Amazon cloudformation Cloudformation错误:属性NetworkInterface的值必须是对象列表,amazon-cloudformation,Amazon Cloudformation,在CloudFormation模板中引用NetworkInterface时,我得到属性NetworkInterface的错误值必须是对象列表 以下是相关章节: MyAppNetworkInterface: 类型:AWS::EC2::NetworkInterface 特性: 子网:!Ref SubnetPrivate MyApp: 类型:AWS::EC2::实例 特性: 实例类型:t2.1中等 网络接口: - !参考MyAppNetworkInterface 你不能那样做。相反,请独立创建这两个

在CloudFormation模板中引用NetworkInterface时,我得到属性NetworkInterface的错误值必须是对象列表

以下是相关章节:

MyAppNetworkInterface: 类型:AWS::EC2::NetworkInterface 特性: 子网:!Ref SubnetPrivate

MyApp: 类型:AWS::EC2::实例 特性: 实例类型:t2.1中等 网络接口: - !参考MyAppNetworkInterface
你不能那样做。相反,请独立创建这两个资源,然后连接网络接口附件资源


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


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

请参阅:

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