我想使用 aws cloudformation 模板启动多个 Ec2 实例,而不使用 AutoScaling。 请告诉我如何启动?
最佳答案
有多种方法可以使用 CloudFormation 启动多个实例,而无需安装 Autoscaling Group。
以下模板有 2 个资源,将启动 2 个 EC2 实例。您可以根据需要添加更多资源。
server1:
Type: AWS::EC2::Instance
Properties:
InstanceType: !Ref Server1InstanceType
KeyName: !Ref ServerKeypair
ImageId: !Ref ServerImageId
SecurityGroupIds:
- !Ref ServerSG
SubnetId: !Ref PrivateWeb1b
Tags:
- Key: Name
Value: server1
server2:
Type: AWS::EC2::Instance
Properties:
InstanceType: !Ref Server2InstanceType
KeyName: !Ref ServerKeypair
ImageId: !Ref ServerImageId
SecurityGroupIds:
- !Ref ServerSG
SubnetId: !Ref PrivateWeb1b
Tags:
- Key: Name
Value: server2
以下模板有 1 个资源,将启动 1 个 EC2 实例。根据第二种方法,您可以使用同一模板创建多个 Cloudformation 堆栈来获取多个 EC2 实例。
server1:
Type: AWS::EC2::Instance
Properties:
InstanceType: !Ref Server1InstanceType
KeyName: !Ref ServerKeypair
ImageId: !Ref WebserverImageId
SecurityGroupIds:
- !Ref WebserverSG
SubnetId: !Ref PrivateWeb1b
Tags:
- Key: Name
Value: server1
关于amazon-web-services - 如何在不使用 AutoScaling 的情况下使用 aws cloudformation 启动多个 EC2 实例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46557710/