gpt4 book ai didi

amazon-web-services - 如何在aws堆栈中添加多个ec2实例

转载 作者:行者123 更新时间:2023-12-03 07:29:54 24 4
gpt4 key购买 nike

我想通过门户或云形成创建 AWS 堆栈。但我想在一个堆栈中添加多个 EC2 实例。我没有找到足够的例子。我怎样才能找到一个?

最佳答案

只需添加更多AWS::EC2::Instance resource进入您的 CloudFormation 模板。

例如:

{
"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": {
}
}
]
}
}
}
}

关于amazon-web-services - 如何在aws堆栈中添加多个ec2实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46525053/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com