I tried other templates from the net but still getting the same error. Error
message: Template contains errors.: Template format error: At least one Resources member must be defined.
{
"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" }
},
I tried other templates for net but same error I am getting
"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"}
]
}
},
some of code I deleted for posting it is giving large code error so
"Outputs" : {
"InstanceId" : {
"Description" : "InstanceId of the newly created instance",
"Value" : { "Ref" : "Instance" }
},
}
}
If anyone has a simple template of Launching an AWS EC2 instance using CloudFormation Template please post
Your examples don't appear to have defined any AWS::EC2::Instance
resources, which are what tell CloudFormation to provision EC2 instances.
Here's a very minimalist CloudFormation template that will create one t2.micro instance. Check out the AWS::EC2::Instance resource definition for details on what properties can be added to customize it.
{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"ExampleEc2Instance": {
"Type": "AWS::EC2::Instance",
"Properties": {
"InstanceType": "t2.micro",
"ImageId" : "ami-a0cfeed8"
}
}
}
}
Finding a valid AMI for a particular operating system, configuration, and region can be a bit tricky. This walkthrough discusses a strategy to automate the looking up of AMIs using AWS Lambda.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With