Skip to content

Bug: can't use deployed/remote authorizer with sam local start-api #5313

@brandon-burciaga

Description

@brandon-burciaga

Description:

I know using a local authorizer was released in I think version 1.80.0, which is great. However, I want to be able to use an already deployed authorizer while running sam local start-api. This authorizer is in it's own repo and is brought into other SAM repos like this, using it's ARN:

Example template:

Resources:
  BaseApi:
    Type: AWS::Serverless::Api
    Properties:
      Auth:
        DefaultAuthorizer: MyAuth
        AddDefaultAuthorizerToCorsPreflight: false
        Authorizers:
          MyAuth:
            FunctionPayloadType: REQUEST
            FunctionArn: !Sub 'arn:aws:lambda:us-east-1:123123123123:function:my-jwt-authorizer-${Env}'
            Identity:
              ReauthorizeEvery: 0

This does not work, and the error output can be seen below.

Steps to reproduce:

  1. Deploy an authorizer to AWS in it's own repository
  2. Attempt to use that authorizer in another repo template.yml by using it's FunctionARN.
  3. Run sam local start-api
  4. Call a function
  5. See the error output above

Observed result:

sam     my-jwt-authorizer-dev not found. Possible options in your template: [...]

sam    Failed to find a Function to invoke a Lambda authorizer, verify that this Function exists locally if it is not a remote resource.                                                                                                sam    | Lambda authorizer failed to invoke successfully: FunctionNotFound 

Expected result:

The deployed authorizer to be referenced correctly by it's ARN and ran before running the local Lambda function.

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS:
  2. sam --version:
  3. AWS region:
# Paste the output of `sam --info` here
 "version": "1.86.1",                                                                                                 
"system": {
    "python": "3.11.3",
    "os": "Linux-5.10.16.3-microsoft-standard-WSL2-x86_64-with-glibc2.31"                                              },                                                                                                                   "additional_dependencies": {                                                                                           "docker_engine": "23.0.3",                                                                                           "aws_cdk": "2.69.0 (build 60a5b2a)",                                                                                 "terraform": "1.3.3"                                                                                               },                                                                                                                   "available_beta_feature_env_vars": [                                                                                   "SAM_CLI_BETA_FEATURES",                                                                                             "SAM_CLI_BETA_BUILD_PERFORMANCE",                                                                                    "SAM_CLI_BETA_TERRAFORM_SUPPORT",                                                                                    "SAM_CLI_BETA_RUST_CARGO_LAMBDA"                                                                                   ]                                                                                                                  }  

Add --debug flag to command you are running

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions