Cloudformation 无法解析参数 - VolumeAttachment
Cloudformation fails to parse parameters - VolumeAttachment
我正在尝试实施一个 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"
我怀疑参数类型中的 List 是罪魁祸首,但我没有找到其他方法让用户可以从可用 instances/EBS 中进行选择(除了静态列表)。
我们将不胜感激。
如果您的用户select 只有一个实例和卷(如果没有自定义资源或宏就无法循环多个选择),那么它应该是:
Resources:
MountPoint:
Type: "AWS::EC2::VolumeAttachment"
Properties:
Device: /dev/sdh
InstanceId: !Select [0, !Ref InstanceIdToMount]
VolumeId: !Select [0, !Ref EBSVolumeID]
看起来 AWS::EC2::Instance::Id
和 AWS::EC2::Volume::Id
是 supported 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
我正在尝试实施一个 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"
我怀疑参数类型中的 List 是罪魁祸首,但我没有找到其他方法让用户可以从可用 instances/EBS 中进行选择(除了静态列表)。
我们将不胜感激。
如果您的用户select 只有一个实例和卷(如果没有自定义资源或宏就无法循环多个选择),那么它应该是:
Resources:
MountPoint:
Type: "AWS::EC2::VolumeAttachment"
Properties:
Device: /dev/sdh
InstanceId: !Select [0, !Ref InstanceIdToMount]
VolumeId: !Select [0, !Ref EBSVolumeID]
看起来 AWS::EC2::Instance::Id
和 AWS::EC2::Volume::Id
是 supported 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