[英]How can I launch more than one EC2 instances using aws cloudformation without using AutoScaling?
我想在不使用 AutoScaling 的情況下使用 aws cloudformation 模板啟動多個 Ec2 實例。 請讓我知道如何啟動?
在沒有 Autoscaling Group 的情況下,有多種方法可以使用 CloudFormation 啟動多個實例。
以下模板有 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
嘗試使用類型: AWS::EC2::EC2Fleet
您可以指定配置信息以啟動一組或一組實例。 EC2 隊列可以結合使用按需實例、預留實例和 Spot 實例購買模型,跨多個可用區啟動多種實例類型。 使用 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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.