gpt4 book ai didi

amazon-web-services - 添加从自定义资源获取属性的条件

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

我有一个用于创建 EBS 卷的 CFT。然后我有第二个 CFT 将卷附加到实例。我使用运行 lambda 的自定义资源来查找 EbsVolumeId 和 InstanceId

这 2 个 CFT 是 jenkins 管道的一部分,使用 CFT 创建 EBS 卷的 playbook 可能会被跳过,因此没有 EbsVolumeId 可供引用。

因此,在附加 EBS 卷的 CFT 中,我尝试添加一个条件

Resources:
MountPoint:
Type: AWS::EC2::VolumeAttachment
Condition: AttachEBS
Properties:
InstanceId: !GetAtt SCSHelper.InstanceId
VolumeId: !GetAtt SCSHelper.EbsVolumeId

自定义资源看起来像

SCSHelper:
Type: Custom::SCSHelper

所以我必须在资源之前定义条件:

Conditions:
AttachEBS: !Not [!Equals http:// !GetAtt SCSHelper.EbsVolumeId , None ]

问题是条件失败了:

An error occurred (ValidationError) when calling the CreateStack operation: Template format error: Unresolved dependencies https://forums.aws.amazon.com/. Cannot reference resources in the Conditions block of the template An error occurred (ValidationError) when calling the CreateStack operation: Template format error: Unresolved dependencies https://forums.aws.amazon.com/.

因此,SCSHelper.EbsVolumeId 属性似乎不可用于要使用的条件。

是否有一种方法可以实现此目的,或者是否有更好的方法来有条件地运行附加 EBS 卷的 CFT?

提前致谢...

最佳答案

Conditions的重要部分文档是这个

Parameters

Define the input values that you want to evaluate in your conditions. Conditions will result in true or false based on values from these input parameters.

CloudFormation 中的条件可以仅基于参数。它们无法考虑运行中的资源值,因为这些值在编译时未知。

关于amazon-web-services - 添加从自定义资源获取属性的条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51951217/

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