Pri*_*ani 2 amazon-web-services aws-cloudformation
我想使用 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
Run Code Online (Sandbox Code Playgroud)
以下模板有 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
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5810 次 |
最近记录: |