我试图使用cloudformation镜像我的EC2实例。目前,我已经能够使用对流层创建以下JSON,并且遇到了错误'参数:[KeyPair]必须有值'。我不确定这个'价值'是什么?参数:[KeyPair]必须具有值
我明白错误,但不知道解决方案是什么。
{
"Outputs": {
"InstanceAccess": {
"Description": "",
"Value": {
"Fn::Join": [
"",
[
"ssh -i ",
{
"Ref": "KeyPair"
},
" [email protected]",
{
"Fn::GetAtt": [
"MyInstance",
"PublicDnsName"
]
}
]
]
}
}
},
"Parameters": {
"KeyPair": {
"Description": "jj",
"Type": "AWS::EC2::KeyPair::launch"
}
},
"Resources": {
"MyInstance": {
"Properties": {
"ImageId": "< my image id goes here>",
"InstanceType": "t1.micro",
"KeyName": {
"Ref": "KeyPair"
},
"SecurityGroups": [
{
"Ref": "SecurityGroup"
}
]
},
"Type": "AWS::EC2::Instance"
},
"SecurityGroup": {
"Properties": {
"GroupDescription": "Allow access to MyInstance",
"SecurityGroupIngress": [
{
"CidrIp": "0.0.0.0/0",
"FromPort": "22",
"IpProtocol": "tcp",
"ToPort": "22"
},
{
"CidrIp": "0.0.0.0/0",
"FromPort": "80",
"IpProtocol": "tcp",
"ToPort": "80"
},
{
"CidrIp": "0.0.0.0/0",
"FromPort": "8080",
"IpProtocol": "tcp",
"ToPort": "8080"
},
{
"CidrIp": "0.0.0.0/0",
"FromPort": "443",
"IpProtocol": "tcp",
"ToPort": "443"
}
]
},
"Type": "AWS::EC2::SecurityGroup"
}
}
}
我早些时候尝试过。我的解决方案出现以下错误:'参数:[KeyPair]必须具有值' –
Fyi,“launch”是我的keyPair的名称。我必须把它放在哪里吗? –
不在模板中。您的密钥对是一个参数,因此当您使用模板创建堆栈时(例如通过Web控制台或CLI),您必须传递有效的密钥对名称作为参数。 – rbarni