Issue with Blueprint and Pure Lambda Functions
See original GitHub issueI am using Blueprint for API endpoints and Pure lambda functions. I am able to successfully register my endpoints and hit them, but the lambda functions that interact with these endpoints are not being registered because I get an error message that says this:
"errorMessage": "Handler 'function_name' missing on module 'app'","errorType": "Runtime.HandlerNotFound"
In the chalicelib directory, I have:
__init__.py
api_endpoints.py
pure_lambdas.py
The app.py is setup like this:
from chalicelib.api_endpoints import api_endpoints
from chalicelib.pure_lambdas import pure_lambdas
app = Chalice(app_name='app-name')
app.experimental_feature_flags.update(['BLUEPRINTS'])
app.register_blueprint(api_endpoints)
app.register_blueprint(pure_lambdas)
The pure_lambdas.py is setup like this:
pure_lambdas = Blueprint(__name__)
@pure_lambdas.lambda_function(name='NAME')
def function_name(event, context):
[code]
@pure_lambdas.lambda_function(name='NAME1')
def function_name1(event, context):
[code]
When I keep the lambda functions within app.py, everything runs properly. I just can’t get it to work when I use Blueprint.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Pure Lambda Functions — AWS Chalice
An API handler that coordinates with API Gateway for creating rest APIs. A custom authorizer that allows you to integrate custom auth logic...
Read more >Lambda features - AWS Documentation
A blueprint provides sample code that shows how to use Lambda with an AWS service or a popular third-party application. Blueprints include sample...
Read more >Getting started with Chalice to create AWS Lambdas in Python
In this post, we'll see how we can install Chalice on our local machines, write a simple REST API to return the famous...
Read more >Python Chalice Pure Lambda Function - reference name in ...
In a chalice application, you will have multiple stages: prod/dev/test. Lambda names are really predictable and they do not change.
Read more >Build and Deploy Python Flask APIs in AWS Lambda via CDK
(2.4) lambda/app/api/__init__.py. This defines the api blueprint and imports the files necessary for the blueprint to function. We only need to ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@madhavmehta1 I used the same app.py you had in your original comment. For completeness this is the app.py file:
My
api_endpoints.py
andpure_lambdas.py
are exactly what was shown in my previous comment.@rajpdus The documentation says the concept is extended to ALL Chalice resources:
Note The Chalice blueprints are conceptually similar to Blueprints in Flask. Flask blueprints allow you to define a set of URL routes separately from the main Flask object. This concept is extended to all resources in Chalice. A Chalice blueprint can have Lambda functions, event handlers, built-in authorizers, etc. in addition to a collection of routes.