You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将Elastic Beanstalk环境从Launch Configuration迁移至Launch Template

将Elastic Beanstalk环境从Launch Configuration迁移到Launch Template

要将使用Launch Configuration的Elastic Beanstalk环境转换为Launch Template,可按照以下步骤操作:

步骤1:确认当前环境配置

首先确认你的环境确实使用Launch Configuration:

  • 通过Elastic Beanstalk控制台:进入环境的「配置」→「实例」页面,查看「启动选项」类型
  • 通过AWS CLI执行命令:
aws elasticbeanstalk describe-environment-resources --environment-name YOUR_ENV_NAME

在输出的Resources列表中,若存在AWSEBAutoScalingLaunchConfiguration,说明当前使用的是Launch Configuration。

步骤2:更新环境以使用Launch Template

方法一:通过Elastic Beanstalk控制台操作

  1. 登录Elastic Beanstalk控制台,选择目标环境
  2. 切换到配置标签页,找到实例配置模块,点击编辑
  3. 在启动选项区域,将类型从「启动配置」切换为「启动模板」:
    • 若没有现成的匹配模板,Elastic Beanstalk会自动创建一个基于当前Launch Configuration配置的新启动模板
    • 若已有符合要求的启动模板,可直接选择现有模板,并验证模板的实例类型、AMI、安全组、IAM实例配置文件等参数与原配置一致
  4. 点击应用,环境将开始执行滚动更新,逐步替换为使用Launch Template的EC2实例

方法二:通过AWS CLI或配置文件操作

  1. 创建一个AWS Elastic Beanstalk配置文件(例如migrate-to-launch-template.config),内容示例如下(根据你的实际环境参数调整):
Resources:
  AWSEBEC2LaunchTemplate:
    Type: AWS::EC2::LaunchTemplate
    Properties:
      LaunchTemplateName: !Sub "${AWSEBEnvironmentName}-launch-template"
      LaunchTemplateData:
        InstanceType: !Ref InstanceType
        ImageId: !Ref ImageId
        SecurityGroupIds: !Ref SecurityGroups
        IamInstanceProfile: !Ref IamInstanceProfile
        UserData: !Base64 "${UserData}"
  1. 执行CLI命令更新环境:
aws elasticbeanstalk update-environment --environment-name YOUR_ENV_NAME --option-settings file://migrate-to-launch-template.config

环境会自动启动更新流程,替换实例启动方式。

步骤3:验证转换结果

更新完成后,验证环境已切换到Launch Template:

  • 控制台查看:进入环境「配置」→「实例」页面,确认「启动选项」类型为「启动模板」
  • CLI命令验证:再次执行describe-environment-resources命令,确认AWSEBEC2LaunchTemplate存在,且Auto Scaling组已关联该模板
  • 检查EC2实例:在EC2控制台查看实例的「启动来源」,确认是目标Launch Template

注意事项

  • 转换过程为滚动更新,不会导致环境停机,但需确保你的应用支持滚动部署模式
  • 迁移前请备份当前环境配置,若出现问题可通过Elastic Beanstalk的版本回滚功能恢复
  • 原Launch Configuration不会自动删除,可在确认迁移成功后手动清理,建议保留一段时间以备回滚
  • 若你的Launch Configuration包含自定义用户数据、实例存储卷等特殊配置,需确保Launch Template中同步配置这些参数,避免功能异常

内容的提问来源于stack exchange,提问作者Zags

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.10 14:50:44