I don't think the problem is with !FindInMap
. I quickly validated it using following addition to my template.
Outputs:
MaverickOutput:
Value: !FindInMap [ paths, example, foo1 ]
The value (/{stage}/foo1/
) was reflected in the CloudFormation stack output post sam deploy
.
Coming to the reason why it did not work with the Api event. If you follow this link to official docs, you can see this.
The object describing an Api event source type. If an AWS::Serverless::Api resource is defined, the path and method values must correspond to an operation in the OpenAPI definition of the API.
This combined with the error (Api Event must have a String specified for 'Path'."
) that you are receiving, I think it is fair to assume that this resource does not accept references which will be resolved during deployment time.
PS:
I could not find any documentation to support my theory, but another fact which supports this is that the maps can also store numbers and there won't be any way to know what the final value is going to be until actual deployment takes place. Therefore, if deployment time references were allowed, you might actually refer to a number for the Path
value.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…