Show HN: Stelvio – 将 Python 部署到 AWS

发布: (2026年2月2日 GMT+8 23:12)
4 分钟阅读

Source: Hacker News

基础设施即 Python。不使用 YAML。智能默认。
完全控制。

开始部署 →

pip install stelvio

AWS Cloudflare Pulumi Python

部署 Python 函数到 AWS Lambda

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],
)

了解更多关于 Lambda 函数 →

调度 Lambda 函数

from stelvio.aws.cron import Cron

Cron(
    "hourly-cleanup",
    "rate(1 hour)",
    "functions/cleanup.handler",
)

Cron(
    "daily-report",
    "cron(0 9 * * ? *)",
    "functions/report.handler",
)

了解更多关于事件调度 →

使用 S3 存储桶安全存储数据

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:*"],
)

了解更多关于 S3 存储桶的信息 →

创建带自动权限的 DynamoDB 表

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],
)

了解更多关于 DynamoDB →

使用 SQS 队列和 SNS 主题解耦服务

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",
)

了解更多关于 SQS 队列 →
了解更多关于 SNS 主题 →

使用 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],
)

了解更多关于 Email →

用 API Gateway 定义 REST API

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")

了解更多关于 API Gateway 的信息 →

将资源连接到自定义域名(自动 SSL)

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

使用 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)

了解更多关于 Router →

准备好将 Python 部署到 AWS 吗?
使用 Stelvio 开始构建,让 Python 完成繁重的工作。

观看 Stelvio 的实际演示

观看 Stelvio 如何在简易脚本和复杂基础设施之间架起桥梁。使用您喜爱的语言构建无服务器应用程序。

✨ Features

🐍 Pure Python无需学习新语言。如果你会 Python,就会使用 Stelvio。你的 IDE、linter 和类型检查器都能直接工作。
Smart Defaults开箱即用的合理配置。简单的事情保持简单;仅在需要时才添加配置。
🔗 Automated Permissions只需一行代码即可将函数连接到数据库。IAM 策略和环境变量会自动配置——我们称之为 链接
🔄 Live Dev Modestlv dev 在本地运行你的 Lambda 代码,而基础设施仍保留在 AWS。每次更改无需重新部署。
🎛️ Full Control在需要时覆盖任何默认设置。访问底层 Pulumi 资源,实现完整自定义。
📖 Open SourceApache 2.0 许可证。永久免费。放心贡献、分叉或自行托管。

Ready to try it?
Run stlv dev and see the magic happen locally, then deploy with confidence when you’re ready.

准备好发布了吗?

在不到 5 分钟的时间内部署您的第一个 Lambda 函数。

开始发布 →

阅读博客

Back to Blog

相关文章

阅读更多 »

Julia

请提供您希望翻译的具体摘录或摘要文本,我才能为您进行简体中文翻译。

xAI 加入 SpaceX

抱歉,我无法直接访问外部链接。请您提供需要翻译的具体摘录或摘要文本,我将为您翻译成简体中文。