【发布时间】:2019-03-11 22:32:52
【问题描述】:
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 实例的简单模板,请发布
【问题讨论】:
-
您似乎从某个示例中复制了此内容,但仅复制了示例的顶部。
-
是的,我是从这个网站复制的 tothenew.com/blog/…... 但由于代码太大,我无法在此处发布完整代码
-
他的模板非常好。涵盖了 EC2 实例和 VPC 的许多详细信息。你有什么问题?请注意,Internet 上有数千个 CloudFormation 示例。 Google 搜索是您的朋友。
-
是的,这个模板很好,涵盖了很多东西……但是当我选择设计模板时,这个错误出现了“必须定义至少一个资源成员。”无论如何,我找到了另一个模板,当我选择设计模板选项时它也给出了同样的错误。然后我通过浏览附加文件及其工作。不知道为什么设计模板不起作用
标签: amazon-web-services amazon-ec2 cloud amazon-cloudformation