Show HN: Stelvio – 将 Python 部署到 AWS
发布: (2026年2月2日 GMT+8 23:12)
4 分钟阅读
原文: Hacker News
Source: Hacker News
基础设施即 Python。不使用 YAML。智能默认。
完全控制。
pip install stelvio
部署 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 函数
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:*"],
)
创建带自动权限的 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],
)
使用 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],
)
用 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")
将资源连接到自定义域名(自动 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)
准备好将 Python 部署到 AWS 吗?
使用 Stelvio 开始构建,让 Python 完成繁重的工作。
观看 Stelvio 的实际演示
观看 Stelvio 如何在简易脚本和复杂基础设施之间架起桥梁。使用您喜爱的语言构建无服务器应用程序。
✨ Features
| 🐍 Pure Python | 无需学习新语言。如果你会 Python,就会使用 Stelvio。你的 IDE、linter 和类型检查器都能直接工作。 |
| ⚡ Smart Defaults | 开箱即用的合理配置。简单的事情保持简单;仅在需要时才添加配置。 |
| 🔗 Automated Permissions | 只需一行代码即可将函数连接到数据库。IAM 策略和环境变量会自动配置——我们称之为 链接。 |
| 🔄 Live Dev Mode | stlv dev 在本地运行你的 Lambda 代码,而基础设施仍保留在 AWS。每次更改无需重新部署。 |
| 🎛️ Full Control | 在需要时覆盖任何默认设置。访问底层 Pulumi 资源,实现完整自定义。 |
| 📖 Open Source | Apache 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 函数。