組み込み関数 Fn::And は AND 演算子を表し、少なくとも 2 つの条件を含める必要があります。指定されたすべての条件が true と評価された場合、true が返されます。条件が false と評価された場合、false が返されます。
宣言
JSON
{ "Fn::And": [ "condition1", // 条件1 "condition2", // 条件2 ... ] }YAML
完全な関数名の構文:
Fn::And: - condition1 // 条件1 - condition2 // 条件2 - ...短縮形の構文:
!And [condition1, condition2, ...]
パラメーター
condition: 評価する条件。
戻り値
true または false。
例
Fn::And を使用して、Conditions セクションまたは Rules セクションのみで条件を定義できます。
ROSTemplateFormatVersion: '2015-09-01'
Parameters:
EnvType:
Default: pre
Type: String
Conditions:
TestEqualsCond:
!Equals
- prod
- !Ref EnvType
TestAndCond:
!And
- TestEqualsCond
- !Equals
- pre
- !Ref EnvType{
"Parameters": {
"EnvType": {
"Default": "pre",
"Type": "String"
}
},
"Conditions": {
"TestEqualsCond": {
"Fn::Equals": [
"prod",
{"Ref": "EnvType"}
]
},
"TestAndCond": {
"Fn::And": [
"TestEqualsCond",
{
"Fn::Equals": [
"pre",
{"Ref": "EnvType"}
]
}
]
}
}
}