gpt4 book ai didi

amazon-web-services - 使用cloudformation启动ec2,它应该使用启动模板

转载 作者:行者123 更新时间:2023-12-03 07:13:35 27 4
gpt4 key购买 nike

我正在尝试使用启动模板创建一个 ec2 实例:因此,我使用以下数据创建了一个启动模板。

启动模板非常基本: img1

当我尝试运行如下所示的云形成模板时:

AWSTemplateFormatVersion: 2010-09-09
Resources:
TestTemplate:
Type: 'AWS::EC2::Instance'
Properties:
LaunchTemplate:
LaunchTemplateSpecification:
LaunchTemplateId: lt-00d9f13eea240e524
LaunchTemplateName: Testtemplate
Version: '1'

我收到此错误:

Encountered unsupported property LaunchTemplateSpecification, whereas in designer it shows that instance can be created.

我缺少什么?我检查了文档,这是 AWS::EC2::instance 支持的属性..

如果我在理解和 yaml 中缺少某些内容,请告诉我

最佳答案

由于 EC2 不是通过自动缩放组从启动模板启动,而是通过资源定义启动,因此您需要首先删除并进行如下配置

  HostA:
Type: AWS::EC2::Instance
Properties:
LaunchTemplate:
LaunchTemplateId: !Ref HostALaunchTemplate
Version: !GetAtt HostALaunchTemplate.LatestVersionNumber

启动模板示例

通过自动扩展组启动启动模板时,通常不需要在启动模板中指定网络接口(interface),因为自动扩展组会处理它。

在启动模板内,删除 LaunchTemplateData 中的 SecurityGroupId

  HostALaunchTemplate:
Type: AWS::EC2::LaunchTemplate
Properties:
LaunchTemplateName: HostALaunchTemplate
LaunchTemplateData:
SecurityGroupIds:
- !ImportValue MyASG

并通过网络接口(interface)添加安全组,如下所示

  HostALaunchTemplate:
Type: AWS::EC2::LaunchTemplate
Properties:
LaunchTemplateName: HostALaunchTemplate
NetworkInterfaces:
- DeviceIndex: 0
Groups:
- !ImportValue MyASG
SubnetId: !ImportValue MySubnet

关于amazon-web-services - 使用cloudformation启动ec2,它应该使用启动模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59541023/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com