question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue with Blueprint and Pure Lambda Functions

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jameslscommented, Jul 16, 2020

@madhavmehta1 I used the same app.py you had in your original comment. For completeness this is the app.py file:

$ tree
.
├── app.py
├── chalicelib
│   ├── __init__.py
│   ├── api_endpoints.py
│   └── pure_lambdas.py
└── requirements.txt
$ cat app.py
from chalice import Chalice
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)

My api_endpoints.py and pure_lambdas.py are exactly what was shown in my previous comment.

1reaction
madhavmehta1commented, Jul 15, 2020

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found