Reputation: 32326
I am using the following code of Parameters to select the latest AMI. It works as execpted.
"Parameters" : {
"LatestAmiId" : {
"Type" : "AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>",
"Default" : "/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-ebs"
}},
Is there a similar way to select the subnet of default security group? I do not want to mention the subnet (or security group) like this...
"SubnetId": "subnet-e8ecf09c, subnet-aa9dfc90, subnet-ce083188, subnet-718bd259",
Update:
I am using the following code and it fails with an error " Value of property SubnetId must be of type String"
{
"Parameters": {
"LatestAmiId": {
"Type": "AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>",
"Default": "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-ebs"
},
"myKeyPair" : {
"Description" : "Amazon EC2 Key Pair",
"Type" : "AWS::EC2::KeyPair::KeyName"
},
"mySubnetIDs" : {
"Description" : "Subnet IDs",
"Type" : "List<AWS::EC2::Subnet::Id>"
},
"Oksoftaccess":{
"Type":"AWS::SSM::Parameter::Value<String>",
"Default":"myEC2TypeDev"
},
"Oksoftsecret":{
"Type":"String",
"Default":"mysecret1"
}
},
Upvotes: 0
Views: 381
Reputation: 5124
As per this document, the “SubnetId” property in the “AWS::EC2::Instance” must be “String” type. However, the parameter type called “Subnet” is defined as “List” which is a list . EC2 instances can be run in the only one subnet (not multiple subnets).
Change the parameter type to “AWS::EC2::Subnet::Id” as below in your CF template and then try again:
"mySubnetIDs": {
...
"Type": "AWS::EC2::Subnet::Id"
...
}
Upvotes: 1