aws / aws/chalice

Error using Chalice blueprints

Open
#1,713 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
11.1k
Forks
1k
Avg merge
1d 22h
Merged PRs (30d)
2

Description

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:
```python
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:
```python
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

Contributor guide

Open the contributing guide

Research direction

Start with app.py and chalicelib/s3_events.py, including chalicelib/__init__.py, then deploy the example and trigger the S3 event to reproduce the Runtime.ImportModuleError. Trace which module name Chalice packages and configures for the Lambda handler; done means the uploaded object invokes the blueprint handler without an import error.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python
Domain
cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.