首页 > 解决方案 > Aws - Cloudformation - Fn::Equals Error , 条件只能是对参数和其他条件的布尔运算

问题描述

我正在尝试基于环境创建 ACL 并具有以下条件。

Global: 
Env: stage 
Region: us-west -1 

Conditions:
  IsStage:  Fn::Equals [!Ref "Env", "stage"]

Resources:

publicIngressVpc:
    Type: AWS::EC2::NetworkAclEntry
    Condition: IsStage
    Properties:
      NetworkAclId:
        Fn::ImportValue:
          !Sub ${VpcStack}-publicNetworkAclId
      RuleNumber: 150
      Protocol: -1 # tcp
      RuleAction: allow
      CidrBlock: Some VPC
      PortRange:
        From: 1024
        To: 65535

我收到以下错误:

Template format error: Conditions can only be boolean operations on parameters and other conditions

标签: conditional-statementsamazon-cloudformation

解决方案


试试这个:

Conditions:
  IsStage:  
    !Equals [ !Ref Env, 'stage' ]

推荐阅读