amazon-web-services - 用于 EC2 实例中现货请求的 aws cloudformation 模板

标签 amazon-web-services aws-cloudformation spot-instances

我需要一个示例云形成模板来在 AWS 中配置 ec2 实例时添加现货请求。我已尝试使用控制台来配置现货实例,但我找不到在 ec2 中添加现货请求的任何确切模板

最佳答案

您可以创建 SpotFleet 资源,这是一个示例

SpotFleet:
 Type: AWS::EC2::SpotFleet
 Properties:
   SpotFleetRequestConfigData:
     IamFleetRole: !GetAtt [IAMFleetRole, Arn]
     SpotPrice: '1000'
     TargetCapacity:
       Ref: TargetCapacity
     LaunchSpecifications:
     - EbsOptimized: 'false'
       InstanceType:
         Ref: InstanceType
     ImageId:
       Fn::FindInMap:
       - AWSRegionArch2AMI
       - Ref: AWS::Region
       - Fn::FindInMap:
         - AWSInstanceType2Arch
         - Ref: InstanceType
         - Arch
     SubnetId:
       Ref: Subnet1
     WeightedCapacity: '8'
   - EbsOptimized: 'true'
     InstanceType:
       Ref: InstanceType
     ImageId:
       Fn::FindInMap:
       - AWSRegionArch2AMI
       - Ref: AWS::Region
       - Fn::FindInMap:
       - AWSInstanceType2Arch
       - Ref: InstanceType
       - Arch
     Monitoring:
       Enabled: 'true'
       SecurityGroups:
        - GroupId:
            Fn::GetAtt:
            - SG0
            - GroupId
      SubnetId:
         Ref: Subnet0
      IamInstanceProfile:
        Arn:
        Fn::GetAtt:
        - RootInstanceProfile
        - Arn
      WeightedCapacity: '8'

关于amazon-web-services - 用于 EC2 实例中现货请求的 aws cloudformation 模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69664117/

相关文章:

amazon-web-services - AWS 自动缩放策略终止繁忙实例而不是空闲实例

angular - 使用 AWS Amplify 构建 Angular 10 应用程序时出错

amazon-web-services - 使用 EC2 Image Builder 将附加 EBS 卷安装到 AMI

amazon-web-services - Terraform:将 CloudFormation 模板写入磁盘

aws-cloudformation - 将 CommaDelimitedList of Roles 转换为 Cloudformation 中的 Arns 列表

amazon-web-services - 当嵌套堆栈处于 DELETE_COMPLETE 状态时,如何强制更新根堆栈?

amazon-web-services - 从本地计算机连接时,AWS RDS 速度非常慢