单个 Cloudformation 资源上的多个条件

Multiple conditions on a single Cloudformation resource

如何为一个资源添加多个条件?

资源需要满足多个条件才能生成。在资源的 Condition: 属性中提到。

Instrinsic function conditions

您需要用逗号分隔您的条件。从这个 doc:

If you have multiple conditions, separate them with commas.

条件 And 函数的示例可以在 this doc:

中找到
"MyAndCondition": {
   "Fn::And": [
      {"Fn::Equals": ["sg-mysggroup", {"Ref": "ASecurityGroup"}]},
      {"Condition": "SomeOtherCondition"}
   ]
}

使用 And 函数应该允许您定义资源必须满足的多个条件。