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

使用AWS EC2 HTTPS API调用RunInstances时LaunchTemplate参数报错求助

解决AWS EC2 RunInstances API中LaunchTemplate参数的HTTPS调用问题

AWS EC2的RunInstances API采用REST-query风格,不能直接以JSON格式传递LaunchTemplate参数,必须遵循AWS的层级参数命名规则(用.分隔嵌套结构),这是你出错的核心原因。

正确的参数构造规则

LaunchTemplate参数需要拆分为以下键值对(二选一指定模板标识,版本可选):

  • LaunchTemplate.LaunchTemplateId=lt-xxxxxx:用启动模板ID指定
  • LaunchTemplate.LaunchTemplateName=my-template:用启动模板名称指定
  • LaunchTemplate.Version=$Default:可选,指定使用的模板版本,默认值为$Default,也可填具体版本号或$Latest

HTTPS请求示例(GET方式)

GET https://ec2.us-east-1.amazonaws.com/?Action=RunInstances
&MinCount=1
&MaxCount=1
&LaunchTemplate.LaunchTemplateId=lt-0123456789abcdef0
&LaunchTemplate.Version=$Default
&Version=2016-11-15

Postman配置步骤

  1. 选择GET请求方法,填入对应区域的EC2 Endpoint(比如us-west-2为https://ec2.us-west-2.amazonaws.com)
  2. 在「Params」标签页添加参数:
    • Key: Action,Value: RunInstances
    • Key: MinCount,Value: 1
    • Key: MaxCount,Value: 1
    • Key: LaunchTemplate.LaunchTemplateId,Value: 你的启动模板ID
    • Key: LaunchTemplate.Version,Value: $Default
    • Key: Version,Value: 2016-11-15(或更新的稳定版本)
  3. 配置AWS签名:在「Authorization」标签页选择「AWS Signature」,填入Access Key、Secret Key,选择对应区域,Service Name填ec2

常见错误排查

  • 错误传递JSON格式的LaunchTemplate参数:REST-query API不支持直接传JSON,必须拆分层级键值对
  • 参数名拼写错误:API参数名是LaunchTemplate,而非文档中的结构体名称LaunchTemplateSpecification
  • 未指定API版本:务必添加Version参数,否则可能导致参数识别失败

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.18 05:55:25