Deploy a Astro app on AWS
Deployment.io builds your Astro app from its repository and serves it from Amazon S3 and CloudFront in your own AWS account.
Before you start
- The app is in a GitHub, GitLab or Bitbucket repository that's connected to Deployment.io. See Adding a Repository.
- The site uses Astro's default static output. A project that needs a server (an adapter with
output: 'server') can't be deployed as a static site.
Deployment
- Create a new Static site on Deployment.io.
- Select your app's repository.
- Build command:
npm run build. - Publish directory:
dist. - Single-page app: No.
- Root directory: leave it empty unless the app lives in a subfolder of the repository (a monorepo). Then enter that folder.
- Choose the Environment and click Deploy static site.
Your site is available at the CloudFront URL shown in the dashboard once the build finishes. See Adding Custom Domains and Automatic Deployment on Git Push.
How the build runs
Deployment.io installs the app's dependencies before the build command, with the package manager its lockfile names — npm (package-lock.json), Yarn (yarn.lock) or pnpm (pnpm-lock.yaml). A packageManager field in package.json is honoured. So the build command is only the build itself — don't add an install step.
Builds run on Node.js 22, and package.json must be at the top of the repository or of the Root directory.
Environment variables
The environment's variables are available to the build. Astro puts only variables with the PUBLIC_ prefix into the code that runs in the browser. Read them with import.meta.env.
Anything in a static site's build is public — never put a secret there.
Routing
Astro writes each page as <path>/index.html by default, which is how Deployment.io serves a page's address.
With Single-page app set to No, an address with no page shows the site's 404.html with a 404 status, and an address without a trailing slash (such as /about) redirects to the one with it (/about/). If the site was already deployed with Yes, change the setting on its Settings tab; it applies on the next deploy.