Skip to content

Bug: Trailing slashes in the paths in the Events type cause errors #665

@sthulb

Description

@sthulb

Description:

Given the following template:

  Func: 
    Type: AWS::Serverless::Function
    Properties:
      Handler: bar.handler
      Events:
        HTTP:
          Type: Api
          Properties:
            Path: /bar/
            Method: GET

When calling the /bar/ endpoint in the API Gateway, it will always error with a message of:

Thu Nov 15 15:22:53 UTC 2018 : Execution failed due to configuration error: Invalid permissions on Lambda function

I've deployed the template with and WITHOUT the trailing slash on the path, the template without works.

To add further info, using aws lambda get-policy --function-name ... to get the policies of both versions, they're identical.

WITH:

{
    "Policy": "{\"Version\":\"2012-10-17\",\"Id\":\"default\",\"Statement\":[{\"Sid\":\"test-FuncBHTTPPermissionTest-QA18Q84KEKFR\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"apigateway.amazonaws.com\"},\"Action\":\"lambda:invokeFunction\",\"Resource\":\"arn:aws:lambda:eu-west-1:1234567890:function:test-FuncB-1X4GNWC7MCTBL\",\"Condition\":{\"ArnLike\":{\"AWS:SourceArn\":\"arn:aws:execute-api:eu-west-1:1234567890:5v9ewolbwc/*/*/bar\"}}},{\"Sid\":\"test-FuncBHTTPPermissionProd-1I13SM8SHZ1I\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"apigateway.amazonaws.com\"},\"Action\":\"lambda:invokeFunction\",\"Resource\":\"arn:aws:lambda:eu-west-1:1234567890:function:test-FuncB-1X4GNWC7MCTBL\",\"Condition\":{\"ArnLike\":{\"AWS:SourceArn\":\"arn:aws:execute-api:eu-west-1:777977323905:5v9ewolbwc/Prod/*/bar\"}}}]}",
    "RevisionId": "018fad31-a77e-4bf2-97cd-2066f7313216"
}

WITHOUT:

{
    "Policy": "{\"Version\":\"2012-10-17\",\"Id\":\"default\",\"Statement\":[{\"Sid\":\"test-FuncBHTTPPermissionTest-QA18Q84KEKFR\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"apigateway.amazonaws.com\"},\"Action\":\"lambda:invokeFunction\",\"Resource\":\"arn:aws:lambda:eu-west-1:1234567890:function:test-FuncB-1X4GNWC7MCTBL\",\"Condition\":{\"ArnLike\":{\"AWS:SourceArn\":\"arn:aws:execute-api:eu-west-1:777977323905:5v9ewolbwc/*/*/bar\"}}},{\"Sid\":\"test-FuncBHTTPPermissionProd-1I13SM8SHZ1I\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"apigateway.amazonaws.com\"},\"Action\":\"lambda:invokeFunction\",\"Resource\":\"arn:aws:lambda:eu-west-1:1234567890:function:test-FuncB-1X4GNWC7MCTBL\",\"Condition\":{\"ArnLike\":{\"AWS:SourceArn\":\"arn:aws:execute-api:eu-west-1:1234567890:5v9ewolbwc/Prod/*/bar\"}}}]}",
    "RevisionId": "5872c240-7b82-4d73-8e2e-f11353a40145"
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions