Search code examples
amazon-web-serviceslambdayamlaws-cloudformation

Template format error: YAML not well-formed


I'm getting Template format error: YAML not well-formed on the final line of this resource but no idea where I'm going wrong.

  LambdaPermission:
    Type: AWS::Lambda::Permission
    Properties:
      Action: lambda:InvokeFunction
      FunctionName: !GetAtt LambdaFunction.Arn
      Principal: apigateway.amazonaws.com
      SourceArn: !Join
        - ''
        - - !Sub 'arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:'
          - Fn::ImportValue:
            !Sub ${ParentStack}-api
          - '/*'

Solution

  • There should be a tab after ImportValue.

      LambdaPermission:
        Type: AWS::Lambda::Permission
        Properties:
          Action: lambda:InvokeFunction
          FunctionName: !GetAtt LambdaFunction.Arn
          Principal: apigateway.amazonaws.com
          SourceArn: !Join
            - ''
            - - !Sub 'arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:'
              - Fn::ImportValue:
                  !Sub ${ParentStack}-api
              - '/*'