gpt4 book ai didi

amazon-web-services - 参数: [KeyPair] must have values

转载 作者:行者123 更新时间:2023-12-05 03:10:10 25 4
gpt4 key购买 nike

我正在尝试使用 cloudformation 镜像我的 EC2 实例。目前,我已经能够使用对流层创建以下 JSON,但遇到错误“参数:[KeyPair] 必须有值”。我不确定这个“值(value)观”必须是什么?

我理解错误,但不确定解决方案是什么。

{
"Outputs": {
"InstanceAccess": {
"Description": "",
"Value": {
"Fn::Join": [
"",
[
"ssh -i ",
{
"Ref": "KeyPair"
},
" ubuntu@",
{
"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 参数应该具有有效的类型。根据Parameters CloudFormation User Guide 部分,KeyPair 参数的类型为 AWS::EC2::KeyPair::KeyName。所以它应该看起来像这样:

"KeyPair": {
"Description": "The name of the keypair to use for SSH access",
"Type": "AWS::EC2::KeyPair::KeyName"
}

此外,如果您在模板中将 key 对名称声明为参数,则在使用该模板创建堆栈时必须将现有 key 对名称作为参数传递。

关于amazon-web-services - 参数: [KeyPair] must have values,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40900132/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com