Comments (5)
hey @kbakk thank you so much for that. Now that Powertools has a Router functionality, @michaelbrewer and I have been discussing revamping this with two options: Monolithic and Micro function - both with shared and Lambda Layer (build optimization + dev dependency).
The monolithic option would take an hour to add since we already have a good project structure that works in both PyCharm and VSCode. The latter requires an additional CLI (e.g. PyInvoke) to support building separate functions while supporting relative and absolute imports, since SAM CLI discards the top level directory - the latter also needs additional cycles to ensure C bindings are built within a Docker Container.
from cookiecutter-aws-sam-python.
A few examples on things I find difficult which I think can help others:
- Multiple Lambda functions (could be an idea to show how to use two different functions in the same module, as well as two completely standalone modules)
- Some shared library that all functions uses (showcasing layers)
- Lambda function with additional modules (in app.py e.g.
from my_module import my_func
)
from cookiecutter-aws-sam-python.
You may want to look into Poetry. I'm experimenting with this currently:
[tool.poetry]
# ...
packages = [
{ include = "my_app_dir", from = "functions/my_app_dir" },
{ include = "tests" }
]
This creates a .pth
in the site-packages
folder, I believe this is similar to modifying PYTHONPATH
(for the local dev-environment).
cat $(poetry env info -p)/lib/python3.9/site-packages/my_project.pth
~/Code/my_project
~/Code/my_project/functions/my_app_dir
My handler is in functions/my_app_dir/my_app_dir/lambda_handler
. The double-dir is to be able to say import my_app_dir.sub_module
in the Lambda handler.
MyLogicFn:
Type: AWS::Serverless::Function
Properties:
CodeUri: functions/my_app_dir
Handler: my_app_dir.lambda_handler.create_asset
from cookiecutter-aws-sam-python.
from cookiecutter-aws-sam-python.
Hi @heitorlessa, do you have any update on this? I'd like to see both approaches you described at your comments...
hey @kbakk thank you so much for that. Now that Powertools has a Router functionality, @michaelbrewer and I have been discussing revamping this with two options: Monolithic and Micro function - both with shared and Lambda Layer (build optimization + dev dependency).
The monolithic option would take an hour to add since we already have a good project structure that works in both PyCharm and VSCode. The latter requires an additional CLI (e.g. PyInvoke) to support building separate functions while supporting relative and absolute imports, since SAM CLI discards the top level directory - the latter also needs additional cycles to ensure C bindings are built within a Docker Container.
from cookiecutter-aws-sam-python.
Related Issues (20)
- Pipenv installing deps on system packages HOT 2
- Unable to import module 'app' HOT 6
- User's umask overrides permissions for sam initialized project HOT 3
- Add support for sam invoke to Makefile HOT 1
- make test results in no module named pytest HOT 4
- Add DOCKER flag to make build HOT 3
- Upgrade Requests library
- Update instructions to use sam build HOT 10
- `make package` fails due to `ln` on macOS HOT 4
- Update project to target latest stable: Python 3.8
- Rebuild project with latest SAM build, and Lambda powertools HOT 2
- Fix up bootstrapping and update tests HOT 1
- Create functional cookiecutter tests
- Exemplify multiple files
- Apply opinionated style & conventions
- Use the new Powertools API Gateway event handler
- Template generation might fail if python environment is not setup correctly HOT 1
- `sam init` fails to deploy `gh:aws-samples/cookiecutter-aws-sam-python` on Windows platform HOT 1
- [Discussion] Convert Makefile into a Python script HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cookiecutter-aws-sam-python.