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

Getting ValueError: Function name is required when running API Gateway from Terraform #7236

Closed
sevetseh28 opened this issue Jul 9, 2024 · 5 comments
Labels
area/local stage/waiting-for-release Fix has been merged to develop and is waiting for a release type/bug

Comments

@sevetseh28
Copy link

sevetseh28 commented Jul 9, 2024

Hi everyone. I'm running my API Gateway locally with:

sam local start-api --hook-name terraform --disable-authorizer

The API Gateway starts without issues ,but when hitting any endpoint I get the following:

Traceback (most recent call last):                                                                                                     
  File "flask/app.py", line 1473, in wsgi_app                                                                                          
  File "flask/app.py", line 882, in full_dispatch_request                                                                              
  File "flask/app.py", line 880, in full_dispatch_request                                                                              
  File "flask/app.py", line 865, in dispatch_request                                                                                   
  File "samcli/local/apigw/local_apigw_service.py", line 725, in _request_handler                                                      
  File "samcli/local/apigw/local_apigw_service.py", line 618, in _invoke_lambda_function                                               
  File "samcli/commands/local/lib/local_lambda.py", line 118, in invoke                                                                
  File "samcli/lib/providers/sam_function_provider.py", line 122, in get                                                               
ValueError: Function name is required

I ran the above with and without the authoriser, but I've also tried running the authoriser individually with:
sam local invoke ModuleIdeApiAwsLambdaFunctionAuthorizerFunction836CD508 --hook-name terraform --skip-prepare-infra --event authoriser-event.json

and it works well when running the Lambda function alone. Any ideas what could be wrong?

Thank you!

@sevetseh28 sevetseh28 added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Jul 9, 2024
@sevetseh28 sevetseh28 changed the title Getting ValueError: Function name is required Getting ValueError: Function name is required when running API Gateway from Terraform Jul 9, 2024
@sevetseh28
Copy link
Author

BTW the endpoint im calling is using an AWS Integration (for example, to start execution of a State machine). I guess this might be why, as it's trying to invoke a lambda function for this integration. Is there any way I can mock it?

@lucashuy
Copy link
Contributor

Can you provide a sample project for us to reproduce this issue? The bounds of what we support with sam local is limited, and we may not support your use case (ie. APIGW integration with a state machine), but we'll be able to help further with a project.

@lucashuy lucashuy added blocked/more-info-needed More info is needed from the requester. If no response in 14 days, it will become stale. area/local area/terraform terraform support issue and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Jul 10, 2024
@sevetseh28
Copy link
Author

sevetseh28 commented Jul 11, 2024

hey @lucashuy thanks for your reply. I ended up changing my integration type to Lambda proxy integration for more flexibility and endpoint customisation.
I was initially using Step Functions integration but sam doesn't seem to support it, I read the source code here.
I thought that the SAM tool would mimic the Integration through a Lambda function locally

@lucashuy
Copy link
Contributor

lucashuy commented Jul 12, 2024

Our support for Lambda invocations locally is limited to directly invoking the Lambda (through sam local invoke and sam local start-lambda), and with the API Gateway Lambda integrations (using sam local start-api).

Unfortunately we don't support the local invocations of Lambda through other integration means with API Gateway.

The AWS Step Functions team created a tool to use together with SAM CLI to help test Step Functions locally and requires a little bit of setup to use. This can be an alternative to using SAM CLI as an "all-in-one" solution.
https://docs.aws.amazon.com/step-functions/latest/dg/sfn-local-lambda.html

I'm going to leave this issue open for now as the only item for our team to take from this issue is that we probably should fix that method that returns a ValueError, to return our own error instead of reusing the built-in exception.

@lucashuy lucashuy added type/bug and removed blocked/more-info-needed More info is needed from the requester. If no response in 14 days, it will become stale. area/terraform terraform support issue labels Jul 12, 2024
@mildaniel mildaniel added the stage/waiting-for-release Fix has been merged to develop and is waiting for a release label Aug 21, 2024
Copy link
Contributor

Patch is released in v1.124.0. Closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/local stage/waiting-for-release Fix has been merged to develop and is waiting for a release type/bug
Projects
None yet
Development

No branches or pull requests

3 participants