aws cloudformation 中的映射。 Fn::FindInMap对象需要三个参数

Mappings in aws cloudformation. Fn::FindInMap object requires three parameters

我有映射部分:

Mappings:
  ScheduledPeriodMap:
    Development:
      "Expression": "cron(0 12 30 2 ? *)"
    Production:
      "Expression": "rate(1 minute)"

后来我用了:

Events:
  ScheduleMyLambda:
    Type: Schedule
    Properties:
      Schedule: !FindInMap [ScheduledPeriodMap, !Sub "${Environment}", "Expression"]

我在 cloudformation deploy 期间遇到异常:

Waiter encountered a terminal failure state Status: FAILED. Reason: Template error: every Fn::FindInMap object requires three parameters, the map name, map key and the attribute for return value

怎么了?

Fn::FindInMap documentation中写着:

Supported Functions You can use the following functions in a Fn::FindInMap function:

Fn::FindInMap

Ref

表示这里不能用!Sub "${Environment}",请用!Ref Environment代替。