Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
brandon-burciaga opened this issue Jun 9, 2023 · 4 comments
Closed
Labels
area/local/start-api sam local start-api command

Comments

@brandon-burciaga
Copy link

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

@brandon-burciaga brandon-burciaga added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Jun 9, 2023
@lucashuy
Copy link
Contributor

lucashuy commented Jun 9, 2023

Hi, thanks for reporting this. Unfortunately, the message is incorrect, sam local start-api does not support invoking a deployed Lambda function when it is referenced with the ARN in the properties like this. The function would have to exist and be defined locally in your template for SAM CLI to find it.

We'll update the message to correctly reflect this.

@lucashuy lucashuy added the area/local/start-api sam local start-api command label Jun 9, 2023
@mildaniel mildaniel removed the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Jun 9, 2023
@brandon-burciaga
Copy link
Author

@lucashuy thanks for the comment. Do you think this functionality would be something on the roadmap in the future?

@lucashuy
Copy link
Contributor

Unfortunately I don't have an answer as to whether or not Lambda Authorizers with ARN references to remotely defined Lambda authorizers will be able to be invoked in the future. Should anything change, our roadmap will reflect that.

@github-actions
Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/local/start-api sam local start-api command
Projects
None yet
Development

No branches or pull requests

3 participants