首页 > 解决方案 > 我无法使用 get-launch-template-data 的输出创建模板

问题描述

我开始玩 AWS。我使用 AWS 管理控制台创建了一个 EC2 实例。我希望能够使用 CLI 创建新的类似实例,因此我一直在查看 get-launch-template-data (其中指出“检索指定实例的配置数据。您可以使用此数据创建一个启动模板。”)并期望其输出是 create-launch-template 的有效输入。

我查看了 AWS CLI 文档,并查看了 StackOverflow,但我发现的唯一相关问题是: 无法使用 awscliAmazon 启动模板创建启动模板 - 更新的 AMI

我一直在运行:

aws ec2 get-launch-template-data --instance-id "i-xxx" --query "LaunchTemplateData"  > MyLaunchData
aws ec2 create-launch-template --launch-template-name xxx --launch-template-data file://MyLaunchData

我得到的错误是:

An error occurred (InvalidInterfaceType.Malformed) when calling the CreateLaunchTemplate operation: '%s' is not a valid value for interface type. Enter a valid value and try again.

我认为 MyLaunchData 的相关部分是:

    "NetworkInterfaces": [
        {
            "AssociatePublicIpAddress": true,
            "DeleteOnTermination": true,
            "Description": "",
            "DeviceIndex": 0,
            "Groups": [
                "sg-xxx"
            ],
            "InterfaceType": "interface",
            "Ipv6Addresses": [],
            "PrivateIpAddresses": [
                {
                    "Primary": true,
                    "PrivateIpAddress": "xxx"
                }
            ],
            "SubnetId": "subnet-xxx"
        }
    ],

有人可以指出我正确的方向吗?
(为了隐私,我显然已经用 xxx 替换了我认为是我的数据)

非常感谢

标签: amazon-web-servicesamazon-ec2command-line-interface

解决方案


不允许使用 InterfaceType:

“%s”不是接口类型的有效值

我知道您正在使用get-launch-template-data的输出,但没有"InterfaceType": "interface"

AWS EC2 文档

InterfaceType

Indicates the type of network interface. To create an Elastic Fabric Adapter (EFA),
specify efa. For more information, see Elastic Fabric Adapter in the Amazon Elastic
Compute Cloud User Guide.

Required: No

Type: String

Allowed Values: efa

推荐阅读