If using environment variables (Option 2), just press Enter when stlv init asks for profile name.
2. Create Project
If you can use uv but you can use anything.
# Create a new project
uvinitstelvio-app&&cdstelvio-app
# Install Stelvio
uvaddstelvio
# Initialize Stelvio project
uvrunstlvinit
# Create a new project
poetrynewstelvio-app&&cdstelvio-app
# Install Stelvio
poetryaddstelvio
# Initialize Stelvio project
poetryrunstlvinit
# Create a new project
mkdirstelvio-app&&cdstelvio-app
python-mvenv.venv&&source.venv/bin/activate
# Install Stelvio
pipinstallstelvio
# Initialize Stelvio project
stlvinit
The stlv init command will create stlv_app.py with your project configuration.
Simple project using Stelvio
Project structure
For this quickstart guide, we'll keep things simple and put our infrastructure
definitions in the main stlv_app.py file so our project structure will look
like this:
In Stelvio, you have complete flexibility in
how you organize your project and where your infrastructure files
are located.
Open stlv_app.py, it will look like this:
stlv_app.py
fromstelvio.appimportStelvioAppfromstelvio.configimportStelvioAppConfigapp=StelvioApp("stelvio-app")@app.configdefconfiguration(env:str)->StelvioAppConfig:returnStelvioAppConfig()# Uses default values/setting@app.rundefrun()->None:# Create your infra herepass
Define our infrastructure
We need to put our infrastructure definitions inside the @app.run function.
Let's create a simple API to create and list todos.
First, let's add the imports we need at the top of the file:
A Lambda function with code from functions/todos.py file with:
properly configured env vars containing table name and arn
generated routing code to properly route requests to proper functions
lambda integration between methods and lambda
IAM (roles, policies, etc.)
stage
deployment
log groups
Your ApiGateway will be available at https://<api-id>.execute-api.<region>.amazonaws.com/v1.
If you want to use a custom domain, please refer to the Api Gateway guide.
importjsonfromdatetimeimportdatetimeimportboto3fromboto3.dynamodb.conditionsimportKeyfromstlv_resourcesimportResourcesdynamodb=boto3.resource('dynamodb')table=dynamodb.Table(Resources.todos.table_name)defpost(event,context):# Parse the request bodybody=json.loads(event.get('body','{}'))# Create itemitem={'username':body.get('username'),'created':datetime.utcnow().isoformat(),'title':body.get('title'),'done':False}# Save to DynamoDBtable.put_item(Item=item)return{'statusCode':201,'body':json.dumps(item)}defget(event,context):# Get username from query parametersusername=event.get('pathParameters',{}).get('username')# Query DynamoDBresponse=table.query(KeyConditionExpression=Key('username').eq(username))return{'statusCode':200,'body':json.dumps({'todos':response['Items']})}
Preview our infrastructure
Now we're ready to deploy. First let's create our functions/todos.py file, then preview what will be created.
Create the functions directory and todos.py file with the Lambda code shown above.
But it has one side effect - when you run preview or deploy Stelvio will create stlv_resources.py which contains type safe
definitions of our lambda environment variables which we an use in our lambda code.
You can see it above in our lambda code:
fromstlv_resourcesimportResources# <--- importing Resources class from stlv_resources.py...table=dynamodb.Table(Resources.todos.table_name)## <--- getting our table's name
Deploy
Now let's deploy our infrastructure:
uvrunstlvdeploy
poetryrunstlvdeploy
stlvdeploy
Stelvio will create all your infrastructure with real-time progress indicators.
When deployment finishes, you'll see the outputs at the bottom:
In the outputs, look for api_todos-api_invoke_url - this contains the URL of your todos API.
Copy this URL to test your API.
Environments
By default, Stelvio deployed to your personal environment (using your username). All resources are automatically prefixed with your app name and environment, so you can safely deploy multiple projects and environments without naming conflicts.
Let's take a moment to appreciate what we've accomplished with just a few commands:
Set up a complete project with stlv init
Created a database (DynamoDB table)
Built serverless functions (AWS Lambda)
Deployed a REST API (API Gateway)
Deployed everything to AWS with stlv deploy
Most importantly, we did this while writing clean, maintainable Python code. No YAML files, no complex setup, no clicking through AWS consoles, and no infrastructure expertise required.
Stelvio handled all the complex AWS configuration automatically - IAM roles, permissions, networking, environment variables, and more.
That's it for this quickstart! We hope Stelvio makes your AWS development much simpler. Try building something and let us know your feedback on GitHub or team@stelvio.dev