'AWS APIGateway works on Test, but returns Missing Authentication on actual call

I have a simple API that I'm creating using AWS SAM, and Lambda functions.

There are 2 methods:

  • /helloWorld (This one returns helloWorld)
  • /hello (This one returns hello <name passed as query parameter>)

/helloWorld works, /hello works when using Test under AWS' APIGateway console: Call working at Console's test

But when I call the same thing from curl or Postman I get: POSTMAN not working

template.yml:

Resources:
  HelloWorldAPI:
    Type: AWS::Serverless::Api
    Properties: 
      Name: HelloWorldApi
      StageName: !Ref StageName

  HelloWorldAPIResource:
    Type: AWS::ApiGateway::Resource
    Properties:
      RestApiId: !Ref HelloWorldAPI
      ParentId: !GetAtt HelloWorldAPI.RootResourceId
      PathPart: hello

  HelloNameAPIMethod:
    Type: AWS::ApiGateway::Method
    Properties:
      AuthorizationType: NONE
      HttpMethod: GET
      ResourceId: !Ref HelloWorldAPIResource
      RestApiId: !Ref HelloWorldAPI
      Integration:
        Type: AWS_PROXY
        IntegrationHttpMethod: POST
        Uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HelloNameFunction.Arn}/invocations

  HelloWorldFunction:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: helloWorldGolang
      CodeUri: hello-world/
      Handler: hello-world
      Events: 
        ApiEvent:
          Type: Api
          Properties:
            Method: GET
            Path: /helloWorld
            RestApiId: !Ref HelloWorldAPI
              # Ref: MyApi

  HelloNameFunction:
    Type: AWS::Serverless::Function
    Properties:
      FunctionName: helloName
      CodeUri: hello-name/
      Handler: hello-name

  HelloNameFunctionPermission:
    Type: AWS::Lambda::Permission
    Properties:
      FunctionName: !GetAtt HelloNameFunction.Arn
      Action: lambda:InvokeFunction
      Principal: apigateway.amazonaws.com
      SourceArn: !Join
        - ''
        - - 'arn:'
          - !Ref 'AWS::Partition'
          - ':execute-api:'
          - !Ref 'AWS::Region'
          - ':'
          - !Ref 'AWS::AccountId'
          - ':'
          - !Ref HelloWorldAPI
          - /*/*/*

This might sound weird, but I swear it was working 5 minutes ago. I know because I committed when it did.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source