【发布时间】:2021-02-01 14:21:49
【问题描述】:
我正在创建一个 AWS SAM 模板,并希望使用映射来存储一些常用路径。 我的映射定义如下所示:
Mappings:
envs:
np:
vpcId: vpc-1412343432
prod:
vpcId: vpc-4123121323
paths:
example:
foo1: /{stage}/foo1/
foo2: /{stage}/foo2/
foo3: /{stage}/foo3/
后来在模板中,我有一个带有!findInMap的函数定义
myFunc:
Type: AWS::Serverless::Function
Properties:
Handler: index.myFunc
Role: !GetAtt myFunc.Arn
Events:
foo:
Type: HttpApi
Properties:
Path: !FindInMap [ paths, example, foo1 ]
Method: get
ApiId: !Ref fooApi
当我运行 sam deploy 时,它返回错误 Event with id [foo] is invalid. Api Event must have a String specified for 'Path'。看起来 findInMap 返回空值。你知道我做错了什么吗?
【问题讨论】:
-
作为快速检查,如果您在
path中硬编码/{stage}/foo1/,而不是使用FindInMap,它是否有效?
标签: amazon-cloudformation aws-sam