Ec2 实例在云形成过程中立即终止

Ec2 instance getting terminated instantly in cloud formation

我创建了一个简单的 JSON 模板,用于使用 CloudFormation 启动 EC2 实例。 JSON 代码适用于 RedHat ami-2051294a(在 us-east-1 region 中)但不适用于 Amazon Linux ami-0b33d91d.

可能是什么问题?

  "Resources": {
    "Ec2Instance" :{
      "Type" : "AWS::EC2::Instance",
      "Properties" : {
        "Tags": [
          { "Key" : "Name" , "Value" : "BIP-Spark" } 
           ],
        "KeyName": { "Ref" : "KeyName" },
        "InstanceType" : { "Ref" : "BipDevInstanceType" },
        "ImageId" : { "Ref" : "NATAMI" },
        "IamInstanceProfile" : { "Ref": "RoleName" },
        "BlockDeviceMappings" : [ { 
           "DeviceName" : "/dev/sda1",
           "Ebs" : { "VolumeSize" : "30", "VolumeType": "gp2" } 
            },
           {
           "DeviceName" : "/dev/sdb",
           "Ebs" : { "VolumeSize" : "30", "VolumeType": "gp2" }
           }
        ],
        "NetworkInterfaces" : [ {
           "GroupSet": [ "sg-***" ],
           "SubnetId": { "Ref" : "SubnetID" },
           "AssociatePublicIpAddress": "true",
           "DeleteOnTermination": "true",
           "DeviceIndex":"0" }
         ]
        }
      }
    }
}

这两个 AMI 都非常适合我。

这是我用来成功启动 Amazon Linux AMI ami-0b33d91d:

的 Amazon EC2 实例的模板的最小版本
{  
   "AWSTemplateFormatVersion":"2010-09-09",

  "Resources": {
    "Ec2Instance" :{
      "Type" : "AWS::EC2::Instance",
      "Properties" : {
        "InstanceType" : "t2.micro",
        "ImageId" : "ami-0b33d91d",
        "NetworkInterfaces" : [ {
           "GroupSet": [ "sg-xxxxxxxx" ],
           "SubnetId": "subnet-xxxxxxxx",
           "AssociatePublicIpAddress": "true",
           "DeleteOnTermination": "true",
           "DeviceIndex":"0" }
         ]
        }
      }
    }
}

实例成功进入运行状态并保持运行正确

很可能您手动输入的参数之一不正确。