I want to create an AWS stack through portal or through cloud formation. But I want to add multiple EC2 instances in one single stack. I am not finding enough examples. How can I find one ?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Just add more AWS::EC2::Instance
resource into your CloudFormation template.
For example:
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Ec2 block device mapping",
"Resources": {
"MyEC2Instance1": {
"Type": "AWS::EC2::Instance",
"Properties": {
"ImageId": "ami-79fd7eee",
"KeyName": "testkey1",
"BlockDeviceMappings": [
{
"DeviceName": "/dev/sdm",
"Ebs": {
"VolumeType": "io1",
"Iops": "200",
"DeleteOnTermination": "false",
"VolumeSize": "20"
}
},
{
"DeviceName": "/dev/sdk",
"NoDevice": {
}
}
]
}
},
"MyEC2Instance2": {
"Type": "AWS::EC2::Instance",
"Properties": {
"ImageId": "ami-79fd7eee",
"KeyName": "testkey2",
"BlockDeviceMappings": [
{
"DeviceName": "/dev/sdm",
"Ebs": {
"VolumeType": "io1",
"Iops": "200",
"DeleteOnTermination": "false",
"VolumeSize": "20"
}
},
{
"DeviceName": "/dev/sdk",
"NoDevice": {
}
}
]
}
}
}
}