我正在尝试将SecurityGroup名称作为参数传递给CloudFormation模板。在创建堆栈时,它会向我提供所有安全组的下拉列表,而我会提供一个但其失败并出现以下错误
“参数验证失败:参数名称SecurityGroup的参数值launch-wizard-1不存在。用户请求回滚。”
{
"Description": "Create an EC2 instance running the latest amazon Linux AMI.",
"Parameters": {
"KeyPair": {
"Description": "The EC2 key Pair to allow SSH access to the instance",
"Type": "String"
},
"SecurityGroup": {
"Description": "Name of security group",
"Type": "AWS::EC2::SecurityGroup::GroupName"
}
},
"Resources": {
"EC2Instance": {
"Properties": {
"ImageId": "ami-0080e4c5bc078760e",
"InstanceType": "t2.micro",
"KeyName": {
"Ref": "KeyPair"
},
"SecurityGroups" : [ {"Ref" : "SecurityGroup"} ]
},
"Type": "AWS::EC2::Instance"
}
},
"Outputs": {
"InstanceId": {
"Description": "The InstanceId of newly created EC2 instance",
"Value": {
"Ref": "EC2Instance"
}
}
},
"AWSTemplateFormatVersion": "2010-09-09"
}
答案 0 :(得分:0)
我测试了您的模板(替换AMI并使用自己的安全组名称),并且工作正常。
实例可能是在与安全组不同的VPC 中启动的。