【问题标题】:How to set the instance type with Elastic Beanstalk?如何使用 Elastic Beanstalk 设置实例类型?
【发布时间】:2015-06-14 13:45:32
【问题描述】:

如何更改现有 Elastic Beanstalk 应用程序的实例类型?

目前我正在网络界面中更改它:

我尝试使用命令行工具更改它: eb setenv InstanceType=t2.medium

没有抛出错误,也没有改变实例类型。

【问题讨论】:

    标签: amazon-web-services amazon-elastic-beanstalk


    【解决方案1】:

    setenv 命令用于更改环境变量。因此,您尝试的命令相当于 bash:

    export InstanceType=t2.medium

    并没有真正为您的 beanstalk 环境做任何事情。

    您可以在创建过程中使用 -i 选项创建环境

    eb create -i t2.micro
    

    或者,您可以使用eb config 编辑当前运行的环境。这将打开一个文本编辑器。查找如下所示的部分:

    aws:autoscaling:launchconfiguration:
        IamInstanceProfile: aws-elasticbeanstalk-ec2-role
        EC2KeyName: aws
        InstanceType: t1.micro
    

    然后将 t1.micro 编辑为 t2.micro。 (保存并退出)


    但为了让您的生活更轻松,您可以将以下内容另存为 .elasticbeanstalk/saved_configs/default.cfg.yml,CLI 将在所有未来创建时使用所有这些设置。

    AWSConfigurationTemplateVersion: 1.1.0.0
    OptionSettings:
      aws:elb:loadbalancer:
        CrossZone: true
      aws:elasticbeanstalk:command:
        BatchSize: '30'
        BatchSizeType: Percentage
      aws:autoscaling:launchconfiguration:
        IamInstanceProfile: aws-elasticbeanstalk-ec2-role
        EC2KeyName: aws
        InstanceType: t2.micro
      aws:elb:policies:
        ConnectionDrainingEnabled: true
      aws:autoscaling:updatepolicy:rollingupdate:
        RollingUpdateType: Health
        RollingUpdateEnabled: true
      aws:elb:healthcheck:
        Interval: '30'
    

    【讨论】:

    • 在文档中的什么位置可以找到eb create-i 选项?
    • 总是有eb create --help。但如果你真的想要一个网络文档:docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb3-create.html
    • eb config 似乎显示的是 CloudFormation 配置而不是 EB
    • @eric elastic beanstalk 使用 cloudformation。所以是的,EB 环境的配置本质上只是一个 cloudformation 模板。
    • @NickHumrich 能否请您帮忙解决一个题外话问题.. 是否可以在 ebextensions 配置中定义 cloudformation 功能(如 CAPABILITY_NAMED_IAM)?
    【解决方案2】:

    更多脚本方式:

    aws elasticbeanstalk update-environment --environment-name "your-env-name" --option-settings "Namespace=aws:autoscaling:launchconfiguration,OptionName=InstanceType,Value=t2.micro"
    

    【讨论】:

      【解决方案3】:

      接受的解决方案在 2020 年对我不起作用。

      截至今天(2020 年 2 月 26 日),在我的 .ebextensions/02_python.config 中,我必须在 option_settings 下添加以下内容:

      option_settings:
        # ...
      
        aws:ec2:instances:
          InstanceTypes: 'm5.large'
      

      参考:https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.managing.as.html#environments-cfg-autoscaling-namespace.instances

      【讨论】:

        猜你喜欢
        • 2015-12-21
        • 2016-03-29
        • 2020-06-26
        • 2016-05-10
        • 2016-02-03
        • 2020-11-06
        • 2021-12-12
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多