Skip to content

Getting Started

Astro AWS is an Astro SSR adapter and constructs for deploying your Astro application to AWS.

IMPORTANT NOTE: These packages only provide the bare minimum AWS CDK configuration to get your application running. Everything that does not need to be configured uses the default values AWS provides.

Create a new Astro project using the create-astro CLI then add the Astro AWS adapter.

Terminal window
npm create astro@latest
npx astro add @astro-aws/adapter
Terminal window
yarn create astro@latest
yarn astro add @astro-aws/adapter
Terminal window
pnpm create astro@latest
pnpm astro add @astro-aws/adapter
Terminal window
### Using NPM
npm run build
# Using Yarn
yarn build
# Using PNPM
pnpm run build

Create a new AWS CDK project using the CDK cli.

Section titled “Create a new AWS CDK project using the CDK cli.”
Terminal window
npm i -g aws-cdk
mkdir my-cdk-project
cd my-cdk-project
cdk init app --language typescript
Terminal window
# Using NPM
npm i @astro-aws/constructs
# Using Yarn
yarn add @astro-aws/constructs
# Using PNPM
pnpm i @astro-aws/constructs

Modify lib/hello-cdk-stack.ts to contain the following

Section titled “Modify lib/hello-cdk-stack.ts to contain the following”
lib/hello-cdk-stack.ts
import { Stack } from "aws-cdk-lib/core"
import type { StackProps } from "aws-cdk-lib/core"
import { AstroAWS } from "@astro-aws/constructs"
export interface HelloCdkStackProps extends StackProps {}
export class HelloCdkStack extends Stack {
public constructor(scope: Construct, id: string, props: HelloCdkStackProps) {
super(scope, id, props)
new AstroAWS(this, "AstroAWS", {
websiteDir: "../my-astro-project",
})
}
}
Terminal window
cdk deploy