【问题标题】:Template format error: Every Mappings attribute must be a String or a List模板格式错误:每个映射属性必须是字符串或列表
【发布时间】:2020-02-16 05:57:12
【问题描述】:

我想在我的 CloudFormation 模板顶部有一些快速参考,这样我就不必每次在整个模板中需要它时都写出复杂的参考。

所以我写了这个:

Mappings:
  StandardResourcesMap:
    AWSExecuteApi:
      string: !Join [ ':' , ['arn', !Sub '${AWS::Partition}', 'execute-api', !Sub '${AWS::Region}', !Sub '${AWS::AccountId}'] ]
    AWSLambdaFunctions:
      string: !Join [ ':' , ['arn', !Sub '${AWS::Partition}', 'apigateway', !Sub '${AWS::Region}', 'lambda:path/2015-03-31/functions/'] ]

CloudFormation 模板的其余部分遵循这一点,并且,如果没有上述行,模板将部署(一个 S3 存储桶、DynamoDB 表和一个基于 python 3.7 的 Lambda)。

希望我可以使用:

!FindInMap [StandardResourcesMap,AWSExecuteApi,string]

每当我需要冗长的值时,模板验证失败:

An error occurred (ValidationError) when calling the CreateChangeSet operation: Template format error: Every Mappings attribute must be a String or a List.

正如标题所说。

我尝试了Mappings 的多种变体,例如使用!Ref 变体:

Mappings:
  StandardResourcesMap:
    AWSExecuteApi:
      string: !Join [ ':' , ['arn', !Ref 'AWS::Partition', 'execute-api', !Ref 'AWS::Region', !Ref 'AWS::AccountId'] ]
    AWSLambdaFunctions:
      string: !Join [ ':' , ['arn', !Ref 'AWS::Partition', 'apigateway', !Ref 'AWS::Region', 'lambda:path/2015-03-31/functions/'] ]

我只是被各种验证错误所吸引,集中在上面提到的那个。

任何帮助将不胜感激。

【问题讨论】:

标签: amazon-web-services amazon-cloudformation


【解决方案1】:

问题是这样的:You cannot include parameters, pseudo parameters, or intrinsic functions in the Mappings section.Mappings

【讨论】:

  • 啊哈! - 而已!非常感谢。两件事:(1)可怕的错误信息 - 它当然没有表明问题所在。 (2) 我真的希望我可以存储引用链,这样我就不必到处重复这样的块了。知道有什么方法吗?
猜你喜欢
  • 2016-03-21
  • 2017-02-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-23
  • 2020-03-25
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多