Skip to content

使用 SST 将你的 Astro 站点部署到 AWS

你可以使用 SST 将 Astro 站点部署到 AWS,SST 是一个用于部署具有 SSG 和 SSR 支持的现代全栈应用的开源框架。

¥You can deploy an Astro site to AWS using SST, an open-source framework for deploying modern full-stack applications with SSG and SSR support.

你还可以使用任何其他 SST 组件,如 Cron 作业、存储桶、队列等,同时保持类型安全。

¥You can also use any additional SST components like Cron Jobs, Buckets, Queues, etc while maintaining type-safety.

¥Quickstart

  1. Create an astro project.

  2. Run npx sst@latest init.

  3. It should detect that you are using Astro and ask you to confirm.

  4. Once you’re ready for deployment you can run npx sst deploy --stage production.

你还可以阅读 带有 SST 教程的完整 AWS Astro,它将指导你完成这些步骤。

¥You can also read the full Astro on AWS with SST tutorial that will guide you through the steps.

¥SST components

要使用任何 其他 SST 组件,请将它们添加到 sst.config.ts

¥To use any additional SST components, add them to sst.config.ts.

sst.config.ts
const bucket = new sst.aws.Bucket("MyBucket", {
access: "public",
});
new sst.aws.Astro("MyWeb", {
link: [bucket],
});

然后在 .astro 文件中访问它们。

¥And then access them in your .astro file.

---
import { Resource } from "sst"
console.log(Resource.MyBucket.name)
---

请参阅 SST 文档:链接资源 以了解更多信息。

¥Consult the SST docs on linking resources to learn more.

如果你有任何疑问,可以 在 SST Discord 中询问

¥If you have any questions, you can ask in the SST Discord.

More Deployment Guides

Astro 中文网 - 粤ICP备13048890号