I wrote a simple cloudformation template that has few parameters. All parameters work. But when I pass Availability zone, the template gives error during creation saying "not a valid availability zone". Here is my error and code below:
11:48:47 UTC-0700 CREATE_FAILED AWS::EC2::Instance EC2Instance Invalid availability zone:
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "EC2 Head Node Instance ",
"Parameters": {
"AZ": {
"Description": "Availablity Zone",
"Type": "String"
},
"Region":{
"Description": "Dev/Test/Prod regions",
"Type": "String"
},
"AMI": {
"Description": "AMI to start virtual server",
"Type": "String",
"MaxLength": 12,
"MinLength": 12
},
"Subnet": {
"Description": "subnet to launch virtual server in",
"Type": "AWS::EC2::Subnet::Id"
}
},
"Resources": {
"EC2Instance": {
"Type": "AWS::EC2::Instance",
"Properties": {
"ImageId": {"Ref": "AMI"},
"SubnetId": {"Ref": "Subnet"},
"AvailabilityZone": {"Ref":"AZ"},
"Tags": [
{
"Key": "Name",
"Value": "QRM Head Node in DEV region"
}
]
}
}
},
"Outputs": {
"InstanceId": {
"Value": {"Ref": "EC2Instance"},
"Description": "ID of virtual server"
},
"PublicIPAddress": {
"Value": {"Fn::GetAtt": ["EC2Instance", "PublicIp"]},
"Description": "public IP address of virtual server"
}
}
}