我正在通过cloudformation启动p2.xlarge实例,但有时会因错误而失败"安全组在默认VPC中不存在" (不总是)。我认为这可能是一场竞争。
这是我的cloudformation模板:
"Resources":{
"MyInstance":{
"Type":"AWS::EC2::Instance",
"Properties":{
"ImageId":"ami-xxxxxxxx",
"InstanceType":{
"Ref":"InstanceType"
},
"SecurityGroups":[
{
"Ref":"MySecurityGroup"
}
],
"KeyName":{
"Ref":"KeyName"
},
"UserData":{
"Fn::Base64":{
"Fn::Join":[
"",
[
"#!/bin/bash -x\n"
]
]
}
}
}
},
"MySecurityGroup":{
"Type":"AWS::EC2::SecurityGroup",
"Properties":{
"GroupDescription":"Enable ports",
"SecurityGroupIngress":[
{
"IpProtocol":"tcp",
"FromPort":22,
"ToPort":22,
"CidrIp":"0.0.0.0/0"
},
{
"IpProtocol":"tcp",
"FromPort":80,
"ToPort":80,
"CidrIp":"0.0.0.0/0"
},
{
"IpProtocol":"tcp",
"FromPort":443,
"ToPort":443,
"CidrIp":"0.0.0.0/0"
}
]
}
}