Deploy Python to AWS in minutes, not days

💥 Check out this insightful post from Hacker News 📖

📂 **Category**:

✅ **What You’ll Learn**:

Deploy Python functions to AWS Lambda. Link to other resources for automatic permissions.

from stelvio.aws.function import Function
from stelvio.aws.s3 import Bucket

bucket = Bucket("reports")

# Link grants permissions automatically
Function(
    "processor",
    handler="functions/process.handler",
    links=[bucket],
)

Learn more about Lambda functions →

Schedule Lambda functions with cron expressions or rate intervals.

from stelvio.aws.cron import Cron

Cron(
    "hourly-cleanup",
    "rate(1 hour)",
    "functions/cleanup.handler",
)
Cron(
    "daily-report",
    "cron(0 9 * * ? *)",
    "functions/report.handler",
)

Learn more about Event scheduling →

Securely store any amount of data with AWS S3 Buckets.

from stelvio.aws.s3 import Bucket

# Create a bucket that triggers a function on new uploads
uploads = Bucket("user-uploads")
uploads.notify(
    "functions/process_upload.handler",
    events=["s3:ObjectCreated:*"],
)

Learn more about S3 Buckets →

Create DynamoDB tables and link them to functions for automatic permissions.

from stelvio.aws.dynamo_db import DynamoTable
from stelvio.aws.function import Function

table = DynamoTable(
    name="users",
    partition_key="user_id",
    sort_key="created_at",
)

Function(
    "user-handler",
    handler="functions/user.handler",
    links=[table],
)

Learn more about DynamoDB →

Decouple services with SQS queues and SNS topics.

from stelvio.aws.queue import Queue
from stelvio.aws.topic import Topic

orders = Queue("orders")
orders.subscribe(
    "processor",
    "functions/process_order.handler",
)

alerts = Topic("alerts")
alerts.subscribe(
    "notifier",
    "functions/send_alert.handler",
)

Learn more about SQS Queues & SNS Topics →

Send high-volume emails securely and reliably using Amazon SES.

from stelvio.aws.email import Email
from stelvio.aws.function import Function

mailer = Email(
    "support-email",
    "support@example.com",
)

Function(
    "sender",
    handler="functions/send.handler",
    links=[mailer],
)

Learn more about Email →

Define REST APIs and route requests to Lambda functions or other resources.

from stelvio.aws.apigateway import Api

api = Api(
    "payment-api",
    domain_name="api.example.com",
)

api.route("POST", "/charge", handler="functions/charge.post")
api.route("GET", "/history", handler="functions/history.get")

Learn more about API Gateway →

Connect your Stelvio resources to custom domains with automatic SSL certificates.

app = StelvioApp(
    "my-app",
    dns=CloudflareDns("your-cloudflare-zone-id")
    # other configurations...
)

...

api = Api(
    "payment-api",
    domain_name="api.example.com",
)

api.route("POST", "/charge", handler="functions/charge.post")
api.route("GET", "/history", handler="functions/history.get")

Learn more about Custom Domains →

Combine multiple Stelvio resources under the same custom domain using a Router.

domain_name = "example.com"

bucket = Bucket("static-files-bucket")

api = Api("my-api")
api.route("GET", "/api", "functions/hello.handler")

router = Router("router-example", custom_domain=domain_name)
router.route("/files", bucket)
router.route("/api", api)

Learn more about Router →

💬 **What’s your take?**
Share your thoughts in the comments below!

#️⃣ **#Deploy #Python #AWS #minutes #days**

🕒 **Posted on**: 1770052989

🌟 **Want more?** Click here for more info! 🌟

By

Leave a Reply

Your email address will not be published. Required fields are marked *