[英]How can I launch more than one EC2 instances using aws cloudformation without using AutoScaling?
I want to launch more than one Ec2 instances using aws cloudformation template without using AutoScaling.我想在不使用 AutoScaling 的情况下使用 aws cloudformation 模板启动多个 Ec2 实例。 Please let me know how can I launch?
请让我知道如何启动?
There are several ways to launch multiple instances using CloudFormation without having Autoscaling Group in place.在没有 Autoscaling Group 的情况下,有多种方法可以使用 CloudFormation 启动多个实例。
Following template has 2 resource which will launch 2 EC2 instance.以下模板有 2 个资源,将启动 2 个 EC2 实例。 You can add more resources as per requirement.
您可以根据需要添加更多资源。
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
Following template has 1 resource which will launch 1 EC2 instance.以下模板有 1 个资源,将启动 1 个 EC2 实例。 As per 2nd method, you can create multiple Cloudformation stacks using same template to get multiple EC2 instances.
按照第二种方法,您可以使用相同的模板创建多个 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
Try using Type: AWS::EC2::EC2Fleet尝试使用类型: AWS::EC2::EC2Fleet
You can specifies a configuration information to launch a fleet--or group--of instances.您可以指定配置信息以启动一组或一组实例。 An EC2 Fleet can launch multiple instance types across multiple Availability Zones, using the On-Demand Instance, Reserved Instance, and Spot Instance purchasing models together.
EC2 队列可以结合使用按需实例、预留实例和 Spot 实例购买模型,跨多个可用区启动多种实例类型。 Using EC2 Fleet, you can define separate On-Demand and Spot capacity targets, specify the instance types that work best for your applications, and specify how Amazon EC2 should distribute your fleet capacity within each purchasing model.
使用 EC2 队列,您可以定义单独的按需和 Spot 容量目标,指定最适合您的应用程序的实例类型,并指定 Amazon EC2 应如何在每个购买模型中分配您的队列容量。
**YAML** Type: AWS::EC2::EC2Fleet Properties: ExcessCapacityTerminationPolicy: String LaunchTemplateConfigs: - FleetLaunchTemplateConfigRequest OnDemandOptions: OnDemandOptionsRequest ReplaceUnhealthyInstances: Boolean SpotOptions: SpotOptionsRequest TagSpecifications: - TagSpecification TargetCapacitySpecification: TargetCapacitySpecificationRequest TerminateInstancesWithExpiration: Boolean Type: String ValidFrom: String ValidUntil: String
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-ec2fleet.html https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-ec2fleet.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.