gpt4 book ai didi

amazon-web-services - Cloudformation 无法解析参数 - VolumeAttachment

转载 作者:行者123 更新时间:2023-12-03 07:23:24 25 4
gpt4 key购买 nike

我正在尝试实现一个 Cloudformation 模板,它将现有的 EBS 卷安装到现有的 EC2 实例。这是我使用的代码:

AWSTemplateFormatVersion: "2010-09-09"
Description: MountEBStoDev
Parameters:
EBSVolumeID:
Description: The volume we want to attach to the instances
Type: "List<AWS::EC2::Volume::Id>"
InstanceIdToMount:
Description: The instance to attach the volume to
Type: "List<AWS::EC2::Instance::Id>"

Resources:
MountPoint:
Type: "AWS::EC2::VolumeAttachment"
Properties:
Device: /dev/sdh
InstanceId: !Ref InstanceIdToMount
VolumeId: !Ref EBSVolumeID

运行堆栈时,用户可以选择所需的 EBS 和 EC2 实例,我可以看到选择后正确指定了参数,但 Cloudformation 无法附加 EBS 并出现错误

"Value of property InstanceId must be of type String"

我怀疑参数类型中的列表是罪魁祸首,但我没有找到其他方法让用户可以从可用实例/EBS 中进行选择(除了静态列表)。

任何帮助将不胜感激。

最佳答案

看起来 AWS::EC2::Instance::IdAWS::EC2::Volume::Idsupported parameter types ,因此您只需更改代码即可使用它们。就像这样:

AWSTemplateFormatVersion: "2010-09-09"
Description: MountEBStoDev
Parameters:
EBSVolumeID:
Description: The volume we want to attach to the instances
Type: "AWS::EC2::Volume::Id"
InstanceIdToMount:
Description: The instance to attach the volume to
Type: "AWS::EC2::Instance::Id"

Resources:
MountPoint:
Type: "AWS::EC2::VolumeAttachment"
Properties:
Device: /dev/sdh
InstanceId: !Ref InstanceIdToMount
VolumeId: !Ref EBSVolumeID

关于amazon-web-services - Cloudformation 无法解析参数 - VolumeAttachment,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68191501/

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