gpt4 book ai didi

amazon-web-services - 必须定义至少一个资源成员...云形成 ec2 中的错误

转载 作者:行者123 更新时间:2023-12-04 08:01:34 24 4
gpt4 key购买 nike

I tried other templates from the net but still getting the same error. Error

消息:模板包含错误。:模板格式错误:必须定义至少一个资源成员。

{
"AWSTemplateFormatVersion" : "2010-09-09",

"Description" : "TTND AWS CloudFormation template to launch first instance",

"Parameters" : {

"KeyName" : {
"Description" : "EC2 Key Pair for SSH Access",
"Default" : "sample",
"MinLength": "1",
"MaxLength": "64",
"AllowedPattern" : "[-_ a-zA-Z0-9]*",
"ConstraintDescription" : "can contain only alphanumeric characters, spaces, dashes and underscores."
},
"InstanceType" : {
"Description" : "Instance1 EC2 instance type",
"Type" : "String",
"Default" : "t2.micro",
"AllowedValues" : [ "t2.micro","m1.small","m1.medium","m1.large"],
"ConstraintDescription" : "must be a valid EC2 instance type."
}
},
"Mappings" : {
"AWSInstanceMapping" : {
"t2.micro" : { "Arch" : "64" },
"t2.small" : { "Arch" : "64" },
"t2.medium" : { "Arch" : "64" },
"t2.large" : { "Arch" : "64" },
"m3.medium" : { "Arch" : "64" },
"m4.large" : { "Arch" : "64" },
"m4.xlarge" : { "Arch" : "64" },
"m4.2xlarge" : { "Arch" : "64" }
}
},

"InstanceAMI" : {
"us-east-1" : { "64" : "ami-09ca8e1e" }
},

我尝试了其他网络模板,但遇到了同样的错误

"Resources" : {

"VPC" : {
"Type" : "AWS::EC2::VPC",
"Properties" : {
"CidrBlock" : "10.0.0.0/16",
"Tags" : [
{"Key" : "Application", "Value" : { "Ref" : "AWS::StackId"} },
{ "Key": "Name", "Value": "Project_VPC"},
{"Key" : "Network", "Value" : "Public" }
]
}
},

"PublicSubnet" : {
"Type" : "AWS::EC2::Subnet",
"Properties" : {
"VpcId" : { "Ref" : "VPC" },
"CidrBlock" : "10.0.0.0/24",
"Tags" : [
{"Key" : "Application", "Value" : { "Ref" : "AWS::StackId"} },
{"Key" : "Network", "Value" : "Public" },
{ "Key": "Name", "Value": "Project_Public_Subnet"}
]
}
},

"InternetGateway" : {
"Type" : "AWS::EC2::InternetGateway",
"Properties" : {
"Tags" : [
{"Key" : "Application", "Value" : { "Ref" : "AWS::StackId"} },
{"Key" : "Network", "Value" : "Public" },
{ "Key": "Name", "Value": "Project_Internetgateway"}
]
}
},

"AttachGateway" : {
"Type" : "AWS::EC2::VPCGatewayAttachment",
"Properties" : {
"VpcId" : { "Ref" : "VPC" },
"InternetGatewayId" : { "Ref" : "InternetGateway" }
}
},
"PublicRouteTable" : {
"Type" : "AWS::EC2::RouteTable",
"Properties" : {
"VpcId" : {"Ref" : "VPC"},
"Tags" : [
{"Key" : "Application", "Value" : { "Ref" : "AWS::StackId"} },
{"Key" : "Network", "Value" : "Public" },
{ "Key": "Name", "Value": "cloudwords_public_routetable"}
]
}
},

我为了发布它而删除的一些代码给出了很大的代码错误,所以

"Outputs" : {
"InstanceId" : {
"Description" : "InstanceId of the newly created instance",
"Value" : { "Ref" : "Instance" }
},
}
}

如果有人有使用 CloudFormation 模板启动 AWS EC2 实例的简单模板,请发布

最佳答案

您的示例似乎没有定义任何 AWS::EC2::Instance 资源,这些资源告诉 CloudFormation 预置 EC2 实例。

这是一个非常简约的 CloudFormation 模板,它将创建一个 t2.micro 实例。查看AWS::EC2::Instance resource definition有关可以添加哪些属性来对其进行自定义的详细信息。

{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"ExampleEc2Instance": {
"Type": "AWS::EC2::Instance",
"Properties": {
"InstanceType": "t2.micro",
"ImageId" : "ami-a0cfeed8"
}
}
}
}

为特定操作系统、配置和区域查找有效的 AMI 可能有点棘手。 This walkthrough讨论了使用 AWS Lambda 自动查找 AMI 的策略。

关于amazon-web-services - 必须定义至少一个资源成员...云形成 ec2 中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52682189/

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