Error using Chalice blueprints
Hi,
I'm working on a project with Chalice and I have an error when I'm using Blueprints that I don't really understand.
My project is organised like that:
- my project
- chalicelib
- s3_events.py
- __init__.py
- app.py
I created an s3_events file to use blueprint like that:
from chalice import Blueprint
s3_event_blueprints = Blueprint(__name__)
@s3_event_blueprints.on_s3_event(bucket="test-bucket", events=["s3:ObjectCreated:*"]")
def handle_object_created(event):
pass
And in my app.py it's like that:
from chalice import Chalice
from chalicelib.s3_events import s3_event_blueprints
app = Chalice(app_name="panenkapi")
app.register_blueprint(s3_event_blueprints)
Then, when I deploy I don't have error, but when I upload a file the lambs function is triggered and I get the following error :
[ERROR] Runtime.ImportModuleError: Unable to import module 's3_event_blueprints': No module named 's3_event_blueprints'
I saw this issue : https://github.com/aws/chalice/issues/1680 but I already have an __init__.py file in chalicelib..
Did I do something wrong with blueprints or is it an issue ? How can I solve this ?
Thank you for your help,
Maxime
You have to define your s3_event_blueprints variable inside s3_events.py such as:
s3_event_blueprints = Blueprint(__name__)
and in app.py
app = Chalice(app_name='your-api')
app.register_blueprint(s3_event_blueprints, url_prefix='/your-s3-api')