serverless-application-model icon indicating copy to clipboard operation
serverless-application-model copied to clipboard

Sam Doesn't Create the second api

Open ahmadsn26 opened this issue 9 years ago • 1 comments

Hello.

i have created my sam following the code from examples and it work for one api. but as soon as i create the other method that one is not created and when i look at the template that is being parsed the other function is not even parsed.

Here is my sam

` ---
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: AWS SAM template with API defined in an external Swagger file along with Lambda integrations and CORS configurations
Resources:
  ServiceStatusFunctionApi:
    Type: AWS::Serverless::Api
    Properties:
      DefinitionUri: swagger.yml
      StageName: Prod
      Variables:
        # NOTE: Before using this template, replace the <<region>> and <<account>> fields
        #       in Lambda integration URI in the swagger file to region and accountId
        #       you are deploying to
        LambdaFunctionName: !Ref ServiceStatusFunction

  ServiceStatusFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: ./
      Handler: index.serviceStatus
      Runtime: nodejs4.3
      Events:
        ProxyApiRoot:
          Type: Api
          Properties:
            RestApiId: !Ref ServiceStatusFunctionApi
            Path: /service/status
            Method: GET
      #       
      # Create Card Api
      #
    CreateMemberShipCardFunctionApi:
      Type: AWS::Serverless::Api
      Properties:
        DefinitionUri: swagger.yml
        StageName: Prod
        Variables:
          LambdaFunctionName: !Ref CreateMemberShipCardFunction
      #
      # Create Card Lambda Function
      #
    CreateMemberShipCardFunction:
      Type: AWS::Serverless::Function
      Properties:
        CodeUri: ./
        Handler: index.createMemberShipCard
        Runtime: nodejs4.3
        Events:
          ProxyApiRoot:
            Type: Api
            Properties:
              RestApiId: !Ref CreateMemberShipCardFunctionApi
              Path: /comp/membershipcard
              Method: POST 
`

If i dont have to enable cors it works just fine with old styling but with the example given for enabling cors via swagger i am getting some errors.

Please guide me if i am doing something wrong with my sam so that i can get this working

P.S if this is not the correct platform my apologies i am unable to find anything at all on sof or in examples regarding my problem

ahmadsn26 avatar Jun 26 '17 21:06 ahmadsn26

You have an indentation bug. CreateMemberShipCardFunctionApi is must be at same level of indentation as ServiceStatusFunction. Not a SAM issue.

sanathkr avatar Jun 28 '17 08:06 sanathkr