from stelvio.aws.dynamo import Table, AttributeType
from stelvio.aws.api_gateway import Api
# Create DynamoDB table and Lambda
table = Table(
name="todos",
fields={"todo_id": AttributeType.STRING},
partition_key="todo_id",
)
api = Api("todos-api")
api.route("POST", "/todos", "functions/todos.create", links=table)
api.route("GET", "/todos", "functions/todos.list")
api.deploy()
# That's it. Lambdas, IAM roles and policies handled automatically.
# Project structure:
# todos_project/
# ├── stlv_app.py
# └── functions/
# ├── requirements.txt
# └── todos.py