我試圖使用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