0

部署此模板时出现“内部转换”错误。我使用映射来转换开发和产品设置。这适用于单个值,但 cloudformation 在尝试转换事件配置时感到窒息。这通过aws cloudformation validate-template了我的配置有什么问题?:

我使用映射来转换开发和产品设置。这适用于单个值,但 SAM 在尝试转换事件配置时感到窒息,我的配置有什么问题?:

AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'

Parameters:
  env:
    Description: Config map for transforming template with dev or prod values
    Type: String
    Default: dev

# Template uses !FindInMap along with env parameter to reference dev or prod values defined here
Mappings:
  ConfigMap:
    dev:
      awsAccount: 'dev'
      configFile: 'dev_config.yaml'
      cloudwatchEvents: !Ref "AWS::NoValue"
    prod:
      awsAccount: 'prod'
      configFile: 'prod_config.yaml'
      cloudwatchEvents:
        Schedule1:
          Type: Schedule
          Properties:
            Schedule: rate(3 minutes)

Resources:
  myfunction:
    Type: 'AWS::Serverless::Function'
    Properties:
      CodeUri: ../build
      Handler: lambda_function.lambda_handler
      Runtime: python3.6
      MemorySize: 128
      Timeout: 30
      Events:
        !FindInMap
            - ConfigMap
            - !Ref env
            - cloudwatchEvents

      Environment:
        Variables:
          config_file: !FindInMap
            - ConfigMap
            - !Ref env
            - configFile

      Tags:
        account: !FindInMap
          - ConfigMap
          - !Ref env
          - awsAccount
        blah: derp
4

1 回答 1

0

Looks like you have a typo after !FindInMap, you are missing a colon after that. It should be !FindInMap:

于 2018-11-20T18:33:59.820 回答