Amazon web services 如何为ec2 SpotFleet实例的SecurityGroup定义对象列表

Amazon web services 如何为ec2 SpotFleet实例的SecurityGroup定义对象列表,amazon-web-services,amazon-ec2,amazon-cloudformation,Amazon Web Services,Amazon Ec2,Amazon Cloudformation,我有下面的cloudformation模板,它定义了一个带有安全组的spotfleet ec2实例 Parameters: KeyName: Description: The EC2 Key Pair to allow SSH access to the instance Type: 'AWS::EC2::KeyPair::KeyName' Resources: Ec2Instance: Type: 'AWS::EC2::SpotFleet' Proper

我有下面的cloudformation模板,它定义了一个带有安全组的spotfleet ec2实例

Parameters:
  KeyName:
    Description: The EC2 Key Pair to allow SSH access to the instance
    Type: 'AWS::EC2::KeyPair::KeyName'
Resources:
  Ec2Instance:
    Type: 'AWS::EC2::SpotFleet'
    Properties:
      SpotFleetRequestConfigData:
        AllocationStrategy: lowestPrice
        SpotPrice: 1
        LaunchSpecifications:
          - InstanceType: p2.8xlarge
            KeyName: !Ref KeyName
            ImageId: ami-07d0cf3af28718ef8
            SecurityGroups:
              - !Ref InstanceSecurityGroup
  InstanceSecurityGroup:
    Type: 'AWS::EC2::SecurityGroup'
    Properties:
      GroupDescription: Enable SSH access via port 22
      SecurityGroupIngress:
        - IpProtocol: tcp
          FromPort: '22'
          ToPort: '22'
          CidrIp: 0.0.0.0/0
但是我在创建堆栈时遇到了这个错误:property SecurityGroups的值必须是对象列表。我想知道为什么SecurityGroups不是对象列表?

更新:

检查后,似乎必须指定以下数组:

旧答案:

我想你必须具体说明!引用MyExistingSecurityGroup而不是MyExistingSecurityGroup。

我从模板中删除了MyExistingSecurityGroup行,但仍然存在相同的问题。
    SecurityGroups:
    - GroupId:
        Fn::GetAtt:
        - InstanceSecurityGroup
        - GroupId